Debian Codegraph @

ansible_collections/google/cloud/tests/integration/targets/gcp_secret_manager/tasks/regionalsecretslookup.yml

raw symbols SCIP
1 # Copyright 2024 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 regional test secret if it exists
17 google.cloud.gcp_secret_manager:
18 name: "{{ lookup_resource_name }}"
19 version: "all"
20 location: "us-central1"
21 project: "{{ gcp_project }}"
22 auth_kind: "{{ gcp_cred_kind }}"
23 service_account_file: "{{ gcp_cred_file | default(omit) }}"
24 state: absent
25 - name: Create a regional secret
26 google.cloud.gcp_secret_manager:
27 name: "{{ lookup_resource_name }}"
28 location: "us-central1"
29 value: "ansible lookup test regional secret value"
30 labels:
31 key1: "val1"
32 key2: "val2"
33 project: "{{ gcp_project }}"
34 auth_kind: "{{ gcp_cred_kind }}"
35 service_account_file: "{{ gcp_cred_file | default(omit) }}"
36 state: present
37 - name: Add a new version to a regional secret
38 google.cloud.gcp_secret_manager:
39 name: "{{ lookup_resource_name }}"
40 location: "us-central1"
41 value: "ansible lookup test regional secret value updated"
42 project: "{{ gcp_project }}"
43 auth_kind: "{{ gcp_cred_kind }}"
44 service_account_file: "{{ gcp_cred_file | default(omit) }}"
45 state: present
46 # ----------------------------------------------------------
47 - name: Retrieve the latest secret version of a regional secret
48 ansible.builtin.set_fact:
49 secret_value: "{{ lookup('google.cloud.gcp_secret_manager', key=lookup_resource_name, location='us-central1', project=gcp_project, auth_kind=gcp_cred_kind, service_account_file=gcp_cred_file) | string }}"
50 - name: Assert secret value
51 ansible.builtin.assert:
52 that:
53 - secret_value is contains("ansible lookup test regional secret value updated")
54 # ----------------------------------------------------------
55 - name: Retrieve the specified secret version of a regional secret
56 ansible.builtin.set_fact:
57 secret_value: "{{ lookup('google.cloud.gcp_secret_manager', key=lookup_resource_name, location='us-central1', version='1', project=gcp_project, auth_kind=gcp_cred_kind, service_account_file=gcp_cred_file) | string }}"
58 - name: Assert secret value
59 ansible.builtin.assert:
60 that:
61 - secret_value is contains("ansible lookup test regional secret value")
62 # ---------------------------------------------------------
63 # Post-test teardown
64 # If errors happen, don't crash the playbook!
65 - name: Delete the regional test secret
66 google.cloud.gcp_secret_manager:
67 name: "{{ lookup_resource_name }}"
68 location: "us-central1"
69 version: "all"
70 project: "{{ gcp_project }}"
71 auth_kind: "{{ gcp_cred_kind }}"
72 service_account_file: "{{ gcp_cred_file | default(omit) }}"
73 state: absent
74 ignore_errors: true