Closed n0one42 closed 1 week ago
Got the same issue and
{% raw %}{{ var_name }}{% endraw %}
is not working
Here is my workflow:
id: infrastructure_automation
namespace: tutorial
tasks:
- id: setup
type: io.kestra.plugin.core.flow.WorkingDirectory
tasks:
- id: load_ssh_key
type: io.kestra.plugin.core.storage.LocalFiles
inputs:
inventory.ini: |
docker2 ansible_host=192.168.1.72 new_hostname=docker2
playbook.yml: |
---
- name: Update package
hosts: all
become: True
tasks:
- name: Update apt package index
ansible.builtin.apt:
update_cache: yes
- name: Upgrade all apt packages
ansible.builtin.apt:
upgrade: dist
- name: Set the hostname
hostname:
name: "{% raw %}{{new_hostname}}{% endraw %}"
- name: Ensure /etc/hosts is updated with the new hostname
lineinfile:
path: /etc/hosts
regexp: "^127\.0\.1\.1\s+"
line: "127.0.1.1 {% raw %}{{new_hostname}}{% endraw %}"
state: present
- name: Reboot the server
shell: sleep 2 && shutdown -r now
async: 1
poll: 0
ignore_errors: true
- name: Wait for the reboot to complete if there was a change.
wait_for_connection:
connect_timeout: 20
sleep: 5
delay: 5
timeout: 300
id_rsa: "{{ secret('SSH_KEY') }}"
- id: "bash"
type: "io.kestra.core.tasks.scripts.Bash"
commands:
- 'chmod 600 id_rsa'
- id: ansible_task
type: io.kestra.plugin.ansible.cli.AnsibleCLI
docker:
image: cytopia/ansible:latest-tools
commands:
- ansible-playbook -i inventory.ini --key-file id_rsa playbook.yml
env:
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_REMOTE_USER: "root"
ANSIBLE_USER: "root"
ANSIBLE_PRIVATE_KEY_FILE: id_rsa
Environment Kestra Version: latest Operating System (Docker):
@loicmathieu
Can you help us this is very blocking
So the issue was that we render twice the file content, I fixed it, it will be backported for our next bugfix release on 0.17
Describe the issue
Like I already wrote in this post: https://github.com/kestra-io/kestra/issues/4087 which was instantly closed without even waiting for an answer like everyone would be just dump, I will ask it here again.
Also the
line: {% raw %}{{ item }}{% endraw %}
does not work in this case like described in the documentation.throws the error:
Doing the same but inside a real playbook file and executing it like this, does work.
pb_temp.yml
content.So a simple how to this line should looks like would be enough. What is wrong in this:
line: {% raw %}{{ item }}{% endraw %}
Environment