March 2019
Intermediate to advanced
412 pages
9h 49m
English
When wanting to pass complex data to included tasks, such as a list or hash, an alternative syntax can be used when including the file. Let's repeat the last scenario, only this time instead of including the task file twice, we'll include it once and pass a hash of the paths and files in. First, we'll recreate the files.yaml file:
--- - name: create leading path file: path: "{{ item.value.path }}" state: directory with_dict: "{{ files }}" - name: touch the file file: path: "{{ item.value.path + '/' + item.key }}" state: touch with_dict: "{{ files }}"
Now we'll alter our includer.yaml playbook to provide the files hash in a single include statement:
---- name: touch files hosts: localhost gather_facts: ...
Read now
Unlock full access