|
5 | 5 | cidr_block: "{{ awx_stack.runners.aws.vpc.cidr }}" |
6 | 6 | region: "{{ awx_cluster.aws.region }}" |
7 | 7 | state: present |
8 | | - register: vpc_info |
| 8 | + register: awx_vpc_info |
9 | 9 |
|
10 | 10 | - name: Create an Internet Gateway associated with VPC |
11 | 11 | amazon.aws.ec2_vpc_igw: |
12 | | - vpc_id: "{{ vpc_info.vpc.id }}" |
| 12 | + vpc_id: "{{ awx_vpc_info.vpc.id }}" |
13 | 13 | region: "{{ awx_cluster.aws.region }}" |
14 | 14 | state: present |
15 | | - register: igw_info |
| 15 | + register: awx_igw_info |
16 | 16 |
|
17 | 17 | - name: Create a subnet for each cluster |
18 | 18 | amazon.aws.ec2_vpc_subnet: |
19 | | - vpc_id: "{{ vpc_info.vpc.id }}" |
| 19 | + vpc_id: "{{ awx_vpc_info.vpc.id }}" |
20 | 20 | cidr: "{{ awx_stack.runners.aws.subnet.public_base }}.{{ item * 2 }}.0/23" |
21 | 21 | az: "{{ awx_cluster.aws.zones[0] }}" |
22 | 22 | region: "{{ awx_cluster.aws.region }}" |
|
26 | 26 | Name: "{{ awx_stack.name_prefix }}-public-subnet-{{ item }}" |
27 | 27 | Environment: k8s |
28 | 28 | ManagedBy: ansible |
29 | | - loop: "{{ range(1, (cluster_names | length) + 1) }}" |
30 | | - register: public_subnets |
| 29 | + loop: "{{ range(1, (awx_cluster_names | length) + 1) }}" |
| 30 | + register: awx_public_subnets |
31 | 31 |
|
32 | 32 | - name: Parse subnet ids |
33 | 33 | ansible.builtin.set_fact: |
34 | | - subnet_ids: "{{ public_subnets.results | community.general.json_query('[*].subnet.id') }}" |
| 34 | + subnet_ids: "{{ awx_public_subnets.results | community.general.json_query('[*].subnet.id') }}" |
35 | 35 |
|
36 | 36 | - name: Create a route table for public subnets |
37 | 37 | amazon.aws.ec2_vpc_route_table: |
38 | | - vpc_id: "{{ vpc_info.vpc.id }}" |
| 38 | + vpc_id: "{{ awx_vpc_info.vpc.id }}" |
39 | 39 | region: "{{ awx_cluster.aws.region }}" |
40 | 40 | subnets: "{{ subnet_ids }}" |
41 | 41 | routes: |
42 | 42 | - dest: "0.0.0.0/0" |
43 | | - gateway_id: "{{ igw_info.gateway_id }}" |
| 43 | + gateway_id: "{{ awx_igw_info.gateway_id }}" |
44 | 44 | tags: |
45 | 45 | Name: "{{ awx_stack.name_prefix }}-public-route-table" |
46 | 46 | Creator: "ansible" |
|
58 | 58 | - --topology |
59 | 59 | - public |
60 | 60 | - --network-id |
61 | | - - "{{ vpc_info.vpc.id }}" |
| 61 | + - "{{ awx_vpc_info.vpc.id }}" |
62 | 62 | - --subnets |
63 | 63 | - "{{ item[1] }}" |
64 | 64 | - --zones |
|
76 | 76 | - --networking |
77 | 77 | - "{{ awx_cluster.networking.mode }}" |
78 | 78 | - --state |
79 | | - - "{{ state_store }}" |
| 79 | + - "{{ awx_kops_state_store }}" |
80 | 80 | async: 600 |
81 | | - loop: "{{ cluster_names | zip(subnet_ids) }}" |
| 81 | + loop: "{{ awx_cluster_names | zip(subnet_ids) }}" |
82 | 82 | poll: 0 |
83 | | - register: async_create_results |
| 83 | + register: awx_async_create_results |
84 | 84 |
|
85 | 85 | - name: Wait for asynchronous operations to complete |
86 | 86 | ansible.builtin.async_status: |
87 | 87 | jid: "{{ item.ansible_job_id }}" |
88 | | - loop: "{{ async_create_results.results }}" |
| 88 | + loop: "{{ awx_async_create_results.results }}" |
89 | 89 | register: async_create_poll_results |
90 | 90 | until: async_create_poll_results.finished |
91 | 91 | delay: 30 |
|
95 | 95 | ansible.builtin.async_status: |
96 | 96 | mode: cleanup |
97 | 97 | jid: "{{ item.ansible_job_id }}" |
98 | | - loop: "{{ async_create_results.results }}" |
| 98 | + loop: "{{ awx_async_create_results.results }}" |
99 | 99 |
|
100 | 100 | - name: Asynchronously build kOps clusters |
101 | 101 | ansible.builtin.command: |
|
106 | 106 | - --name |
107 | 107 | - "{{ item }}" |
108 | 108 | - --state |
109 | | - - "{{ state_store }}" |
| 109 | + - "{{ awx_kops_state_store }}" |
110 | 110 | - --yes |
111 | 111 | - --internal |
112 | 112 | - --create-kube-config=false |
113 | 113 | async: 600 |
114 | | - loop: "{{ cluster_names }}" |
| 114 | + loop: "{{ awx_cluster_names }}" |
115 | 115 | poll: 0 |
116 | | - register: async_update_results |
| 116 | + register: awx_async_update_results |
117 | 117 |
|
118 | 118 | - name: Wait for asynchronous operations to complete |
119 | 119 | ansible.builtin.async_status: |
120 | 120 | jid: "{{ item.ansible_job_id }}" |
121 | | - loop: "{{ async_update_results.results }}" |
| 121 | + loop: "{{ awx_async_update_results.results }}" |
122 | 122 | register: async_update_poll_results |
123 | 123 | until: async_update_poll_results.finished |
124 | 124 | delay: 30 |
|
128 | 128 | ansible.builtin.async_status: |
129 | 129 | mode: cleanup |
130 | 130 | jid: "{{ item.ansible_job_id }}" |
131 | | - loop: "{{ async_update_results.results }}" |
| 131 | + loop: "{{ awx_async_update_results.results }}" |
132 | 132 |
|
133 | 133 | - name: Export the kubeconfigs for the clusters |
134 | 134 | ansible.builtin.command: |
|
140 | 140 | - kubecfg |
141 | 141 | - --admin |
142 | 142 | - --state |
143 | | - - "{{ state_store }}" |
| 143 | + - "{{ awx_kops_state_store }}" |
144 | 144 | - --kubeconfig |
145 | 145 | - /tmp/{{ item }}.yaml |
146 | | - loop: "{{ cluster_names }}" |
147 | | - register: export_kops_output |
148 | | - changed_when: export_kops_output.rc == 0 |
| 146 | + loop: "{{ awx_cluster_names }}" |
| 147 | + register: awx_kops_export_output |
| 148 | + changed_when: awx_kops_export_output.rc == 0 |
149 | 149 |
|
150 | 150 | - name: Asynchronously validate kOps cluster |
151 | 151 | ansible.builtin.command: |
|
154 | 154 | - validate |
155 | 155 | - cluster |
156 | 156 | - --state |
157 | | - - "{{ state_store }}" |
| 157 | + - "{{ awx_kops_state_store }}" |
158 | 158 | - --wait |
159 | 159 | - 10m |
160 | 160 | environment: |
161 | 161 | KUBECONFIG: /tmp/{{ item }}.yaml |
162 | 162 | async: 600 |
163 | | - loop: "{{ cluster_names }}" |
| 163 | + loop: "{{ awx_cluster_names }}" |
164 | 164 | poll: 0 |
165 | | - register: async_validate_results |
| 165 | + register: awx_async_validate_results |
166 | 166 |
|
167 | 167 | - name: Wait for asynchronous operations to complete |
168 | 168 | ansible.builtin.async_status: |
169 | 169 | jid: "{{ item.ansible_job_id }}" |
170 | | - loop: "{{ async_validate_results.results }}" |
| 170 | + loop: "{{ awx_async_validate_results.results }}" |
171 | 171 | register: async_validate_poll_results |
172 | 172 | until: async_validate_poll_results.finished |
173 | 173 | delay: 60 |
|
177 | 177 | ansible.builtin.async_status: |
178 | 178 | mode: cleanup |
179 | 179 | jid: "{{ item.ansible_job_id }}" |
180 | | - loop: "{{ async_validate_results.results }}" |
| 180 | + loop: "{{ awx_async_validate_results.results }}" |
0 commit comments