|
13 | 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | | - |
17 | | -- name: Discover GCP VPC |
18 | | - google.cloud.gcp_compute_network_info: |
19 | | - project: "{{ run__gcp_project }}" |
20 | | - filters: |
21 | | - - name = "{{ run__vpc_name }}" |
22 | | - register: __gcp_vpc_discovered |
23 | | - |
24 | | -- name: Set GCP VPC Details |
25 | | - when: |
26 | | - - __gcp_vpc_discovered is defined |
27 | | - - __gcp_vpc_discovered.resources is defined |
28 | | - - __gcp_vpc_discovered.resources | length > 0 |
29 | | - ansible.builtin.set_fact: |
30 | | - run__gcp_vpc_discovered: "{{ __gcp_vpc_discovered.resources[0] }}" |
31 | | - |
32 | | -# GCP Filter by network name doesn't seem to work with the Ansible Collection, thus the below construction |
33 | | -- name: Discover GCP Subnets |
34 | | - when: |
35 | | - - run__gcp_vpc_discovered is defined |
36 | | - - run__gcp_vpc_discovered | length > 0 |
37 | | - register: __gcp_subnets_discovered |
38 | | - google.cloud.gcp_compute_subnetwork_info: |
39 | | - region: "{{ run__region }}" |
40 | | - filters: |
41 | | - - "name = {{ run__namespace }}*" |
42 | | - project: "{{ run__gcp_project }}" |
43 | | - |
44 | | -# TODO Refactor to follow AWS discovery/assignment process |
45 | | -- name: Set GCP Subnet Details |
46 | | - when: |
47 | | - - __gcp_subnets_discovered is defined |
48 | | - - __gcp_subnets_discovered.resources is defined |
49 | | - - __gcp_subnets_discovered.resources | length > 0 |
50 | | - #- __gcp_subnet_item.selfLink in run__gcp_vpc_discovered.subnetworks |
51 | | - ansible.builtin.set_fact: |
52 | | - run__datahub_subnet_ids: "{{ __gcp_subnets_discovered | community.general.json_query('resources[*].name') }}" |
0 commit comments