--- # ---------------------------------------------------------------------------- # # *** AUTO GENERATED CODE *** Type: MMv1 *** # # ---------------------------------------------------------------------------- # # This file is automatically generated by Magic Modules and manual # changes will be clobbered when the file is regenerated. # # Please read more about how to change this file at # https://www.github.com/GoogleCloudPlatform/magic-modules # # ---------------------------------------------------------------------------- # Pre-test setup - name: Delete a project google.cloud.gcp_resourcemanager_project: name: "{{ resource_prefix[0:30] }}" id: "{{ resource_prefix[0:30] }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" parent: type: folder id: "{{ gcp_folder_id }}" state: absent # ---------------------------------------------------------- - name: Create a project google.cloud.gcp_resourcemanager_project: name: "{{ resource_prefix[0:30] }}" id: "{{ resource_prefix[0:30] }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" parent: type: folder id: "{{ gcp_folder_id }}" state: present register: result - name: Assert changed is true ansible.builtin.assert: that: - result.changed == true - name: Pause for 2 minutes for project to appear ansible.builtin.pause: minutes: 2 - name: Verify that project was created google.cloud.gcp_resourcemanager_project_info: project: "{{ gcp_project }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" # choose 1000 projects so iterate past the deleted ones. page_size: 1000 scopes: - https://www.googleapis.com/auth/cloud-platform register: results - name: Verify that command succeeded ansible.builtin.assert: that: - results['resources'] | selectattr("lifecycleState", "equalto", "ACTIVE") | map(attribute='name') | select("match", ".*{{ resource_prefix[0:30] }}.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a project that already exists google.cloud.gcp_resourcemanager_project: name: "{{ resource_prefix[0:30] }}" id: "{{ resource_prefix[0:30] }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" parent: type: folder id: "{{ gcp_folder_id }}" state: present register: result - name: Assert changed is false ansible.builtin.assert: that: - result.changed == false # ---------------------------------------------------------- - name: Delete a project google.cloud.gcp_resourcemanager_project: name: "{{ resource_prefix[0:30] }}" id: "{{ resource_prefix[0:30] }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" parent: type: folder id: "{{ gcp_folder_id }}" state: absent register: result - name: Assert changed is true ansible.builtin.assert: that: - result.changed == true - name: Pause for 2 minutes for project to appear ansible.builtin.pause: minutes: 2 - name: Verify that project was deleted google.cloud.gcp_resourcemanager_project_info: project: "{{ resource_prefix[0:30] }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" # choose 1000 projects so iterate past the deleted ones. page_size: 1000 scopes: - https://www.googleapis.com/auth/cloud-platform register: results - name: Verify that command succeeded ansible.builtin.assert: that: - results['resources'] | selectattr("lifecycleState", "equalto", "DELETE_REQUESTED") | map(attribute='name') | select("match", ".*{{ resource_prefix[0:30] }}.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Delete a project that does not exist google.cloud.gcp_resourcemanager_project: name: "{{ resource_prefix[0:30] }}" id: "{{ resource_prefix[0:30] }}" auth_kind: "{{ gcp_cred_kind }}" service_account_file: "{{ gcp_cred_file | default(omit) }}" parent: type: folder id: "{{ gcp_folder_id }}" state: absent register: result - name: Assert changed is false ansible.builtin.assert: that: - result.changed == false