Home > Enterprise >  Ansible4 builtin shell rewrites trust list command to trust list-modules
Ansible4 builtin shell rewrites trust list command to trust list-modules

Time:06-22

Ansible4 builtin shell rewrites trust list command to trust list-modules:

- block:
  - name: Check if Certs installed - Linux RHEL8 - step 1
    ansible.builtin.shell:
      cmd: "trust list"
    register: isCertInstalled

some additional formatting is piped to whittle this down to a number (omitted for privacy purposes), then:

TASK [Check if Certs installed - Linux RHEL8 - step 1] ******************************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"changed": true, "cmd": ["trust", "list"], "delta": "0:00:00.007482", "end": "2022-06-21 18:20:43.759496", "msg": "non-zero return code", "rc": 2, "start": "2022-06-21 18:20:43.752014", "stderr": "p11-kit: 'list-modules' is not a valid command. See 'trust --help'", "stderr_lines": ["p11-kit: 'list-modules' is not a valid command. See 'trust --help'"], "stdout": "", "stdout_lines": []}

Any idea how to force it to literally just run "trust list" instead of "trust list-modules"? RHEL 8.5, Ansible 4.1, Python 3.9

CodePudding user response:

Use the full path for the trust command and enclose trust list in single quotes. Ansible is only seeing LIST, tying that in as list module.

ie. "'trust list' | grep Internal-Cert | wc -l | tr -d '\n'"

  • Related