Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- - hosts: localhost
- connection: local
- gather_facts: false
- tasks:
- - name: "Set the test facts"
- set_fact:
- new_inner_dict:
- foo: "bar"
- full_dict:
- outer_key: "outer key value"
- outer_dict:
- inner_key: "inner key value"
- inner_dict:
- foo: "bar"
- remove: "me"
- - name: "This is the full dictionary"
- debug:
- var: full_dict
- - name: erase inner_dict
- set_fact:
- full_dict: "{{ full_dict | combine({'outer_dict': {'inner_dict': None }}, recursive=True) }}"
- - name: "Use 'combine' to set inner_dict to a dictionary that does not have 'remove: me' item"
- set_fact:
- full_dict: "{{ full_dict | combine({'outer_dict': {'inner_dict': new_inner_dict }}, recursive=True) }}"
- - name: "Now notice the 'remove: me' item is gone from the inner_dict"
- debug:
- var: full_dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement