On 09.05.2018 07:56, Marcos Georgopoulos wrote:
Hi can someone please explain why the following two seperate 'set_fact's
work.

  - name : combine network and wildcard
    set_fact:
       net_mask: "{{ '{{network}}/{{wildcard}}' }}"
    when: ansible_network_os == 'asa'

You can't use {{ }} inside {{ }}
So correct syntax is

  - name : combine network and wildcard
    set_fact:
       net_mask: '{{network}}/{{wildcard}}'
    when: ansible_network_os == 'asa'


  - name : determine netmask from wildcard
    set_fact:
        mynetmask: "{{ net_mask  |ipaddr('netmask') }}"
    when: ansible_network_os == 'asa'


But this 'combined' effort doesn't work

  - name : determine netmask from network and wildcard
    set_fact:
mynetmask : "{{ '{{network}}/{{wildcard}}' |ipaddr('netmask') }}"
    when: ansible_network_os == 'asa'

  - name : determine netmask from network and wildcard
    set_fact:
mynetmask : "{{ (network ~ '/' ~ wildcard) |ipaddr('netmask') }}"
    when: ansible_network_os == 'asa'


I'm trying to understand the limitations of set_facts.

There is no limitation, you just need to use the correct jinja2 syntax.

--
Kai Stian Olstad

--
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/03610abc43254f71c1079abe748610e4%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to