Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

update_cname_record and 'current' #36

Open
johnnynumba5 opened this issue Oct 27, 2017 · 3 comments
Open

update_cname_record and 'current' #36

johnnynumba5 opened this issue Oct 27, 2017 · 3 comments

Comments

@johnnynumba5
Copy link

Hello, I currently have the following in Ansible, where I'm trying to change the existing CNAME of ansible.xyz to point to the A record of ansibletest002.xyz. It's currently pointing to the A record of ansibletest001.xyz, but again I'm trying to change it so that it points to ansibletest002.xyz.

- name: Update internal CNAME record
  infoblox:
    server=10.1.1.1
    username=joebob
    password=joebob
    action=update_cname_record
    dns_view=Internal
    cname=ansible.xyz
    canonical=ansibletest002.xyz
  register: infoblox_result

However, when I run Ansible I keep getting the following error

    }, 

 "msg": "The 'current' check is not a dict"
}

So when I add the current parameter in it as such,

- name: Update internal CNAME record
  infoblox:
    server=10.1.1.1
    username=joebob
    password=joebob
    action=update_cname_record
    dns_view=Internal
    cname=ansible.xyz
    canonical=ansibletest002.xyz
    current=ansible.xyz
  register: infoblox_result

I then get the following error:

"msg": "argument current is of type <type 'str'> and we were unable to convert to dict: dictionary requested, could not parse JSON or key=value"
}

My question is, what exactly am I suppose to input for the value of current? It appears to be looking for some sort of key value but if that's true where/how do I attain that?

Any help would be appreciated, thank you.

@jnc-cnj
Copy link

jnc-cnj commented Nov 13, 2017

Can you try this?

current:
  cname: ansible.xyz

@johnnynumba5
Copy link
Author

Thank you for the reply! Unfortunately it causes a syntax error. I tried:

current:
  cname: ansible.xyz
current:
  - cname: ansible.xyz
current:
   cname=ansible.xyz

The error message is similar to:

The error appears to have been in '/path/to/role/tasks/main.yml': line 22, column 12, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    canonical=ansibletest002.dpt
    current:
           ^ here

@asainsbury
Copy link

asainsbury commented Nov 22, 2017

The issue is due to the way you have formated the playbook.

The update function requires a dictionary on input, but you have to format the entire play with ':' vs '='

---
- hosts: localhost
  connection: local
  gather_facts: False

  tasks:
    - name: update update_cname_record
      infoblox:
        server: 192.168.1.2
        username: admin
        password: infoblox
        action: update_cname_record
 
        # Change to this
        cname: my_update.local
        canonical: apache05.local
 
        # Obviously the current content
        current:
          cname: my_update.local
          canonical: apache03.local

     
      register: infoblox

    - name: Do awesome stuff with the result
      debug: msg="Go crazy!"

I'm looking at producing a set of known working examples, which can be run as a set of tests for each PR, and will update the README when I'm done.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants