Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /usr/lib/trove-setup/ansible/test # cat hosts
- localhost ansible_connection=local
- /usr/lib/trove-setup/ansible/test # cat test.yml
- ---
- - hosts: localhost
- tasks:
- - set_fact: TROVE_ID=example-trove
- - shell: |
- cat /etc/ssh/ssh_host_*_key.pub | cut -d\ -f1,2 | \
- sed -e's/^/'{{ TROVE_ID|regex_replace('(\\W)', '\\\\\\1')|quote }}',localhost /' > \
- /root/output
- creates=/root/output
- /usr/lib/trove-setup/ansible/test # ansible-playbook -vi hosts test.yml
- PLAY [localhost] **************************************************************
- GATHERING FACTS ***************************************************************
- ok: [localhost]
- TASK: [set_fact TROVE_ID=example-trove] ***************************************
- ok: [localhost] => {"ansible_facts": {"TROVE_ID": "example-trove"}}
- ERROR: an unexpected type error occured. Error was expected string or buffer
- ##################################
- ##################################
- /usr/lib/trove-setup/ansible/test # cat test2.yml
- ---
- - hosts: localhost
- tasks:
- - set_fact: TROVE_ID=example-trove
- - shell: |
- cat /etc/ssh/ssh_host_*_key.pub | cut -d\ -f1,2 | \
- sed -e's/^/'{{ TROVE_ID|quote }}',localhost /' > \
- /root/output
- /usr/lib/trove-setup/ansible/test # ansible-playbook -vi hosts test2.yml
- PLAY [localhost] **************************************************************
- GATHERING FACTS ***************************************************************
- ok: [localhost]
- TASK: [set_fact TROVE_ID=example-trove] ***************************************
- ok: [localhost] => {"ansible_facts": {"TROVE_ID": "example-trove"}}
- TASK: [shell cat /etc/ssh/ssh_host_*_key.pub | cut -d\ -f1,2 | \
- sed -e's/^/'{{TROVE_ID|quote}}',localhost /' > \
- /root/output
- creates=/root/output
- ] ***
- changed: [localhost] => {"changed": true, "cmd": "cat /etc/ssh/ssh_host_*_key.pub | cut -d\\ -f1,2 | \\\nsed -e's/^/'example-trove',localhost /' > \\\n/root/output ", "delta": "0:00:00.003124", "end": "2014-07-14 12:10:43.522656", "rc": 0, "start": "2014-07-14 12:10:43.519532", "stderr": "", "stdout": ""}
- PLAY RECAP ********************************************************************
- localhost : ok=3 changed=1 unreachable=0 failed=0
- /usr/lib/trove-setup/ansible/test # rm /root/output
- ################################
- ################################
- /usr/lib/trove-setup/ansible/test # ansible-playbook -vi hosts test3.yml
- PLAY [localhost] **************************************************************
- GATHERING FACTS ***************************************************************
- ok: [localhost]
- TASK: [set_fact TROVE_ID=example-trove] ***************************************
- ok: [localhost] => {"ansible_facts": {"TROVE_ID": "example-trove"}}
- TASK: [With a name it doesn't crash] ******************************************
- changed: [localhost] => {"changed": true, "cmd": "cat /etc/ssh/ssh_host_*_key.pub | cut -d\\ -f1,2 | \\\nsed -e's/^/''example\\-trove'',localhost /' > \\\n/root/output ", "delta": "0:00:00.003102", "end": "2014-07-14 12:10:52.338362", "rc": 0, "start": "2014-07-14 12:10:52.335260", "stderr": "", "stdout": ""}
- PLAY RECAP ********************************************************************
- localhost : ok=3 changed=1 unreachable=0 failed=0
Advertisement
Add Comment
Please, Sign In to add comment