Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Post History
Turns out I wasn't far off. The dictionary mustn't be quoted. So the following works: - name: Extraction test vars: dictionary: one: 1 two: 2 key_list: - one ...
Answer
#2: Post edited
- Turns out I wasn't far off. The `dictionary` mustn't be quoted.
- So the following works:
```ansible- - name: Extraction test
- vars:
- dictionary:
- one: 1
- two: 2
- key_list:
- - one
- - two
- extracted: "{{ key_list | map('extract', dictionary) }}"
- ansible.builtin.debug:
- var: extracted
- ```
- Turns out I wasn't far off. The `dictionary` mustn't be quoted.
- So the following works:
- ```yaml
- - name: Extraction test
- vars:
- dictionary:
- one: 1
- two: 2
- key_list:
- - one
- - two
- extracted: "{{ key_list | map('extract', dictionary) }}"
- ansible.builtin.debug:
- var: extracted
- ```