Ansible: Appending items to a List: Difference between revisions
(Created page with "Simple task to append items to a list <nowiki> - name: Append items to a list hosts: localhost gather_facts: false vars: mylist: [] tasks: - name: Append list with additional mapping ansible.builtin.set_fact: mylist: "{{ mylist + [{'name': 'blabla', 'mode': 1}] }}" - name: Append list with additional mapping ansible.builtin.set_fact: mylist: "{{ mylist + [{'name': 'yoyoyo', 'mode': 2}] }}" - name: Print the updated...") |
(No difference)
|
Latest revision as of 20:37, 13 March 2024
Simple task to append items to a list
- name: Append items to a list hosts: localhost gather_facts: false vars: mylist: [] tasks: - name: Append list with additional mapping ansible.builtin.set_fact: mylist: "{{ mylist + [{'name': 'blabla', 'mode': 1}] }}" - name: Append list with additional mapping ansible.builtin.set_fact: mylist: "{{ mylist + [{'name': 'yoyoyo', 'mode': 2}] }}" - name: Print the updated list ansible.builtin.debug: msg: "{{ item.name }}" with_items: - "{{ mylist }}"