# How do I use snow\_record and snow\_record find in Ansible? Or should I do something different?

**URL:** <https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914>\
**Category:** Ansible Project\
**Created:** [March 19, 2019, 7:32pm UTC](https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914 "2019-03-19T19:32:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beau\_Gauthreaux](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Beau\_Gauthreaux](https://forum.ansible.com/u/Beau_Gauthreaux)\
**Post date:** [March 19, 2019, 7:32pm UTC](https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914/1 "2019-03-19T19:32:16Z")

</div>

I’m trying to gather change record information from ServiceNow. Specifically I would like to query against a hostname and find if that server has change ticket open. I came across both of these modules for Ansible. I have had little success getting them to function properly. I’m hoping my syntax is bad or I’m doing something dumb. Here are my playbooks.

```auto
   - hosts: localhost
  connection: local
  gather_facts: no
  ignore_errors: True
  tasks:
  - name: Grab a user record
    snow_record:
      username: testuser
      password: somepass
      instance: myinstance
      state: present
      number: CHG9999
      table: change_request
      lookup_field: cmdb_ci.name=someservername

```

For snow\_record\_find:

```auto
- hosts: mytest
  tasks:
  - name: Grab a user record
    snow_record_find:
      username: testuser
      password: somepass
      instance: someinstance
      #state: present
      #number: null??
      table: change_request
      query:
        AND:
          equals:
            active: "True"
            type: "standard"
            u_change_stage: "80"
          contains:
            u_template: "MY-Template"

```

There does not seem to be many examples or documents on how to use these modules. I’m open to using something different as long as it can be done via bash, Python, Ansible or some other command line utility that runs on Linux. Also I grabbed the snow\_record\_find module from [https://github.com/garbled1/ansible\_modules](https://github.com/garbled1/ansible_modules) If you want to try it yourself.

Error output for snow\_record:

```auto
    The full traceback is:
    Traceback (most recent call last):
      File "/root/.ansible/tmp/ansible-tmp-1553017980.16-56687342300902/AnsiballZ_snow_record.py", line 113, in <module>
        _ansiballz_main()
      File "/root/.ansible/tmp/ansible-tmp-1553017980.16-56687342300902/AnsiballZ_snow_record.py", line 105, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/root/.ansible/tmp/ansible-tmp-1553017980.16-56687342300902/AnsiballZ_snow_record.py", line 48, in invoke_module
        imp.load_module(' __main__', mod, module, MOD_DESC)
      File "/tmp/ansible_snow_record_payload_0p5jn8/ __main__.py", line 332, in <module>
      File "/tmp/ansible_snow_record_payload_0p5jn8/ __main__.py", line 328, in main
      File "/tmp/ansible_snow_record_payload_0p5jn8/ __main__.py", line 317, in run_module
    AttributeError: 'module' object has no attribute 'UnexpectedResponse'

    fatal: [localhost]: FAILED! => {
        "changed": false, 
        "module_stderr": "Traceback (most recent call last):\n File \"/root/.ansible/tmp/ansible-tmp-1553017980.16-56687342300902/AnsiballZ_snow_record.py\", line 113, in <module>\n _ansiballz_main()\n File \"/root/.ansible/tmp/ansible-tmp-1553017980.16-56687342300902/AnsiballZ_snow_record.py\", line 105, in _ansiballz_main\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n File \"/root/.ansible/tmp/ansible-tmp-1553017980.16-56687342300902/AnsiballZ_snow_record.py\", line 48, in invoke_module\n imp.load_module(' __main__', mod, module, MOD_DESC)\n File \"/tmp/ansible_snow_record_payload_0p5jn8/ __main__.py\", line 332, in <module>\n File \"/tmp/ansible_snow_record_payload_0p5jn8/ __main__.py\", line 328, in main\n File \"/tmp/ansible_snow_record_payload_0p5jn8/ __main__.py\", line 317, in run_module\nAttributeError: 'module' object has no attribute 'UnexpectedResponse'\n", 
        "module_stdout": "", 
        "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 
        "rc": 1

```

Error output for snow\_record\_show:

```auto
atal: []: FAILED! => {
    "changed": false, 
    "module_stderr": "Shared connection to closed.\r\n", 
    "module_stdout": "Traceback (most recent call last):\r\n File \"/root/.ansible/tmp/ansible-tmp-1553019300.21-10858374496170/AnsiballZ_snow_record_find.py\", line 113, in <module>\r\n _ansiballz_main()\r\n File \"/root/.ansible/tmp/ansible-tmp-1553019300.21-10858374496170/AnsiballZ_snow_record_find.py\", line 105, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/root/.ansible/tmp/ansible-tmp-1553019300.21-10858374496170/AnsiballZ_snow_record_find.py\", line 48, in invoke_module\r\n imp.load_module(' __main__', mod, module, MOD_DESC)\r\n File \"/tmp/ansible_snow_record_find_payload_j9P62r/ __main__.py\", line 260, in <module>\r\n File \"/tmp/ansible_snow_record_find_payload_j9P62r/ __main__.py\", line 257, in main\r\n File \"/tmp/ansible_snow_record_find_payload_j9P62r/ __main__.py\", line 249, in run_module\r\n File \"/usr/lib/python2.7/site-packages/pysnow/legacy_request.py\", line 91, in _all_inner\r\n yield self._get_content(response)\r\n File \"/usr/lib/python2.7/site-packages/pysnow/legacy_request.py\", line 332, in _get_content\r\n server_error['summary'], server_error['details']\r\npysnow.legacy_exceptions.UnexpectedResponse: Unexpected HTTP GET response code. Expected 200, got 401\r\n", 
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", 

```

---

<div class="post-metadata">

**Author:** ![Ankit2](https://avatars.discourse-cdn.com/v4/letter/a/ea5d25/32.png) [@Ankit2](https://forum.ansible.com/u/Ankit2)\
**Post date:** [March 20, 2019, 8:32am UTC](https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914/2 "2019-03-20T08:32:55Z")

</div>

Do you have ADFS in between? This module can’t handle ADFS.

---

<div class="post-metadata">

**Author:** ![Beau\_Gauthreaux](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Beau\_Gauthreaux](https://forum.ansible.com/u/Beau_Gauthreaux)\
**Post date:** [March 22, 2019, 10:44am UTC](https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914/3 "2019-03-22T10:44:19Z")

</div>

I do not have ADFS in between.

Thanks,

---

<div class="post-metadata">

**Author:** ![Beau\_Gauthreaux](https://avatars.discourse-cdn.com/v4/letter/b/9fc348/32.png) [@Beau\_Gauthreaux](https://forum.ansible.com/u/Beau_Gauthreaux)\
**Post date:** [April 11, 2019, 5:52pm UTC](https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914/4 "2019-04-11T17:52:40Z")

</div>

Anybody else have ideas about this?

---

<div class="post-metadata">

**Author:** ![Gajendra\_Gaikwad1](https://avatars.discourse-cdn.com/v4/letter/g/9de053/32.png) [@Gajendra\_Gaikwad1](https://forum.ansible.com/u/Gajendra_Gaikwad1)\
**Post date:** [July 27, 2020, 9:10am UTC](https://forum.ansible.com/t/how-do-i-use-snow-record-and-snow-record-find-in-ansible-or-should-i-do-something-different/29914/5 "2020-07-27T09:10:44Z")

</div>

hello Gauthreaux,

Does your problem has been resolved?

Can you help me to find service\_request(ritm) variables using snow\_record\_find module.

Regards,  
GG
