0
Follow
0
View

Ansible update existing hash values for custom keys

csfxxaq 注册会员
2023-01-25 05:45

For example

  some_hash:
    name1:
      limits:
        max: "{{ rare_case|d(1) }}"
        min: "{{ rare_case|d(2) }}"
    name2:
      limits:
        max: "{{ rare_case|d(10) }}"
        min: "{{ rare_case|d(5) }}"

expands by default to

  some_hash:
    name1:
      limits:
        max: '1'
        min: '2'
    name2:
      limits:
        max: '10'
        min: '5'

In the rare case the dictionary expands to

shell> ansible-playbook playbook.yml -e rare_case=0

  ...

  some_hash:
    name1:
      limits:
        max: '0'
        min: '0'
    name2:
      limits:
        max: '0'
        min: '0'

About the Author

Question Info

Publish Time
2023-01-25 05:45
Update Time
2023-01-25 05:45