garbled1 / ansible_modules

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

Construct query using pysnow QueryBuilder to allow more complex queries #1

Closed joaocpinto closed 6 years ago

joaocpinto commented 6 years ago

Changed the query field to allow conditional queries by making use of pysnow.QueryBuilder

eg:

- name: Find open changes
  snow_record_find:
    username: '{{ username }}'
    password: '{{ password }}'
    instance: dev99999
    table: change_request
    query:
      AND:
        not_equals:
          active: "True"
          type: "standard"
          u_change_stage: "80"
        contains:
          u_template: "CD-I2-RIA"
      NQ:
        equals:
          sys_created_by: '{{ username }}'

The previous behavior can be maintained by using key/value on dict:

 - name: Search for incident assigned to group, return specific fields
   snow_search_records:
     username: ansible_test
     password: my_password
     instance: dev99999
     table: incident
     query:
       assignment_group: d625dccec0a8016700a222a0f7900d06
     return_fields:
       - number
       - opened_at
garbled1 commented 6 years ago

Give me a day or so, and I'll merge this into my PR for ansible itself.

garbled1 commented 6 years ago

This is awesome btw, thank you!

joaocpinto commented 6 years ago

Cool, thanks :)