ansible-collections / google.cloud

GCP Ansible Collection https://galaxy.ansible.com/google/cloud
https://cloud.google.com
GNU General Public License v3.0
99 stars 126 forks source link

gcp_compute_target_pool: Invalid value for field. The project '***' was not found. #614

Open vitabaks opened 8 months ago

vitabaks commented 8 months ago
SUMMARY

Please help me figure out why I'm getting the error "Invalid value for field 'xxxxxx'. The project '********' was not found." when using the gcp_compute_target_pool module.

Upd: I also get a similar error when using the gcp_compute_instance_group module.

ISSUE TYPE
COMPONENT NAME

google.cloud.gcp_compute_target_pool

ANSIBLE VERSION
ansible [core 2.16.2]
  config file = None
  configured module search path = ['/Users/vitabaks/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/vitabaks/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.5 (main, Aug 24 2023, 15:09:45) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/opt/python@3.11/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
community.general 8.1.0 
...
google.cloud  1.3.0  
CONFIGURATION
CONFIG_FILE() = /Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg
DEFAULT_HOST_LIST(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = ['/Users/vitabaks/Documents/GitHub/postgresql_cluster/inventory']
DEFAULT_TIMEOUT(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = 60
DEPRECATION_WARNINGS(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = False
DISPLAY_SKIPPED_HOSTS(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = False
HOST_KEY_CHECKING(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = False
LOCALHOST_WARNING(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = False
PERSISTENT_COMMAND_TIMEOUT(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = 30
PERSISTENT_CONNECT_TIMEOUT(/Users/vitabaks/Documents/GitHub/postgresql_cluster/ansible.cfg) = 60
OS / ENVIRONMENT

MacOS

STEPS TO REPRODUCE
      - name: "GCP: [Load Balancer] Create Primary Health Check"
          google.cloud.gcp_compute_health_check:
            auth_kind: "serviceaccount"
            service_account_contents: "{{ gcp_service_account_contents }}"
            project: "{{ gcp_project | default(gcp_service_account_contents.project_id) }}"
            name: "{{ patroni_cluster_name }}-primary-hc"
            description: "{{ patroni_cluster_name }} Primary Health Check"
            type: "HTTP"
            http_health_check:
              port: "{{ patroni_restapi_port }}"
              request_path: "/primary"
            check_interval_sec: 5
            timeout_sec: 2
            unhealthy_threshold: 2
            healthy_threshold: 3
            state: present
          register: health_check_primary

        - name: "GCP: [Load Balancer] Create Primary Target Pool"
          google.cloud.gcp_compute_target_pool:
            auth_kind: "serviceaccount"
            service_account_contents: "{{ gcp_service_account_contents }}"
            project: "{{ gcp_project | default(gcp_service_account_contents.project_id) }}"
            name: "{{ patroni_cluster_name }}-primary"
            description: "{{ patroni_cluster_name }} Primary Target Pool"
            region: "{{ server_location[:-2] if server_location[-2:] | regex_search('-[a-z]$') else server_location }}"
            instances: "{{ server_result.results }}"
            health_check: "{{ health_check_primary }}"
            state: present
          register: target_pool_primary
EXPECTED RESULTS

Successful creation of a Target Pool with health-check and a list of instances.

ACTUAL RESULTS
TASK [cloud-resources : GCP: [Load Balancer] Create Primary Target Pool] ****************************************************************************************************************************************
task path: /Users/vitabaks/Documents/GitHub/postgresql_cluster/roles/cloud-resources/tasks/gcp.yml:268
The full traceback is:
  File "/var/folders/n6/vzc35vkj7fx8m_hcp4kcr3yc0000gn/T/ansible_google.cloud.gcp_compute_target_pool_payload_8_36qbbd/ansible_google.cloud.gcp_compute_target_pool_payload.zip/ansible_collections/google/cloud/plugins/module_utils/gcp_utils.py", line 336, in raise_for_status
    response.raise_for_status()
  File "/opt/homebrew/lib/python3.11/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "access_token": null,
            "auth_kind": "serviceaccount",
            "backup_pool": null,
            "description": "test-pgcluster Primary Target Pool",
            "env_type": null,
            "failover_ratio": null,
            "health_check": {
                "changed": false,
                "checkIntervalSec": 5,
                "creationTimestamp": "2024-01-29T04:19:55.911-08:00",
                "description": "test-pgcluster Primary Health Check",
                "failed": false,
                "healthyThreshold": 3,
                "httpHealthCheck": {
                    "port": 8008,
                    "proxyHeader": "NONE",
                    "requestPath": "/primary"
                },
                "id": "882219077812758788",
                "kind": "compute#healthCheck",
                "name": "test-pgcluster-primary-hc",
                "selfLink": "https://www.********/compute/v1/projects/********/global/healthChecks/test-pgcluster-primary-hc",
                "timeoutSec": 2,
                "type": "HTTP",
                "unhealthyThreshold": 2
            },
            "instances": [
                {
                    "ansible_index_var": "idx",
                    "ansible_loop_var": "item",
                    "changed": true,
                    "cpuPlatform": "Intel Cascade Lake",
                    "creationTimestamp": "2024-01-29T04:28:28.466-08:00",
                    "deletionProtection": false,
                    "disks": [
                        {
                            "architecture": "X86_64",
                            "autoDelete": true,
                            "boot": true,
                            "deviceName": "test-pgcluster-pgnode01-system",
                            "diskSizeGb": "100",
                            "guestOsFeatures": [
                                {
                                    "type": "VIRTIO_SCSI_MULTIQUEUE"
                                },
                                {
                                    "type": "SEV_CAPABLE"
                                },
                                {
                                    "type": "SEV_SNP_CAPABLE"
                                },
                                {
                                    "type": "SEV_LIVE_MIGRATABLE"
                                },
                                {
                                    "type": "SEV_LIVE_MIGRATABLE_V2"
                                },
                                {
                                    "type": "UEFI_COMPATIBLE"
                                },
                                {
                                    "type": "GVNIC"
                                }
                            ],
                            "index": 0,
                            "interface": "SCSI",
                            "kind": "compute#attachedDisk",
                            "licenses": [
                                "https://www.********/compute/v1/projects/ubuntu-os-cloud/global/licenses/ubuntu-2204-lts"
                            ],
                            "mode": "READ_WRITE",
                            "shieldedInstanceInitialState": {
                                "dbxs": [
                                    {
                                        "content": "2gcDBhMRFQAAAAAAAAAAABENAAAAAvEOndKvSt9o7kmKqTR9N1ZlpzCCDPUCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGgggsIMIIFGDCCBACgAwIBAgITMwAAABNryScg3e1ZiAAAAAAAEzANBgkqhkiG9w0BAQsFADCBgDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCldhc2hpbmd0b24xEDAOBgNVBAcTB1JlZG1vbmQxHjAcBgNVBAoTFU1pY3Jvc29mdCBDb3Jwb3JhdGlvbjEqMCgGA1UEAxMhTWljcm9zb2Z0IENvcnBvcmF0aW9uIEtFSyBDQSAyMDExMB4XDTE2MDEwNjE4MzQxNVoXDTE3MDQwNjE4MzQxNVowgZUxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNyb3NvZnQgQ29ycG9yYXRpb24xDTALBgNVBAsTBE1PUFIxMDAuBgNVBAMTJ01pY3Jvc29mdCBXaW5kb3dzIFVFRkkgS2V5IEV4Y2hhbmdlIEtleTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKXiCkZgbboTnVZnS1h_JbnlcVst9wtFK8NQjTpeB9wirml3h-fzi8vzki0hSNBD2Dg49lGEvs4egyowmTsLu1TnBUH1f_Hi8Noa7fKXV6F93qYrTPajx5v9L7NedplWnMEPsRvJrQdrysTZwtoXMLYDhc8bQHI5nlJDfgqrB8JiC4A3vL9i19lkQOTq4PZb5AcVcE0wlG7lR_btoQN0g5B4_7pI2S_9mU1PXr1NBSEl48Kl4cJwO2GyvOVvxQ6wUSFTExmCBKrT3LnPU5lZY68n3MpZ5VY4skhrEt2dyf5bZNzkYTTouxC0n37OrMbGGq3tpv7JDD6E_Rfqua3dXYECAwEAAaOCAXIwggFuMBQ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zZhe45_mDl1QTyZfxC3PrJn_YoQy5472_xmer24u9mvp3WQMyTb1gKPTnj3hLy2uFi0DToJh2WBW1ksFRSklgT6_WCBnaiNenbpd4_ve9mvp3WQMyTb1gKPTnj3hLzjv6vlnWfOisjf1KFvfEPvnCJFE_vGVZV9c1-in1QM69mvp3WQMyTb1gKPTnj3hL2MvrlzX1Zys2fk-WzcdJaWFdFwdK6WxyTULOAhb48_q9mvp3WQMyTb1gKPTnj3hL6Swi6ztWQtZcHsLK8kfSWUc47rt_s4QaRJVvWeKw0fq9mvp3WQMyTb1gKPTnj3hL_d1uPSnqhMd0Pa1KG9vHALX-wbOR-TJAkIasxx3W29i9mvp3WQMyTb1gKPTnj3hL_mOoT3gsydP88sz5_BH70Ddgh4dY0mKF7RJmm9xubQG9mvp3WQMyTb1gKPTnj3hL_s-yMtEumUttSF0scWdyiqVSWYStXKYedRYiHweaFDa9mvp3WQMyTb1gKPTnj3hLyhcdYUqNfhIck5SM0P5V05mB-dEaqW4DRQpBUifCxlu9mvp3WQMyTb1gKPTnj3hLVbmbDeU9vP5IWqnHN88_thbvPZH6tZmqfKsZ7adjtbq9mvp3WQMyTb1gKPTnj3hLd90ZD6MNiP9eOwEaCuYeYgl4DBMLU17Lh-bwiIoLay-9mvp3WQMyTb1gKPTnj3hLyDyxOSKtmfVgdEZ13TfMlNytWh_Lpkcv7jQRcdk56IS9mvp3WQMyTb1gKPTnj3hLOwKHUz4Mw9DsGqgjy_CpQarYchV50cSZgC3Rw6Y2uKm9mvp3WQMyTb1gKPTnj3hLk5ru9PX6UeIzQMPy5JBIzohyUmr991LDp_Oj8ryfYEm9mvp3WQMyTb1gKPTnj3hLZFdb2RJ4mi4UrVb2NB9Sr2v4DPlEAHhZdenwTi1k10W9mvp3WQMyTb1gKPTnj3hLRcfIrnUKz7tI_DdSfWQS3WRNrtiRPM2KJMlNhWln344=",
                                        "fileType": "BIN"
                                    }
                                ]
                            },
                            "source": "https://www.********/compute/v1/projects/********/zones/us-central1-b/disks/test-pgcluster-pgnode01-system",
                            "type": "PERSISTENT"
                        },
                        {
                            "autoDelete": true,
                            "boot": false,
                            "deviceName": "test-pgcluster-pgnode01-storage",
                            "diskSizeGb": "100",
                            "index": 1,
                            "interface": "SCSI",
                            "kind": "compute#attachedDisk",
                            "mode": "READ_WRITE",
                            "source": "https://www.********/compute/v1/projects/********/zones/us-central1-b/disks/test-pgcluster-pgnode01-storage",
                            "type": "PERSISTENT"
                        }
                    ],
                    "failed": false,
                    "fingerprint": "yfUn-Y6fc-s=",
                    "id": "7073792825910503172",
                    "idx": 0,
                    "invocation": {
                        "module_args": {
                            "access_token": null,
                            "auth_kind": "serviceaccount",
                            "can_ip_forward": null,
                            "confidential_instance_config": null,
                            "deletion_protection": null,
                            "disks": [
                                {
                                    "auto_delete": true,
                                    "boot": true,
                                    "device_name": "test-pgcluster-pgnode01-system",
                                    "disk_encryption_key": null,
                                    "index": null,
                                    "initialize_params": {
                                        "disk_name": "test-pgcluster-pgnode01-system",
                                        "disk_size_gb": 100,
                                        "disk_type": null,
                                        "source_image": "projects/ubuntu-os-cloud/global/images/family/ubuntu-2204-lts",
                                        "source_image_encryption_key": null
                                    },
                                    "interface": null,
                                    "mode": null,
                                    "source": null,
                                    "type": "pd-ssd"
                                },
                                {
                                    "auto_delete": true,
                                    "boot": null,
                                    "device_name": "test-pgcluster-pgnode01-storage",
                                    "disk_encryption_key": null,
                                    "index": null,
                                    "initialize_params": {
                                        "disk_name": "test-pgcluster-pgnode01-storage",
                                        "disk_size_gb": 100,
                                        "disk_type": null,
                                        "source_image": null,
                                        "source_image_encryption_key": null
                                    },
                                    "interface": null,
                                    "mode": null,
                                    "source": null,
                                    "type": "pd-ssd"
                                }
                            ],
                            "env_type": null,
                            "guest_accelerators": null,
                            "hostname": null,
                            "labels": null,
                            "machine_type": "n2-standard-2",
                            "metadata": {
                                "ssh-keys": "root:ssh-rsa **********"
                            },
                            "min_cpu_platform": null,
                            "name": "test-pgcluster-pgnode01",
                            "network_interfaces": [
                                {
                                    "access_configs": [
                                        {
                                            "name": "External NAT",
                                            "nat_ip": null,
                                            "network_tier": null,
                                            "public_ptr_domain_name": null,
                                            "set_public_ptr": null,
                                            "type": "ONE_TO_ONE_NAT"
                                        }
                                    ],
                                    "alias_ip_ranges": null,
                                    "network": {
                                        "selfLink": "global/networks/default"
                                    },
                                    "network_ip": null,
                                    "subnetwork": null
                                }
                            ],
                            "project": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
                            "scheduling": {
                                "automatic_restart": null,
                                "on_host_maintenance": null,
                                "preemptible": true
                            },
                            "scopes": [
                                "https://www.********/auth/compute"
                            ],
                            "service_account_contents": "{\"type\": \"********\", \"project_id\": \"********\", \"private_key_id\": \"********\", \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMI********/3/g=\\n-----END PRIVATE KEY-----\\n\", \"client_email\": \"********\", \"client_id\": \"********\", \"auth_uri\": \"********\", \"token_uri\": \"https://oauth2.********/token\", \"auth_provider_x509_cert_url\": \"https://www.********/oauth2/v1/certs\", \"client_x509_cert_url\": \"https://www.********/robot/v1/metadata/x509/********%40********.iam.gserviceaccount.com\", \"universe_domain\": \"********\"}",
                            "service_account_email": null,
                            "service_account_file": null,
                            "service_accounts": null,
                            "shielded_instance_config": null,
                            "state": "present",
                            "status": "RUNNING",
                            "tags": {
                                "fingerprint": null,
                                "items": [
                                    "test-pgcluster"
                                ]
                            },
                            "zone": "us-central1-b"
                        }
                    },
                    "item": 0,
                    "kind": "compute#instance",
                    "labelFingerprint": "42WmSpB8rSM=",
                    "lastStartTimestamp": "2024-01-29T04:28:33.117-08:00",
                    "machineType": "https://www.********/compute/v1/projects/********/zones/us-central1-b/machineTypes/n2-standard-2",
                    "metadata": {},
                    "name": "test-pgcluster-pgnode01",
                    "networkInterfaces": [
                        {
                            "accessConfigs": [
                                {
                                    "kind": "compute#accessConfig",
                                    "name": "External NAT",
                                    "natIP": "34.170.109.252",
                                    "networkTier": "PREMIUM",
                                    "type": "ONE_TO_ONE_NAT"
                                }
                            ],
                            "fingerprint": "iv0DBhhLZvE=",
                            "kind": "compute#networkInterface",
                            "name": "nic0",
                            "network": "https://www.********/compute/v1/projects/********/global/networks/default",
                            "networkIP": "10.128.0.24",
                            "stackType": "IPV4_ONLY",
                            "subnetwork": "https://www.********/compute/v1/projects/********/regions/us-central1/subnetworks/default"
                        }
                    ],
                    "scheduling": {
                        "automaticRestart": false,
                        "onHostMaintenance": "TERMINATE",
                        "preemptible": true
                    },
                    "selfLink": "https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode01",
                    "shieldedInstanceConfig": {
                        "enableIntegrityMonitoring": true,
                        "enableSecureBoot": false,
                        "enableVtpm": true
                    },
                    "shieldedInstanceIntegrityPolicy": {
                        "updateAutoLearnPolicy": true
                    },
                    "startRestricted": false,
                    "status": "RUNNING",
                    "tags": {
                        "fingerprint": "2lC7VBE5a4k=",
                        "items": [
                            "test-pgcluster"
                        ]
                    },
                    "zone": "https://www.********/compute/v1/projects/********/zones/us-central1-b"
                },
...

    "msg": "GCP returned error: {'error': {'code': 400, 'message': \"Invalid value for field 'resource.healthChecks[0]': 'https://www.********/compute/v1/projects/********/global/healthChecks/test-pgcluster-primary-hc'. The project '********' was not found.\", 'errors': [{'message': \"Invalid value for field 'resource.healthChecks[0]': 'https://www.********/compute/v1/projects/********/global/healthChecks/test-pgcluster-primary-hc'. The project '********' was not found.\", 'domain': 'global', 'reason': 'invalid'}, {'message': \"Invalid value for field 'resource.instances[0]': 'https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode01'. The project '********' was not found.\", 'domain': 'global', 'reason': 'invalid'}, {'message': \"Invalid value for field 'resource.instances[1]': 'https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode02'. The project '********' was not found.\", 'domain': 'global', 'reason': 'invalid'}, {'message': \"Invalid value for field 'resource.instances[2]': 'https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode03'. The project '********' was not found.\", 'domain': 'global', 'reason': 'invalid'}]}}",
    "request": {
        "body": "{\"kind\": \"compute#targetPool\", \"description\": \"test-pgcluster Primary Target Pool\", \"instances\": [\"https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode01\", \"https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode02\", \"https://www.********/compute/v1/projects/********/zones/us-central1-b/instances/test-pgcluster-pgnode03\"], \"name\": \"test-pgcluster-primary\", \"healthChecks\": [\"https://www.********/compute/v1/projects/********/global/healthChecks/test-pgcluster-primary-hc\"]}",
        "method": "POST",
        "url": "https://compute.********/compute/v1/projects/********/regions/us-central1/targetPools"
    }
}
vitabaks commented 8 months ago

Any ideas? This blocks the implementation of GCP support for my product https://github.com/vitabaks/postgresql_cluster/pull/464

vitabaks commented 5 months ago

Please give me an answer.

vitabaks commented 4 months ago

I think I found the reason for the error. The module only works if selfLink is set manually

example:

        - name: "GCP: [Load Balancer] Create regional backend service"
          google.cloud.gcp_compute_region_backend_service:
            auth_kind: "serviceaccount"
            service_account_contents: "{{ gcp_service_account_contents }}"
            project: "{{ gcp_project | default(project_info.resources[0].projectNumber) }}"
            name: "{{ patroni_cluster_name }}-primary"
            description: "{{ patroni_cluster_name }} primary backend"
            region: "{{ region }}"
            load_balancing_scheme: "INTERNAL"
            protocol: "TCP"
            network:
              selfLink: "global/networks/{{ gcp_network_name }}"
            backends:
              - group: "zones/{{ zone }}/instanceGroups/{{ patroni_cluster_name }}"
                balancing_mode: "CONNECTION"
            health_checks:
              - "global/healthChecks/{{ patroni_cluster_name }}-primary-hc"
            state: present

It doesn't work when we use register: name-of-resource and then we try to use this variable "{{ name-of-resource }}" for example in health_checks parameter.

michaelkosko commented 5 days ago

Is this a bug or do we need to continue explicitly defining the selfLink ourselves? Because the documentation still says this for source of disk:

This field represents a link to a Disk resource in GCP. It can be specified in two ways. First, you can place a dictionary with key ‘selfLink’ and value of your resource’s selfLink Alternatively, you can add register: name-of-resource to a gcp_compute_disk task and then set this source field to “{{ name-of-resource }}”

I only ask because it used to work with 'register: name-of-resource'.

apinter commented 5 days ago

Please give me an answer.

Transition to Terraform. This collection is very poorly managed, and maintained so if you have work that needs to be done then do the transition as soon as you can. Also the vote to remove the gcp_collection is up again.

vitabaks commented 4 days ago

I would really prefer not to delete the collection because my product is based on Ansible, and I would strongly prefer not to switch to Terraform for this.

ericsysmin commented 4 days ago

Yep, it's a terrible collection, which isn't maintained, but prided itself on automation generating this. It's a shame that after all the press over the years this got at AnsibleFest but it never delivered. :(

ericsysmin commented 4 days ago

I would really prefer not to delete the collection because my product is based on Ansible, and I would strongly prefer not to switch to Terraform for this.

I'd take a look at using the ansible.builtin.uri modules, they work great for this