|
87 | 87 | - name: Discover AWS VPC Subnets |
88 | 88 | when: infra__aws_subnet_ids is undefined |
89 | 89 | block: |
| 90 | + # Search using a wildcard on the subnet Name tag {{ plat__namespace }}* |
90 | 91 | - name: Query AWS Subnets |
91 | 92 | amazon.aws.ec2_vpc_subnet_info: |
92 | 93 | region: "{{ plat__region }}" |
93 | 94 | filters: |
94 | | - "tag:Name": "{{ plat__namespace }}" |
| 95 | + "tag:Name": "{{ plat__namespace }}*" |
95 | 96 | register: __aws_subnets_info |
96 | 97 |
|
97 | 98 | # NOTE: jenright I had to change this for Terraform created subnets, why? |
|
109 | 110 | ansible.builtin.set_fact: |
110 | 111 | plat__aws_subnet_ids: "{{ infra__aws_subnet_ids }}" |
111 | 112 |
|
112 | | -# TODO: Discover AWS VPC Public Subnets if infra__ is not present |
| 113 | +- name: jenright Debug value of plat__aws_subnet_ids |
| 114 | + ansible.builtin.debug: |
| 115 | + msg: |
| 116 | + - "infra__aws_subnet_ids: {{ infra__aws_subnet_ids | default('BLANK') }}" |
| 117 | + - "__aws_subnets_info: {{ __aws_subnets_info | default('BLANK') }}" |
| 118 | + - "plat__aws_subnet_ids: {{ plat__aws_subnet_ids | default('BLANK') }}" |
| 119 | + |
| 120 | +- name: Prompt added by jenright |
| 121 | + pause: |
| 122 | + prompt: "Check value of plat__aws_subnet_ids" |
| 123 | + when: debug_terraform | default(false) | bool |
| 124 | + |
113 | 125 | - name: Set public subnets for public endpoint access |
114 | 126 | when: plat__public_endpoint_access |
115 | | - ansible.builtin.set_fact: |
116 | | - plat__aws_public_subnet_ids: "{{ infra__aws_public_subnet_ids }}" |
117 | | - plat__endpoint_access_scheme: "PUBLIC" |
| 127 | + block: |
| 128 | + - name: Discover AWS Public Subnets |
| 129 | + when: infra__aws_public_subnet_ids is not defined |
| 130 | + block: |
| 131 | + - name: Print infra__vpc_public_subnets_info names |
| 132 | + debug: |
| 133 | + msg: |
| 134 | + - "{{ item }}" |
| 135 | + loop: "{{ infra__vpc_public_subnets_info | map(attribute='name' ) }}" |
| 136 | + |
| 137 | + # TODO: Change infra__vpc_public_subnets_info to plat__vpc_public_subnets_info |
| 138 | + - name: Query AWS Public Subnets |
| 139 | + amazon.aws.ec2_vpc_subnet_info: |
| 140 | + region: "{{ plat__region }}" |
| 141 | + filters: |
| 142 | + "tag:Name": "{{ item }}" |
| 143 | + loop: "{{ infra__vpc_public_subnets_info | map(attribute='name' ) }}" |
| 144 | + register: __aws_public_subnet_info |
| 145 | + |
| 146 | + - name: jenright Debug Print Discover AWS Public Subnets |
| 147 | + ansible.builtin.debug: |
| 148 | + msg: |
| 149 | + # - "{{ __aws_public_subnet_info }}" |
| 150 | + - "{{ __aws_public_subnet_info.results | community.general.json_query('[*].subnets[*].id') | flatten }}" |
| 151 | + |
| 152 | + - name: Set fact for AWS Public Subnets |
| 153 | + ansible.builtin.set_fact: |
| 154 | + # plat__aws_public_subnet_ids: "{{ __aws_public_subnet_info.subnets|map(attribute='id')| list }}" |
| 155 | + plat__aws_public_subnet_ids: "{{ __aws_public_subnet_info.results | community.general.json_query('[*].subnets[*].id') | flatten }}" |
| 156 | + plat__endpoint_access_scheme: "PUBLIC" |
| 157 | + |
| 158 | + - name: Set fact for AWS Public Subnets by assignment |
| 159 | + when: infra__aws_public_subnet_ids is defined |
| 160 | + ansible.builtin.set_fact: |
| 161 | + plat__aws_public_subnet_ids: "{{ infra__aws_public_subnet_ids }}" |
| 162 | + plat__endpoint_access_scheme: "PUBLIC" |
| 163 | + |
| 164 | +- name: jenright Debug Final Value of plat__aws_public_subnet_ids |
| 165 | + ansible.builtin.debug: |
| 166 | + var: plat__aws_public_subnet_ids |
| 167 | + |
| 168 | +- name: Prompt added by jenright |
| 169 | + pause: |
| 170 | + prompt: "Check value of AWS Public Subnets" |
| 171 | + when: debug_terraform | default(false) | bool |
118 | 172 |
|
119 | 173 | - name: Discover AWS Security Group for Knox |
120 | 174 | when: infra__aws_security_group_knox_id is undefined |
|
0 commit comments