Hi all

I am trying to pass the ansible hostnames as an array list to python script
but could not figure out where the extra characters are coming from. I am
passing with ansible_play_hosts_all variable.
In my host file there are 2 hoosts 1ld501 and 1ld994. but it is passing
some unexpected character marked in red.

*Playbook:*
---
- 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!"
    ]
}

Regards
PD

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEuB3ApSzymExcc7Auzp7P-v%2BxqYWiRp9GyWF%3Dzt2mQrC14Y%2BQ%40mail.gmail.com.

Reply via email to