On Mon, 17 Mar 2014, Matt Martz wrote:

It is actually possible to use set_fact with json data already, or to use info 
from json data for pretty much anything.  You just need to use the from_json 
filter.

- set_fact:
    hostname: "{{ (user_data.content|from_json).hostname }}"

or in the example given:

- name: Set hostname from user data                                             
                                                                                
                                               
  command: "hostname {{ (user_data.content|from_json).hostname }}"              
                                                                                          
                                                        
  when: user_data is defined

Right, didn't think of doing it like this. Quite powerful indeed.

Thanks :)

--
-- dag wieers, [email protected], http://dag.wieers.com/
-- dagit linux solutions, [email protected], http://dagit.net/

[Any errors in spelling, tact or fact are transmission errors]

--
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/alpine.LRH.2.02.1403171337300.6649%40pikachu.3ti.be.
For more options, visit https://groups.google.com/d/optout.

Reply via email to