diff --git a/.ansible-lint b/.ansible-lint index c77c6a873..0c5e66897 100644 --- a/.ansible-lint +++ b/.ansible-lint @@ -1,10 +1,10 @@ --- +profile: production parseable: true skip_list: - ANSIBLE0010 use_default_rules: true verbosity: 1 exclude_paths: - - ./roles/gcp_http_lb/ - - ./tests/ - - ./plugins + # Ignore submodule https://github.com/GoogleCloudPlatform/google-cloud-ops-agents-ansible + - roles/google_cloud_ops_agents/ diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 8d576043c..e9fea6a37 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -37,7 +37,7 @@ jobs: - name: Install ansible-lint run: pip install ansible-lint==24.7.0 - name: Run ansible-lint - run: ansible-lint + run: ansible-lint --exclude roles/google_cloud_ops_agents/ unit: runs-on: ubuntu-latest defaults: diff --git a/roles/gcloud/tasks/archive/command_completion.yml b/roles/gcloud/tasks/archive/command_completion.yml index 277210125..a130e3397 100644 --- a/roles/gcloud/tasks/archive/command_completion.yml +++ b/roles/gcloud/tasks/archive/command_completion.yml @@ -10,7 +10,7 @@ when: ansible_os_family == "Debian" - name: Gcloud | Archive | RedHat | Ensure bash completion is installed - ansible.builtin.yum: + ansible.builtin.dnf: name: - bash-completion register: task_result diff --git a/roles/gcloud/tasks/package/redhat.yml b/roles/gcloud/tasks/package/redhat.yml index 8917561a2..156d54563 100644 --- a/roles/gcloud/tasks/package/redhat.yml +++ b/roles/gcloud/tasks/package/redhat.yml @@ -1,18 +1,18 @@ --- -- name: Gcloud | RHEL | Add an Apt signing key, uses whichever key is at the URL +# https://cloud.google.com/sdk/docs/install#rpm +- name: Gcloud | RHEL | Add a dnf signing key, uses whichever key is at the URL ansible.builtin.yum_repository: name: google-cloud-sdk description: Google Cloud SDK - baseurl: https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 + baseurl: https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-x86_64 enabled: true gpgcheck: true - repo_gpgcheck: true + repo_gpgcheck: false gpgkey: - - https://packages.cloud.google.com/yum/doc/yum-key.gpg - https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg - name: Gcloud | RHEL | Install the google-cloud-sdk package - ansible.builtin.yum: + ansible.builtin.dnf: name: google-cloud-sdk update_cache: "yes" register: task_result @@ -21,7 +21,7 @@ delay: 2 - name: Gcloud | Debian | Install the google-cloud-sdk additional components - ansible.builtin.yum: + ansible.builtin.dnf: name: google-cloud-sdk-{{ item }} update_cache: "yes" register: task_result diff --git a/scripts/cleanup-project.sh b/scripts/cleanup-project.sh index b05a2f15f..76f9714b3 100755 --- a/scripts/cleanup-project.sh +++ b/scripts/cleanup-project.sh @@ -16,6 +16,7 @@ ZONE="us-central1-a" main() { # note: the ordering here is deliberate, to start with # leaf resources and work upwards to parent resources. + cleanup_resource "container" "clusters" "" "--zone=$ZONE" cleanup_resource_per_region "compute" "vpn-tunnels" cleanup_resource "compute" "instances" "" "--zone=$ZONE" cleanup_resource_per_region "compute" "addresses" diff --git a/tests/integration/targets/gcp_container_cluster/tasks/autogen.yml b/tests/integration/targets/gcp_container_cluster/tasks/autogen.yml index 4a845eac0..f3c1d1273 100644 --- a/tests/integration/targets/gcp_container_cluster/tasks/autogen.yml +++ b/tests/integration/targets/gcp_container_cluster/tasks/autogen.yml @@ -55,7 +55,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'my-cluster' in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*my-cluster.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a cluster that already exists google.cloud.gcp_container_cluster: @@ -104,7 +104,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'my-cluster' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*my-cluster.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a cluster that does not exist google.cloud.gcp_container_cluster: diff --git a/tests/integration/targets/gcp_container_node_pool/tasks/autogen.yml b/tests/integration/targets/gcp_container_node_pool/tasks/autogen.yml index ae04f3049..84fe978a7 100644 --- a/tests/integration/targets/gcp_container_node_pool/tasks/autogen.yml +++ b/tests/integration/targets/gcp_container_node_pool/tasks/autogen.yml @@ -62,7 +62,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'my-pool' in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*my-pool.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a node pool that already exists google.cloud.gcp_container_node_pool: @@ -108,7 +108,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'my-pool' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*my-pool.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a node pool that does not exist google.cloud.gcp_container_node_pool: diff --git a/tests/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml b/tests/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml index 67fe3e328..c8ca5354c 100644 --- a/tests/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml +++ b/tests/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml @@ -67,7 +67,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'www.testzone-4.com.'in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*www\\.testzone-4\\.com.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a resource record set that already exists google.cloud.gcp_dns_resource_record_set: @@ -118,7 +118,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'www.testzone-4.com.'not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*www\\.testzone-4\\.com.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a resource record set that does not exist google.cloud.gcp_dns_resource_record_set: diff --git a/tests/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml b/tests/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml index ca78eb436..6aeaa58dd 100644 --- a/tests/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml +++ b/tests/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml @@ -56,7 +56,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "\"{{ resource_name }}\" in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a subscription that already exists google.cloud.gcp_pubsub_subscription: @@ -98,7 +98,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "\"{{ resource_name }}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a subscription that does not exist google.cloud.gcp_pubsub_subscription: diff --git a/tests/integration/targets/gcp_pubsub_topic/tasks/autogen.yml b/tests/integration/targets/gcp_pubsub_topic/tasks/autogen.yml index 0c0dbdc96..d9f3cd3da 100644 --- a/tests/integration/targets/gcp_pubsub_topic/tasks/autogen.yml +++ b/tests/integration/targets/gcp_pubsub_topic/tasks/autogen.yml @@ -44,7 +44,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'test-topic1' in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*test-topic1.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a topic that already exists google.cloud.gcp_pubsub_topic: @@ -82,7 +82,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'test-topic1' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*test-topic1.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a topic that does not exist google.cloud.gcp_pubsub_topic: diff --git a/tests/integration/targets/gcp_sql_database/tasks/autogen.yml b/tests/integration/targets/gcp_sql_database/tasks/autogen.yml index dd87faa83..a84096fbd 100644 --- a/tests/integration/targets/gcp_sql_database/tasks/autogen.yml +++ b/tests/integration/targets/gcp_sql_database/tasks/autogen.yml @@ -64,7 +64,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "\"{{ resource_name }}\" in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a database that already exists google.cloud.gcp_sql_database: @@ -107,7 +107,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "\"{{ resource_name }}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a database that does not exist google.cloud.gcp_sql_database: diff --git a/tests/integration/targets/gcp_sql_user/tasks/autogen.yml b/tests/integration/targets/gcp_sql_user/tasks/autogen.yml index 20ddbea25..0a820cf5d 100644 --- a/tests/integration/targets/gcp_sql_user/tasks/autogen.yml +++ b/tests/integration/targets/gcp_sql_user/tasks/autogen.yml @@ -66,7 +66,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'test-user' in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*test-user.*") | list | length == 1 # ---------------------------------------------------------------------------- - name: Create a user that already exists google.cloud.gcp_sql_user: @@ -111,7 +111,7 @@ - name: Verify that command succeeded ansible.builtin.assert: that: - - "'test-user' not in \"{{ results['resources'] | map(attribute='name') | list }}\"" + - results['resources'] | map(attribute='name') | select("match", ".*test-user.*") | list | length == 0 # ---------------------------------------------------------------------------- - name: Delete a user that does not exist google.cloud.gcp_sql_user: diff --git a/tests/unit/plugins/test_gcp_utils.py b/tests/unit/plugins/test_gcp_utils.py index 4956fe513..804bbbb6f 100644 --- a/tests/unit/plugins/test_gcp_utils.py +++ b/tests/unit/plugins/test_gcp_utils.py @@ -85,7 +85,7 @@ def test_simple_different(self): difference = {"test": "original"} request1 = GcpRequest(value1) request2 = GcpRequest(value2) - self.assertNotEquals(request1, request2) + self.assertNotEqual(request1, request2) self.assertEqual(request1.difference(request2), difference) def test_nested_dictionaries_no_difference(self): @@ -99,7 +99,7 @@ def test_nested_dictionaries_with_difference(self): difference = {"foo": {"quiet": {"tree": "test"}, "bar": "baz"}} request1 = GcpRequest(value1) request2 = GcpRequest(value2) - self.assertNotEquals(request1, request2) + self.assertNotEqual(request1, request2) self.assertEqual(request1.difference(request2), difference) def test_arrays_strings_no_difference(self): @@ -123,7 +123,7 @@ def test_arrays_strings_with_difference(self): } request1 = GcpRequest(value1) request2 = GcpRequest(value2) - self.assertNotEquals(request1, request2) + self.assertNotEqual(request1, request2) self.assertEqual(request1.difference(request2), difference) def test_arrays_dicts_with_no_difference(self): @@ -141,7 +141,7 @@ def test_arrays_dicts_with_difference(self): difference = {"foo": [{"test": "value", "foo": "bar"}]} request1 = GcpRequest(value1) request2 = GcpRequest(value2) - self.assertNotEquals(request1, request2) + self.assertNotEqual(request1, request2) self.assertEqual(request1.difference(request2), difference) def test_dicts_boolean_with_difference(self): @@ -165,5 +165,5 @@ def test_dicts_boolean_with_difference(self): } request1 = GcpRequest(value1) request2 = GcpRequest(value2) - self.assertNotEquals(request1, request2) + self.assertNotEqual(request1, request2) self.assertEqual(request1.difference(request2), difference)