Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- - hosts: localhost
- connection: local
- gather_facts: no
- vars:
- dict_one:
- dict_two:
- variables:
- test: please-change-me # <-- I want to just change this variable.
- another: value
- dict_four:
- test: another unique example
- tasks:
- - name: Change dict_one.dict_two.variables.test to "changed".
- set_fact:
- dict_one_changes: "{{ dict_one.dict_two.variables|combine({'test': 'changed'}) }}"
- - debug: var=dict_one_changes
- # "dict_one_changes": {
- # "another": "value",
- # "test": "changed"
- # }
- - name: Merge changes back into dict_one.
- set_fact:
- dict_one: "{{ dict_one|combine(dict_one_changes) }}"
- - debug: var=dict_one
- # "dict_one": {
- # "another": "value",
- # "dict_four": {
- # "test": "example to not be overridden"
- # },
- # "dict_two": {
- # "variables": {
- # "another": "value",
- # "test": "please-change-me"
- # }
- # },
- # "test": "changed" <-- combined dict change goes to root level
- # }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement