In my host file there are 2 hoosts 1ld501 and 1ld994. but it is passing some unexpected character marked in red.
---
- name: Execute writetoexcel python
script: ./roles/writetoexcel.py {{ ansible_play_hosts_all }}
args:
executable: python3
delegate_to: localhost
Output:
<localhost> EXEC /bin/sh -c ' python3 /root/.ansible/tmp/ansible-tmp-1687354259.71-24015-237464957552077/writetoexcel.py [u'"'"'1ld501'"'"', u'"'"'1ld994'"'"'] && sleep 0'
changed: [1ld501 -> localhost] => {
"changed": true,
"rc": 0,
"stderr": "",
"stderr_lines": [],
"stdout": "[['[u1ld501,', 'u1ld994]']]\nData written to Excel successfully!\n",
"stdout_lines": [
"[['[u1ld501,', 'u1ld994]']]",
"Data written to Excel successfully!"
]
}
Tried with Ansible_hostname no extra characters are there. It is as expected. Please suggest.
Playbook:
---
- name: Execute writetoexcel python
script: ./roles/writetoexcel.py {{ ansible_hostname }}
args:
executable: python3
delegate_to: localhost
Output:
<localhost> EXEC /bin/sh -c ' python3 /root/.ansible/tmp/ansible-tmp-1687354332.97-25377-185430066289739/writetoexcel.py 1ld994 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1687354332.95-25376-35834468227973/ > /dev/null 2>&1 && sleep 0'
changed: [jp1ld501 -> localhost] => {
"changed": true,
"rc": 0,
"stderr": "",
"stderr_lines": [],
"stdout": "[['1ld994']]\nData written to Excel successfully!\n",
"stdout_lines": [
"[['1ld994']]",
"Data written to Excel successfully!"
]
}