google.cloud
google.cloud copied to clipboard
gcp_dns_ resource_record_set invalid value for parameter name
ISSUE TYPE
- Bug Report
COMPONENT NAME
gcp_dns_ resource_record_set
ANSIBLE VERSION
tried with older versions as well got the same issue i.e 2.8 2.7
ansible 2.9.9
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/nepallink/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Apr 15 2020, 17:20:14) [GCC 7.5.0]
CONFIGURATION
- name: creating/adding a cname record
gcp_dns_resource_record_set:
name: "example.com."
managed_zone:
name: "{{ lookup('env','ZONE_NAME') }}"
dnsName: "{{ lookup('env','DNS_NAME') }}"
type: CNAME
ttl: 300
target:
- "{{ lookup('env','CNAME_VALUE') }}"
project: "{{ lookup('env','GCP_PROJECT') }}"
auth_kind: serviceaccount
service_account_file: "{{ credentials_file }}"
state: present
OS / ENVIRONMENT
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
EXPECTED RESULTS
DNS CNAME record created
ACTUAL RESULTS
PLAY [localhost] ************************************************************************************************************************************
TASK [Gathering Facts] ******************************************************************************************************************************
ok: [localhost]
TASK [zeroonedns : creating/adding a cname record] **************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "GCP returned error: {u'error': {u'message': u\"Invalid value for 'parameters.name': ''\", u'code': 400, u'errors': [{u'reason': u'invalid', u'message': u\"Invalid value for 'parameters.name': ''\", u'domain': u'global'}]}}"}
PLAY RECAP ******************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
It's a bit late, but it looks like this is what happens if (a) the resource record does not already exist and (b) the managed_zone dnsName doesn't end in a dot (.).
Annoyingly, this action works fine without the trailing dot if the RR already exists in GCP DNS, but will refuse to add a new record if the dot is missing.