You’re setting a dict to one of its own keys - I think that doesn’t work or
at least results in nothing. But the union of that and dns_parsed will be
the dns_parsed.

You could look into the ‘combine’ filter to overwrite a specific key.

Dick

On Thu, 20 Jun 2019 at 12:01, Punit Jain <[email protected]> wrote:

> Hi,
>
> I have a fact as below:
>
> "dns_parsed": [
>     "10.4.3.2"
> ]
>
> and another fact as:
>
> "actual_config": {
>     "dns": {
>         "domains": ['test.com'],
>         "servers": []
>       }
>  }
>
> I want to update actual_config to make it:
>
> "actual_config": {
>     "dns": {
>         "domains": ['test.com'],
>         "servers": ["10.4.3.2"]
>       }
>  }
>
> my playbook part to accomplish this:
>
> - name: merge dns data
>   set_fact:
>     actual_config: "{{ actual_config.dns.servers | union(dns_parsed) }}"
>
> - debug:
>   var=actual_config
>
> however it removes all other keys from actual_config.
>
> "actual_config": [
>       "10.4.3.2"
> ]
>
> Any clue how to make it work ?
>
> Thanks and Regards,
> Punit
>
>
> --
> 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/CAFXWBQ%2B0qy-kpxWOPkBDYw-Htq99Gm4cc53JE2JO_gG1zVSB-A%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAFXWBQ%2B0qy-kpxWOPkBDYw-Htq99Gm4cc53JE2JO_gG1zVSB-A%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
-- 
Sent from a mobile device - please excuse the brevity, spelling and
punctuation.

-- 
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/CAL8fbwO%3DDVLPd_h7VOTeNrj6Jk7dLBOSmwF205zCh%2Bdo3k7kqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to