mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Bug fixes for gcp_compute_ssl_certificate (#42821)
This commit is contained in:
parent
c38e1e5631
commit
fbfea59d7d
2 changed files with 36 additions and 41 deletions
|
@ -16,8 +16,7 @@
|
|||
- name: delete a ssl certificate
|
||||
gcp_compute_ssl_certificate:
|
||||
name: "{{ resource_name }}"
|
||||
description: |
|
||||
"A certificate for testing. Do not use this certificate in production"
|
||||
description: A certificate for testing. Do not use this certificate in production
|
||||
certificate: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
||||
|
@ -45,15 +44,12 @@
|
|||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: absent
|
||||
#----------------------------------------------------------
|
||||
- name: create a ssl certificate
|
||||
gcp_compute_ssl_certificate:
|
||||
name: "{{ resource_name }}"
|
||||
description: |
|
||||
"A certificate for testing. Do not use this certificate in production"
|
||||
description: A certificate for testing. Do not use this certificate in production
|
||||
certificate: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
||||
|
@ -81,8 +77,6 @@
|
|||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
|
@ -91,19 +85,24 @@
|
|||
- result.changed == true
|
||||
- "result.kind == 'compute#sslCertificate'"
|
||||
- name: verify that ssl_certificate was created
|
||||
shell: |
|
||||
gcloud compute ssl-certificates describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
||||
gcp_compute_ssl_certificate_facts:
|
||||
filters:
|
||||
- name = {{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: results
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results.rc == 0
|
||||
- results['items'] | length == 1
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: create a ssl certificate that already exists
|
||||
gcp_compute_ssl_certificate:
|
||||
name: "{{ resource_name }}"
|
||||
description: |
|
||||
"A certificate for testing. Do not use this certificate in production"
|
||||
description: A certificate for testing. Do not use this certificate in production
|
||||
certificate: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
||||
|
@ -131,8 +130,6 @@
|
|||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: present
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
|
@ -144,8 +141,7 @@
|
|||
- name: delete a ssl certificate
|
||||
gcp_compute_ssl_certificate:
|
||||
name: "{{ resource_name }}"
|
||||
description: |
|
||||
"A certificate for testing. Do not use this certificate in production"
|
||||
description: A certificate for testing. Do not use this certificate in production
|
||||
certificate: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
||||
|
@ -173,8 +169,6 @@
|
|||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: absent
|
||||
register: result
|
||||
- name: assert changed is true
|
||||
|
@ -183,21 +177,24 @@
|
|||
- result.changed == true
|
||||
- result.has_key('kind') == False
|
||||
- name: verify that ssl_certificate was deleted
|
||||
shell: |
|
||||
gcloud compute ssl-certificates describe --project="{{ gcp_project}}" "{{ resource_name }}"
|
||||
gcp_compute_ssl_certificate_facts:
|
||||
filters:
|
||||
- name = {{ resource_name }}
|
||||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
register: results
|
||||
failed_when: results.rc == 0
|
||||
- name: verify that command succeeded
|
||||
assert:
|
||||
that:
|
||||
- results.rc == 1
|
||||
- "\"'projects/{{ gcp_project }}/global/sslCertificates/{{ resource_name }}' was not found\" in results.stderr"
|
||||
- results['items'] | length == 0
|
||||
# ----------------------------------------------------------------------------
|
||||
- name: delete a ssl certificate that does not exist
|
||||
gcp_compute_ssl_certificate:
|
||||
name: "{{ resource_name }}"
|
||||
description: |
|
||||
"A certificate for testing. Do not use this certificate in production"
|
||||
description: A certificate for testing. Do not use this certificate in production
|
||||
certificate: |
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
|
||||
|
@ -225,8 +222,6 @@
|
|||
project: "{{ gcp_project }}"
|
||||
auth_kind: "{{ gcp_cred_kind }}"
|
||||
service_account_file: "{{ gcp_cred_file }}"
|
||||
scopes:
|
||||
- https://www.googleapis.com/auth/compute
|
||||
state: absent
|
||||
register: result
|
||||
- name: assert changed is false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue