garbled1 / ansible_modules

Ansible modules for various things
GNU General Public License v3.0
2 stars 3 forks source link

Possible to update an existing CI record via snow_record module? #5

Open epicanthal opened 5 years ago

epicanthal commented 5 years ago

Is it possible to update an existing CI? Maybe I'm misunderstanding the exact usage. I have the following tasks:

    - name: dump dns_ptr_record
      debug: var=dns_ptr_record
      delegate_to: localhost

    - name: Update FQDN on CMDB Record
      snow_record:
        username: "{{ snow_username }}"
        password: "{{ snow_password }}"
        instance: "{{ snow_instance }}"
        state: present
        number: "{{ sn_sys_id }}"
        table: cmdb_ci_netgear
        lookup_field: sys_id
        data:
          fqdn: "{{ dns_ptr_record }}"
      register: snow_fqdn_update
      delegate_to: localhost

Which results in:

TASK [dump dns_ptr_record] *****************************************************
ok: [switch01 -> localhost] => {
    "dns_ptr_record": "switch01.testdomain.com"
}

TASK [Update FQDN on CMDB Record] **********************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'module' object has no attribute 'UnexpectedResponse'
fatal: [switch01 -> localhost]: FAILED! => {
    "changed": false, 
    "rc": 1
}

MSG:

MODULE FAILURE
See stdout/stderr for the exact error

MODULE_STDERR:

Traceback (most recent call last):
  File "<stdin>", line 113, in <module>
  File "<stdin>", line 105, in _ansiballz_main
  File "<stdin>", line 48, in invoke_module
  File "/tmp/ansible_snow_record_payload_6w5VRp/__main__.py", line 332, in <module>
  File "/tmp/ansible_snow_record_payload_6w5VRp/__main__.py", line 328, in main
  File "/tmp/ansible_snow_record_payload_6w5VRp/__main__.py", line 317, in run_module
AttributeError: 'module' object has no attribute 'UnexpectedResponse'

I can do a "lookup" via sys_id like this that works for me:

    - name: Lookup CMDB Record
      snow_record:
        username: "{{ snow_username }}"
        password: "{{ snow_password }}"
        instance: "{{ snow_instance }}"
        state: present
        number: "{{ sn_sys_id }}"
        table: cmdb_ci_netgear
        lookup_field: sys_id
      register: sn_lookup
      delegate_to: localhost

So I think I'm close on the correct usage of the snow_record module. Any help would be appreciated.