# gcp\_dns\_resource\_record\_set - for subdomains

**URL:** <https://forum.ansible.com/t/gcp-dns-resource-record-set-for-subdomains/29293>\
**Category:** Ansible Project\
**Created:** [December 18, 2018, 8:34pm UTC](https://forum.ansible.com/t/gcp-dns-resource-record-set-for-subdomains/29293 "2018-12-18T20:34:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![katja.loeffler](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@katja.loeffler](https://forum.ansible.com/u/katja.loeffler)\
**Post date:** [December 18, 2018, 8:34pm UTC](https://forum.ansible.com/t/gcp-dns-resource-record-set-for-subdomains/29293/1 "2018-12-18T20:34:01Z")

</div>

Hi,

I’m using ansible 2.7.

I am trying to set a bunch of dns records for my project using the gcp\_dns\_resource\_record\_set module.

This works just fine:

- name: create a resource record set for {{env}}  
gcp\_dns\_resource\_record\_set:  
name: “{{ env }}.{{ dns\_name }}”  
managed\_zone: “{{ my\_managed\_zone }}”  
type: A  
ttl: 300  
target:
- “{{ new\_global\_ip.address }}”  
project: “{{ project\_id }}”  
auth\_kind: “{{ auth\_kind }}”  
service\_account\_file: “{{ credentials\_file }}”  
state: present

My record is being created.

Trying to set a CNAME record like …

- name: create a resource record set for _.{{env}}.{{dns\_name}}  
gcp\_dns\_resource\_record\_set:  
name: "_.{{ env }}.{{ dns\_name }}"  
managed\_zone: “{{ my\_managed\_zone }}”  
type: CNAME  
ttl: 600  
target:
- “{{ env }}.{{dns\_name }}”  
project: “{{ project\_id }}”  
auth\_kind: “{{ auth\_kind }}”  
service\_account\_file: “{{ credentials\_file }}”  
state: present

This is NOT working…

The full traceback is:  
Traceback (most recent call last):  
File “/home/kloeffler/.ansible/tmp/ansible-tmp-1545164919.18-37286040098745/AnsiballZ\_gcp\_dns\_resource\_record\_set.py”, line 113, in   
\_ansiballz\_main()  
File “/home/kloeffler/.ansible/tmp/ansible-tmp-1545164919.18-37286040098745/AnsiballZ\_gcp\_dns\_resource\_record\_set.py”, line 105, in \_ansiballz\_main  
invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)  
File “/home/kloeffler/.ansible/tmp/ansible-tmp-1545164919.18-37286040098745/AnsiballZ\_gcp\_dns\_resource\_record\_set.py”, line 48, in invoke\_module  
imp.load\_module(‘ **main** ’, mod, module, MOD\_DESC)  
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 473, in   
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 185, in main  
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 196, in create  
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 387, in create\_change  
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 405, in resource\_to\_change\_request  
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 393, in update\_soa  
File “/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py”, line 378, in prefetch\_soa\_resource  
ValueError: Google DNS Managed Zone XXXXXXXXXXXXX not found

fatal: [localhost]: FAILED! =\> {  
“changed”: false,  
“module\_stderr”: “Traceback (most recent call last):\n File "/home/kloeffler/.ansible/tmp/ansible-tmp-1545164919.18-37286040098745/AnsiballZ\_gcp\_dns\_resource\_record\_set.py", line 113, in \n \_ansiballz\_main()\n File "/home/kloeffler/.ansible/tmp/ansible-tmp-1545164919.18-37286040098745/AnsiballZ\_gcp\_dns\_resource\_record\_set.py", line 105, in \_ansiballz\_main\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\n File "/home/kloeffler/.ansible/tmp/ansible-tmp-1545164919.18-37286040098745/AnsiballZ\_gcp\_dns\_resource\_record\_set.py", line 48, in invoke\_module\n imp.load\_module(‘ **main** ’, mod, module, MOD\_DESC)\n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 473, in \n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 185, in main\n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 196, in create\n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 387, in create\_change\n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 405, in resource\_to\_change\_request\n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 393, in update\_soa\n File "/tmp/ansible\_gcp\_dns\_resource\_record\_set\_payload\_h2FmDS/ **main**.py", line 378, in prefetch\_soa\_resource\nValueError: Google DNS Managed Zone XXXXXXXXXXXXX not found\n”,  
“module\_stdout”: “”,  
“msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”,  
“rc”: 1

As you can see in the ansible calls, I am usingthe same {{ my\_managed\_zone }} (which I got by calling gcp\_dns\_managed\_zone ).  
It is also not working for A records like " something.{{ env }}.{{ dns\_name }}. "

Help?  
Anyone?  
What am I missing?

Thanks!  
Katja
