The error message is strange and I can not reproduce it in Ansible 2. But
your condition still will not work, a list does not have a find method. In
Ansible you can search a list with in:
roles:
- all_servers
- {role: production_server, when: '"P" in prod_fact'}
On Tuesday, June 14, 2016 at 1:02:51 PM UTC-5, [email protected] wrote:
>
> 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/32f65e07-39c0-42a1-a66a-aa873c388b5e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.