virsh command issue with ansible. launching command within $()

39 views
Skip to first unread message

Alex Dodson

unread,
Sep 23, 2014, 4:22:09 AM9/23/14
to ansible...@googlegroups.com
Hello All,

I have a command to run. Here is a demo of it from the ceph doco

sudo virsh secret-set-value --secret 457eb676-33da-42ec-9a8c-9293d545c337 --base64 $(cat client.cinder.key)

when I try to shell: the command below the cat command within the $() doesnt run. It outputs in a specific format I can't quite match with tr so catting it normally and removing tabs and new lines does not work for me.

virsh secret-set-value --secret 457eb676-33da-42ec-9a8c-9293d545c337 --base64 $(cat client.cinder.key)

When I try to shell:  the below to set it as a variable I get
$(cat client.cinder.key)

failed: [hostname] => {"changed": true, "cmd": "$(cat keyring)", "delta": "0:00:00.008503", "end": "2014-09-23 07:55:37.978874", "rc": 127, "start": "2014-09-23 07:55:37.970371"}
stderr: /bin/sh: [client.cinder]: command not found

[client.cinder] is the first line within the file I cat so for w/e reason it is trying to execute that it appears.

Any ideas how to stop that occuring?

thanks,
Alex




James Cammarata

unread,
Sep 23, 2014, 3:08:13 PM9/23/14
to ansible...@googlegroups.com
Hi Alex, are you breaking this command up over multiple lines by any chance? With the current devel branch, the shell module will interpret newlines as the start of a new command to execute, so doing this:

- shell: |
    echo
    $(cat /path/to/foo)

will result in the contents of the file "foo" being executed similar to what you're seeing above.


--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6106f348-5b54-4f7f-a33d-36cf7ab8dd94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael DeHaan

unread,
Sep 23, 2014, 4:37:56 PM9/23/14
to ansible...@googlegroups.com
Might be good to share the playbook line where you are calling virsh?



Reply all
Reply to author
Forward
0 new messages