John_Test
(John Test)
April 27, 2015, 11:37am
1
Hello
I have a question regarding user_data parameter for nova_compute
http://docs.ansible.com/nova_compute_module.html
Is it possible to see some examples?
What I am trying to do:
Pass information to run commands / install software inside the instance after it is launched
Thanks!
John_Test
(John Test)
April 30, 2015, 5:34pm
2
Figured it out thanks to sivel on IRC.
In case anyone else is wondering just do a lookup(‘file’, ‘filename’)
The file called “filename” can be a bash script file, cloud init file, etc.
Make sure the file starts with the appropriate header such as
#!/bin/bash or #cloud-config etc.
lookup('pipe', 'script') might be more appropriate, it will succeed in
many cases that file will fail.
John_Test
(John Test)
April 30, 2015, 11:58pm
4
pipe is failing on me
pb_set_proxy: “{{ lookup(‘pipe’, ‘proxy-set.sh’) }}”
/bin/sh: 1: proxy-set.sh: not found
ERROR: lookup_plugin.pipe(proxy-set.sh) returned 127
I know it says not found but it is present and in same dir.
I actually have another problem
I am using 2 user_data parameters like this in the same nova_compute task
user_data: “{{ lookup(‘file’, ‘proxy-set.sh’) }}”
user_data: “{{ lookup(‘file’, ‘misc-install.sh’) }}”
Only the misc-install.sh is working and the proxy-set.sh is not.
What’s the correct way to do this?
Thanks!
sivel
(sivel)
May 1, 2015, 12:02am
5
I don’t really think pipe is what you need. pipe executes a command and returns the result. I think ‘file’ is still appropriate.
As far as your double user_data, you can only include one “blob” of data. You could try concatenating the scripts such as:
user_data: “{{ lookup(‘file’, ‘proxy-set.sh’) ~ ‘\n’ ~ lookup(‘file’, ‘misc-install.sh’) }}”
ah, misunderstood, thought you wanted data from executing the script,
not to upload the script itself as data.