cyberark / ansible-modules

Ansible Modules for CyberArk Privileged Account Security Web Service SDK
MIT License
37 stars 17 forks source link

Syntax Error in YAML - Query #5

Closed ipv6freely closed 3 years ago

ipv6freely commented 3 years ago

I'm trying to use the example:

- hosts: localhost

  tasks:

    - name: credential retrieval basic
      cyberark_credential:
        api_base_url: "http://10.10.0.1"
        app_id: "TestID"
        query: "Safe=test;UserName=admin"
      register: {{ result }}
      no_log: true

    - name: Debug message
      debug: 
        var: {{ result }}

Obviously, using the correct values for my setup.

I'm getting an error from Ansible:

JSON: Expecting value: line 1 column 1 (char 0)

Syntax Error while loading YAML.
  found unacceptable key (unhashable type: 'AnsibleMapping')

The error appears to be in '[redacted]/cyberark.yml': line 26, column 21, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

        query: "Safe=[redacted];UserName=admin"
                    ^ here

There appears to be both 'k=v' shorthand syntax and YAML in this task. Only one syntax may be used.
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:

    with_items:
      - {{ foo }}

Should be written as:

    with_items:
      - "{{ foo }}"

It appears that using k=v pairs within the query is the way this is supposed to be done, but Ansible seems to complain about it. What am I doing wrong, here?

ipv6freely commented 3 years ago

The issue is actually that it's trying to register an already existing variable, based on the syntax. Removing the {{}} from both the register and the debug var line fixed it. I've included that fix for README.md in my recent pull request, along with Python3 issues.