0

I need to reject "*" from stdout lines.

    "stdout_lines": [
        "rchinnn01",
        "rchinnn02",
        "*"
    ]

   - set_fact:
     nfs_clients:  "{{ nfs_clients_out.stdout_lines | reject('search','*') | list }}"

TASK [set_fact] ***************************************************************************************************** An exception occurred during task execution. To see the full traceback, use -vvv. The error was: error: nothing to repeat fatal: [rchinnn03]: FAILED! => {"msg": "Unexpected failure during module execution.", "stdout": ""}

0

Please use as below:

- set_fact:
     nfs_clients: "{{ nfs_clients_out.stdout_lines | reject('match','rchinnn*') | list }}"

Please check jinja2 version details

  • I used provided syntax, but it's taking only "" from stdout_lines. But my requirement is vice-versa, I need everything to be assigned to a variable except "" . I tried by replacing rchinnn* with "*", but it's taking * as wildcard and it's rejecting everything. – Pandu Feb 12 at 17:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.