I am working on ansible playbook to grab SNOW record by using snow_record_find module. The documentation (https://docs.ansible.com/ansible/latest/modules/snow_record_find_module.html) have very limited example.
Besides that, I am also unable to understand accurately the api docs (https://pysnow.readthedocs.io/en/latest/api/query_builder.html).
I have tried this play:
    - name: Find records in sc_item_option list
      snow_record_find:
        username: username
        password: password
        instance: instance
        table: sc_item_option
        query:
         sys_id:
           IN:     
             - "5203930cdb230010a5d39235ca9619f6"
             - "605d12bedbe70010a5d39235ca9619dd"
             - "81115fc8db230010a5d39235ca96193d"
      register: allVarsRecord
and get this error:
Expected value of type `str` or `list`, not <class 'dict'>", "query": {"sys_id": {"IN": ["5203930cdb230010a5d39235ca9619f6", "605d12bedbe70010a5d39235ca9619dd", "81115fc8db230010a5d39235ca96193d"]}}
I have also have revised my playbook to be like this:
    - name: Find records in sc_item_option list
      snow_record_find:
        username: username
        password: password
        instance: instance
        table: sc_item_option
        query:
          IN:
            sys_id:     
              - "5203930cdb230010a5d39235ca9619f6"
              - "605d12bedbe70010a5d39235ca9619dd"
              - "81115fc8db230010a5d39235ca96193d"
      register: allVarsRecord
    - debug:
        msg: "{{allVarsRecord}}"
and then get this error:
Expected value of type `str` or `list`, not <class 'dict'>", "query": {"IN": {"sys_id": ["5203930cdb230010a5d39235ca9619f6", "605d12bedbe70010a5d39235ca9619dd", "81115fc8db230010a5d39235ca96193d"]}}
How can I resolve this error and make this work? Any suggestion will do as my mind is exhausted already to think on this..
Thanks in advance.
Use equals instead of IN, depending on the value, the snow query builder will add IN (if list) or = (if string) condition.
    - name: Find records in sc_item_option list
      snow_record_find:
        username: username
        password: password
        instance: instance
        table: sc_item_option
        query:
          equals:   
            sys_id:
              - "5203930cdb230010a5d39235ca9619f6"
              - "605d12bedbe70010a5d39235ca9619dd"
              - "81115fc8db230010a5d39235ca96193d"
      register: allVarsRecord
PS: Untested. Created based on the query builder documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With