-
-
Save craigforr/7c139a22e775879251dab59fd4c266f6 to your computer and use it in GitHub Desktop.
ansible - example of using lookup and a template to generate dynamic list entries for modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#jinja2:trim_blocks: True, lstrip_blocks: True | |
targets: | |
{% for privnet in all_private_subnets %} | |
- subnet_id: "{{ privnet }}" | |
security_groups: [ "{{ sg.group_id }}" ] | |
{% endfor %} | |
{% for pubnet in all_public_subnets %} | |
- subnet_id: "{{ pubnet }}" | |
security_groups: [ "{{ sg.group_id }}" ] | |
{% endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
gather_facts: False | |
connection: local | |
tasks: | |
- efs: | |
state: present | |
name: "{{ region }}-{{ service }}" | |
tags: | |
name: "{{ region }}-{{ service }}" | |
purpose: "{{ service }}" | |
deploy_env: "{{ deploy_env }}" | |
vpc: "{{ vpc_id }}" | |
targets: "{{ lookup('template', 'efs_targets.j2') | from_yaml }}" | |
register: ec2_efs | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment