Doesn't the ec2_facts module already query user-data and parse into usable data?
I was pretty sure it did. On Monday, March 17, 2014, Ben Turner <[email protected]> wrote: > Looks like all "user-data" in AWS is just a "string" at the end of the day. > > So there is no way for Ansible to parse that string and pull out values, > without a third-party module such as > https://github.com/jpmens/ansible-ec2-userdata say ? > > Ben > > > On 15 March 2014 01:39, Michael DeHaan > <[email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');> > > wrote: > >> In your Debug output it looks like it came out that way because that was >> what got stored there. >> >> >> >> >> On Thu, Mar 13, 2014 at 10:27 PM, Ben Turner <[email protected]>wrote: >> >> I tried out some more debug statements; the .json suffix doesn't appear >> to be present ? >> >> The user-data "json" appears to be coming back as a string... >> >> TASK: [common | debug var=user_data] >> ****************************************** >> ok: [ec2-54-253-114-32.ap-southeast-2.compute.amazonaws.com] => { >> "item": "", >> "user_data": { >> "accept_ranges": "bytes", >> "changed": false, >> "connection": "close", >> "content": "{\"hostname\":\"qa\"}", >> "content_length": "17", >> "content_location": "http://169.254.169.254/latest/user-data", >> "content_type": "application/octet-stream", >> "date": "Fri, 14 Mar 2014 02:26:12 GMT", >> "etag": "\"1016948274\"", >> "invocation": { >> "module_args": >> "url=http://169.254.169.254/latest/user-datareturn_content=yes", >> "module_name": "uri" >> }, >> "item": "", >> "last_modified": "Thu, 13 Mar 2014 22:02:44 GMT", >> "redirected": false, >> "server": "EC2ws", >> "status": 200 >> } >> } >> >> TASK: [common | debug var=user_data.json] >> ************************************* >> ok: [ec2-54-253-114-32.ap-southeast-2.compute.amazonaws.com] => { >> "item": "", >> "user_data.json": "{{ user_data.json }}" >> } >> >> TASK: [common | debug var=user_data.content.json] >> ***************************** >> ok: [ec2-54-253-114-32.ap-southeast-2.compute.amazonaws.com] => { >> "item": "", >> "user_data.content.json": "{{ user_data.content.json }}" >> } >> >> >> >> On 14 March 2014 12:15, Romeo Theriault <[email protected]>wrote: >> >> Hi Ben, If you want to access the JSON data it's available in the json >> subkey. So instead of: >> >> {{ user_data.content.hostname }} >> >> I believe it would be >> >> {{ user_data.json.hostname }} >> >> or something similar. >> >> Take a look at the {{ user_data.json }} or {{ user_data }} output with >> the debug module to get a better idea. >> >> Hope that helps, >> Romeo >> >> On Thu, Mar 13, 2014 at 2:35 PM, Ben Turner <[email protected]> wrote: >> > I've been trying to use the user-data provided by EC2 servers to >> determine a >> > servers hostname. >> > >> > So currently new server come up with a hostname of >> "ec2-123-234-345-456" or >> > similar, and I'd like in my ansible script to rename that server to >> > something like "demonstration". >> > >> > To do this, I've gone into my EC2 console, and added the following as >> > user-data to my server: >> > >> > {"hostname": "demonstration"} >> > >> > Then, in my ansible playbook, I >> >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/CAEVJ8QMV-vmK04X5wpfkm2YWg%2BveHsSjAvZda4MvZzvgCLqRcw%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAEVJ8QMV-vmK04X5wpfkm2YWg%2BveHsSjAvZda4MvZzvgCLqRcw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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]<javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');> > . > To post to this group, send email to > [email protected]<javascript:_e(%7B%7D,'cvml','[email protected]');> > . > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/CAGxBzUGZvyNkjYTnpa5E16o90To9BqUUtX-pO9EcbHwmy0L3QQ%40mail.gmail.com<https://groups.google.com/d/msgid/ansible-project/CAGxBzUGZvyNkjYTnpa5E16o90To9BqUUtX-pO9EcbHwmy0L3QQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Matt Martz [email protected] http://sivel.net/ -- 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 post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAD8N0v-at5fizNoDfW6iYdk4WSHDskZwz2Ro4ekroqedR4BdVQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
