Debian Codegraph @

ansible_collections/google/cloud/tests/integration/targets/gcp_parameter_manager/tasks/parameterslookup.yml

raw
1 # Copyright 2025 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 # Pre-test setup
16 - name: Delete the test parameter if it exists
17 google.cloud.gcp_parameter_manager:
18 name: "{{ lookup_resource_name }}"
19 project: "{{ gcp_project }}"
20 auth_kind: "{{ gcp_cred_kind }}"
21 service_account_file: "{{ gcp_cred_file | default(omit) }}"
22 state: absent
23 - name: Create a parameter
24 google.cloud.gcp_parameter_manager:
25 name: "{{ lookup_resource_name }}"
26 version: "test_version"
27 value: "ansible lookup test parameter value"
28 labels:
29 key1: "val1"
30 key2: "val2"
31 project: "{{ gcp_project }}"
32 auth_kind: "{{ gcp_cred_kind }}"
33 service_account_file: "{{ gcp_cred_file | default(omit) }}"
34 state: present
35 - name: Add a new version to a parameter
36 google.cloud.gcp_parameter_manager:
37 name: "{{ lookup_resource_name }}"
38 version: "test_version_1"
39 value: "ansible lookup test parameter value updated"
40 project: "{{ gcp_project }}"
41 auth_kind: "{{ gcp_cred_kind }}"
42 service_account_file: "{{ gcp_cred_file | default(omit) }}"
43 state: present
44 # ----------------------------------------------------------
45 - name: Retrieve the latest parameter version of a parameter
46 ansible.builtin.set_fact:
47 param_value: "{{ lookup('google.cloud.gcp_parameter_manager', key=lookup_resource_name, project=gcp_project, auth_kind=gcp_cred_kind, service_account_file=gcp_cred_file) | string }}"
48 - name: Assert parameter value
49 ansible.builtin.assert:
50 that:
51 - param_value is contains("ansible lookup test parameter value updated")
52 # ----------------------------------------------------------
53 - name: Retrieve the specified parameter version of a parameter
54 ansible.builtin.set_fact:
55 param_value: "{{ lookup('google.cloud.gcp_parameter_manager', key=lookup_resource_name, version='test_version', project=gcp_project, auth_kind=gcp_cred_kind, service_account_file=gcp_cred_file) | string }}"
56 - name: Assert parameter value
57 ansible.builtin.assert:
58 that:
59 - param_value is contains("ansible lookup test parameter value")
60 # ---------------------------------------------------------
61 - name: Render the latest parameter version of a parameter
62 ansible.builtin.set_fact:
63 param_value: "{{ lookup('google.cloud.gcp_parameter_manager', key=lookup_resource_name, project=gcp_project, auth_kind=gcp_cred_kind, render_secret=True, service_account_file=gcp_cred_file) | string }}"
64 - name: Assert parameter value
65 ansible.builtin.assert:
66 that:
67 - param_value is contains("ansible lookup test parameter value updated")
68 # ----------------------------------------------------------
69 - name: Render the specified parameter version of a parameter
70 ansible.builtin.set_fact:
71 param_value: "{{ lookup('google.cloud.gcp_parameter_manager', key=lookup_resource_name, version='test_version', project=gcp_project, auth_kind=gcp_cred_kind, render_secret=True, service_account_file=gcp_cred_file) | string }}"
72 - name: Assert parameter value
73 ansible.builtin.assert:
74 that:
75 - param_value is contains ("ansible lookup test parameter value")
76 # ---------------------------------------------------------
77 # Post-test teardown
78 # If errors happen, don't crash the playbook!
79 - name: Delete the test parameter version
80 google.cloud.gcp_parameter_manager:
81 name: "{{ lookup_resource_name }}"
82 project: "{{ gcp_project }}"
83 version: "test_version"
84 auth_kind: "{{ gcp_cred_kind }}"
85 service_account_file: "{{ gcp_cred_file | default(omit) }}"
86 state: absent
87 ignore_errors: true
88 - name: Delete the test parameter version
89 google.cloud.gcp_parameter_manager:
90 name: "{{ lookup_resource_name }}"
91 project: "{{ gcp_project }}"
92 version: "test_version_1"
93 auth_kind: "{{ gcp_cred_kind }}"
94 service_account_file: "{{ gcp_cred_file | default(omit) }}"
95 state: absent
96 ignore_errors: true
97 - name: Delete the test parameter
98 google.cloud.gcp_parameter_manager:
99 name: "{{ lookup_resource_name }}"
100 project: "{{ gcp_project }}"
101 auth_kind: "{{ gcp_cred_kind }}"
102 service_account_file: "{{ gcp_cred_file | default(omit) }}"
103 state: absent
104 ignore_errors: true