300-635 · Question #56
Which iteration creates three EPGs in Cisco ACI using an Ansible task? Some required aci_epg task attributes have been omitted for brevity.
The correct answer is B. ``` aci_epg: epg: "{{ item.epg }}" loop: - epg:epg1 - epg:epg2 - epg:epg3 ```. Option B is correct because each list element is a valid YAML dictionary with the key epg, which matches exactly what {{ item.epg }} expects - when Ansible iterates, item becomes {epg: epg1}, so item.epg correctly resolves to epg1, epg2, and epg3. Option A fails because the dicti
Question
Options
- A
aci_epg: epg: "{{ item.epg }}" loop: - item: epg1 - item: epg2 - item: epg3 - B
aci_epg: epg: "{{ item.epg }}" loop: - epg:epg1 - epg:epg2 - epg:epg3 - C
aci_epg: epg: "{{ item.epg }}" loop: - item: "{{ epg1 }}" - item: "{{ epg2 }}" - item: "{{ epg3 }}" - D
aci_epg: epg: "{{ item.epg }}" loop: - epg:"{{ epg1 }}" - epg:"{{ epg2 }}" - epg:"{{ epg3 }}"
How the community answered
(44 responses)- A2% (1)
- B80% (35)
- C7% (3)
- D11% (5)
Explanation
Option B is correct because each list element is a valid YAML dictionary with the key epg, which matches exactly what {{ item.epg }} expects - when Ansible iterates, item becomes {epg: epg1}, so item.epg correctly resolves to epg1, epg2, and epg3.
Option A fails because the dictionary key is item, not epg - so item.epg resolves to undefined at runtime, even though the YAML itself is syntactically valid.
Option C has two problems: it also uses item as the key (same fatal flaw as A), and it wraps the EPG names in Jinja2 braces ({{ epg1 }}), which would reference undefined variables rather than literal string values.
Option D is invalid YAML - epg:"{{ epg1 }}" has no space after the colon, which breaks YAML parsing before Ansible even runs; it also references undefined variables like Option C.
Memory tip: Match the key in your loop list to what comes after the dot in item.<key>. If your task says item.epg, every loop entry must be epg: <value> - think of it as "the dot tells you the key."
Topics
Community Discussion
No community discussion yet for this question.