Debian Codegraph @

ansible_collections/google/cloud/tests/integration/targets/gcp_compute_firewall/tasks/update.yml

raw
1 # Copyright 2019 Google Inc.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at
5 #
6 # http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 ---
15 # ----------------------------------------------------------------------------
16 #
17 # *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
18 #
19 # ----------------------------------------------------------------------------
20 #
21 # This file is automatically generated by Magic Modules and manual
22 # changes will be clobbered when the file is regenerated.
23 #
24 # Please read more about how to change this file at
25 # https://www.github.com/GoogleCloudPlatform/magic-modules
26 #
27 # ----------------------------------------------------------------------------
28 # Pre-test setup
29 - name: Delete a firewall
30 google.cloud.gcp_compute_firewall:
31 name: "{{ resource_name }}"
32 allowed:
33 - ip_protocol: tcp
34 ports:
35 - "22"
36 target_tags:
37 - test-ssh-server
38 - staging-ssh-server
39 source_tags:
40 - test-ssh-clients
41 project: "{{ gcp_project }}"
42 auth_kind: "{{ gcp_cred_kind }}"
43 service_account_file: "{{ gcp_cred_file | default(omit) }}"
44 state: absent
45 # ----------------------------------------------------------
46 - name: Create a firewall
47 google.cloud.gcp_compute_firewall:
48 name: "{{ resource_name }}"
49 allowed:
50 - ip_protocol: tcp
51 ports:
52 - "22"
53 target_tags:
54 - test-ssh-server
55 - staging-ssh-server
56 source_tags:
57 - test-ssh-clients
58 project: "{{ gcp_project }}"
59 auth_kind: "{{ gcp_cred_kind }}"
60 service_account_file: "{{ gcp_cred_file | default(omit) }}"
61 state: present
62 register: result
63 - name: Assert changed is true
64 ansible.builtin.assert:
65 that:
66 - result.changed == true
67 - name: Verify that firewall was created
68 google.cloud.gcp_compute_firewall_info:
69 filters:
70 - name = {{ resource_name }}
71 project: "{{ gcp_project }}"
72 auth_kind: "{{ gcp_cred_kind }}"
73 service_account_file: "{{ gcp_cred_file | default(omit) }}"
74 scopes:
75 - https://www.googleapis.com/auth/compute
76 register: results
77 - name: Verify that command succeeded
78 ansible.builtin.assert:
79 that:
80 - results['resources'] | length == 1
81 # ----------------------------------------------------------------------------
82 - name: Update the firewall
83 google.cloud.gcp_compute_firewall:
84 name: "{{ resource_name }}"
85 allowed:
86 - ip_protocol: tcp
87 ports:
88 - "55"
89 target_tags:
90 - test-ssh-server
91 - staging-ssh-server
92 source_tags:
93 - test-ssh-clients
94 project: "{{ gcp_project }}"
95 auth_kind: "{{ gcp_cred_kind }}"
96 service_account_file: "{{ gcp_cred_file | default(omit) }}"
97 state: present
98 register: result
99 - name: Assert changed is true
100 ansible.builtin.assert:
101 that:
102 - result.changed == true
103 # ----------------------------------------------------------------------------
104 - name: Check firewall was updated.
105 google.cloud.gcp_compute_firewall_info:
106 filters:
107 - name = {{ resource_name }}
108 project: "{{ gcp_project }}"
109 auth_kind: "{{ gcp_cred_kind }}"
110 service_account_file: "{{ gcp_cred_file | default(omit) }}"
111 scopes:
112 - https://www.googleapis.com/auth/compute
113 register: results
114 - name: Verify that command succeeded
115 ansible.builtin.assert:
116 that:
117 - results['resources'] | length == 1
118 - name: Verify that update succeeded
119 ansible.builtin.assert:
120 that:
121 - results['resources'][0]['allowed'][0]['ports'][0] == '55'
122 # ----------------------------------------------------------
123 - name: Delete a firewall
124 google.cloud.gcp_compute_firewall:
125 name: "{{ resource_name }}"
126 allowed:
127 - ip_protocol: tcp
128 ports:
129 - "22"
130 target_tags:
131 - test-ssh-server
132 - staging-ssh-server
133 source_tags:
134 - test-ssh-clients
135 project: "{{ gcp_project }}"
136 auth_kind: "{{ gcp_cred_kind }}"
137 service_account_file: "{{ gcp_cred_file | default(omit) }}"
138 state: absent
139 register: result
140 - name: Assert changed is true
141 ansible.builtin.assert:
142 that:
143 - result.changed == true
144 - name: Verify that firewall was deleted
145 google.cloud.gcp_compute_firewall_info:
146 filters:
147 - name = {{ resource_name }}
148 project: "{{ gcp_project }}"
149 auth_kind: "{{ gcp_cred_kind }}"
150 service_account_file: "{{ gcp_cred_file | default(omit) }}"
151 scopes:
152 - https://www.googleapis.com/auth/compute
153 register: results
154 - name: Verify that command succeeded
155 ansible.builtin.assert:
156 that:
157 - results['resources'] | length == 0
158 # ----------------------------------------------------------------------------
159 - name: Delete a firewall that does not exist
160 google.cloud.gcp_compute_firewall:
161 name: "{{ resource_name }}"
162 allowed:
163 - ip_protocol: tcp
164 ports:
165 - "22"
166 target_tags:
167 - test-ssh-server
168 - staging-ssh-server
169 source_tags:
170 - test-ssh-clients
171 project: "{{ gcp_project }}"
172 auth_kind: "{{ gcp_cred_kind }}"
173 service_account_file: "{{ gcp_cred_file | default(omit) }}"
174 state: absent
175 register: result
176 - name: Assert changed is false
177 ansible.builtin.assert:
178 that:
179 - result.changed == false