google.cloud icon indicating copy to clipboard operation
google.cloud copied to clipboard

gcp_dns_resource_record_set does not work with service_account_contents

Open ThYpHo0n opened this issue 5 years ago • 1 comments

SUMMARY

Migrating old issue over from: https://github.com/ansible/ansible/issues/58242 Still happening for me on ansible 2.9.10

ISSUE TYPE
  • Bug Report
COMPONENT NAME

gcp_dns_resource_record_set

ANSIBLE VERSION
ansible 2.9.10
  config file = /Users/user/workspace/devops-ansible/ansible.cfg
  configured module search path = ['/Users/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.9.10/libexec/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 21 2020, 10:48:26) [Clang 11.0.3 (clang-1103.0.32.62)]
STEPS TO REPRODUCE
- name: DNS setup
  hosts: localhost
  gather_facts: false
  become: false
  vars:
    target_ip: "123.123.123.123"
    gcp_project: "PROJECT"
    gcp_cred_kind: serviceaccount
    gcp_cred_content: "{{ gcp_service_account_PROJECT }}"
    gcp_cred_file: "./PROJECT-12345678.json"
  tasks:
    - name: create dns zones
      gcp_dns_managed_zone:
        name: foo-zone
        dns_name: bar.foo.
        description: "foo"
        project: "{{ gcp_project }}"
        auth_kind: "{{ gcp_cred_kind }}"
        service_account_file: "{{ gcp_cred_file }}"
        state: present
      register: registered_zones

    - name: Create dns records
      gcp_dns_resource_record_set:
        managed_zone: "{{ registered_zones }}"
        name: "www.bar.foo."
        target:
          - "{{ target_ip }}"
        type: "A"
        ttl: 3600
        project: "{{ gcp_project }}"
        auth_kind: "{{ gcp_cred_kind }}"
        service_account_contents: "{{ gcp_cred_content }}"
        # this works
        #service_account_file: "{{ gcp_cred_file }}"
        state: present
EXPECTED RESULTS

I expect the dns records to actually be created regardless if service_account_contents or service_account_file is used.

ACTUAL RESULTS
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Credential type 'serviceaccount' not implemented"}

ThYpHo0n avatar Sep 01 '20 10:09 ThYpHo0n

Still happens in 2.9.13;

I added the workaround to /usr/local/lib/python3.8/site-packages/ansible/modules/cloud/google/gcp_dns_resource_record_set.py for the time being

368 'service_account_contents': module.params.get('service_account_contents'),

k-y avatar Nov 17 '20 21:11 k-y