I am trying to find whether a certain letter exists in an stdout_lines
array.
I want the role to run if there is a 'P' found in the stdout_output.
The stdout_lines array looks like this "stdout": "P\r\nA\r\nS\r\nI\r\n",
*"stdout_lines":
["P", "A", "S", "I"]*
myrole.yml
---
- hosts: windows
gather_facts: false
roles:
- all_servers
*- {role: production_server, when: prod_fact.find('P')}*
The error I am getting is fatal: [hostname]: FAILED! => {"failed": true,
"msg": "ERROR! The conditional check '{{prod_fact}}.find('P')' failed. The
error was: ERROR! template error while templating string: expected token
',', got 'string'"}
In order to get the stdout_variable I am using *set_fact*
---
- name: Check Env Type and Save it in Var=prod_fact
script: files/CheckEnvType.ps1 -hostname {{inventory_hostname}}
register: result
- set_fact:
prod_fact: "{{result.stdout_lines | default('')}}"
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/96400119-dfb4-42c8-b9f3-fbd90640d1d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.