mirror of
https://github.com/ansible-collections/google.cloud.git
synced 2025-07-22 12:50:29 -07:00
Ansible KMS Modules (#362)
Signed-off-by: Modular Magician <magic-modules@google.com>
This commit is contained in:
parent
20d7eb508e
commit
aabadcfa7f
12 changed files with 1090 additions and 0 deletions
2
tests/integration/gcp_kms_crypto_key/aliases
Normal file
2
tests/integration/gcp_kms_crypto_key/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/gcp
|
||||
unsupported
|
2
tests/integration/gcp_kms_crypto_key/defaults/main.yml
Normal file
2
tests/integration/gcp_kms_crypto_key/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
resource_name: "{{ resource_prefix }}"
|
0
tests/integration/gcp_kms_crypto_key/meta/main.yml
Normal file
0
tests/integration/gcp_kms_crypto_key/meta/main.yml
Normal file
73
tests/integration/gcp_kms_crypto_key/tasks/main.yml
Normal file
73
tests/integration/gcp_kms_crypto_key/tasks/main.yml
Normal file
|
@ -0,0 +1,73 @@
|
|||
# Copyright 2019 Google Inc.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
---
|
||||
# Pre-test setup
|
||||
- name: create a key ring
|
||||
gcp_kms_key_ring:
|
||||
name: key-key-ring
|
||||
location: us-central1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: keyring
|
||||
- name: delete a crypto key
|
||||
gcp_kms_crypto_key:
|
||||
name: "{{ resource_name }}"
|
||||
key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
#----------------------------------------------------------
|
||||
- name: create a crypto key
|
||||
gcp_kms_crypto_key:
|
||||
name: "{{ resource_name }}"
|
||||
key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- name: verify that crypto_key was created
|
||||
gcp_kms_crypto_key_info:
|
||||
key_ring: "projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring"
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/cloudkms
|
||||
register: results
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: create a crypto key that already exists
|
||||
gcp_kms_crypto_key:
|
||||
name: "{{ resource_name }}"
|
||||
key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
assert:
|
||||
that:
|
||||
- result.changed == false
|
2
tests/integration/gcp_kms_key_ring/aliases
Normal file
2
tests/integration/gcp_kms_key_ring/aliases
Normal file
|
@ -0,0 +1,2 @@
|
|||
cloud/gcp
|
||||
unsupported
|
2
tests/integration/gcp_kms_key_ring/defaults/main.yml
Normal file
2
tests/integration/gcp_kms_key_ring/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
resource_name: "{{ resource_prefix }}"
|
0
tests/integration/gcp_kms_key_ring/meta/main.yml
Normal file
0
tests/integration/gcp_kms_key_ring/meta/main.yml
Normal file
63
tests/integration/gcp_kms_key_ring/tasks/main.yml
Normal file
63
tests/integration/gcp_kms_key_ring/tasks/main.yml
Normal file
|
@ -0,0 +1,63 @@
|
|||
# Copyright 2019 Google Inc.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Pre-test setup
|
||||
- name: delete a key ring
|
||||
gcp_kms_key_ring:
|
||||
name: "{{ resource_name }}"
|
||||
location: us-central1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: absent
|
||||
#----------------------------------------------------------
|
||||
- name: create a key ring
|
||||
gcp_kms_key_ring:
|
||||
name: "{{ resource_name }}"
|
||||
location: us-central1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- name: verify that key_ring was created
|
||||
gcp_kms_key_ring_info:
|
||||
location: us-central1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/cloudkms
|
||||
register: results
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: create a key ring that already exists
|
||||
gcp_kms_key_ring:
|
||||
name: "{{ resource_name }}"
|
||||
location: us-central1
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
assert:
|
||||
that:
|
||||
- result.changed == false
|
Loading…
Add table
Add a link
Reference in a new issue