Hi,

The error says all:
"[WARNING]: conditional statements should not include jinja2 templating
delimiters such as {{ }}"

So, your "when" statement should look like:
when: wc2env == 'stage'

Something else:
You are already passing on "wc2env" as an extra variable. You don't need
the lines below, declaring it again, in the playbook:
 vars:
   wc2env: '{{ wc2env }}'

Alex

On Tue, Feb 7, 2023 at 11:48 AM SysAdmin EM <emaw...@gmail.com> wrote:

> I again, thank you all for your help, I’m really learning a lot.
>
> I have a new query. I am passing via "extra-vars" a variable called wc2env
> and I need to compare it with a string (stage or prod).
>
> Here is my playbook:
>
>   hosts: all
>  gather_facts: no
>  vars:
>    wc2env: '{{ wc2env }}'
>  tasks:
> - name: "Validando si debo deployar dominio en PROD"
>  ansible.builtin.import_playbook: add_carrier_prod.yaml
>  when: "{{ wc2env == 'prod' }}"
>
> - name: "Validando si debo deployar el dominio en STAGE"
>  ansible.builtin.import_playbook: add_carrier_stage.yaml
>  when: "{{ wc2env == 'stage' }}"
>
> I run the playbook this way and for some reason the condition returns
> "false":
>
> ansible-playbook -i hosts --extra-vars "wc2env=stage"
> alta_carrier/playbook/tasks_target.yaml
>
> Here the debug:
>
> PLAYBOOK: tasks_target.yaml
> ************************************************************************************************************************
>
> Positional arguments: alta_carrier/playbook/tasks_target.yaml
> verbosity: 8
> connection: smart
> timeout: 10
> become_method: sudo
> tags: ('all',)
> inventory: ('/etc/ansible/webcheckin/hosts',)
> extra_vars: ('wc2env=stage',)
> forks: 50
> step: True
> 4 plays in alta_carrier/playbook/tasks_target.yaml
>
> [WARNING]: conditional statements should not include jinja2 templating
> delimiters such as {{ }} or {% %}. Found: {{ wc2env == 'prod' }}
> skipping: [wc2-stage] => {
>    "changed": false,
>    "skip_reason": "Conditional result was False"
> }
>
> I’m doing something wrong and I don’t realize they could help me.
>
> Regards,
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CAGUDtn%3DML6m-Q%2Boo9EfyWo8r7R91AgrM27_%3DNVU9FT0c_KokJw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CAGUDtn%3DML6m-Q%2Boo9EfyWo8r7R91AgrM27_%3DNVU9FT0c_KokJw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 



[image: Edmonton_sig_RGB_S.jpg]

Alex Wanderley

Application and Infrastructure Analyst II
Server Solutions & Automation

Financial and Corporate Services | Open City and Technology



780-496-4156  Office

780-819-0273  Mobile



City of Edmonton

Century Place, 19th Floor

9803 102A Avenue NW

Edmonton AB, T5J 3A3



All information contained in this email post is proprietary to the City of
Edmonton, confidential and intended only for the addressed recipient. If
you have received this post in error, please disregard the contents, inform
the sender of the misdirection, and remove it from your system. The
copying, dissemination or distribution of this email, if misdirected, is
strictly prohibited.

-- 
*The contents of this message and any attachment(s) are confidential, 
proprietary to the City of Edmonton, and are intended only for the 
addressed recipient. If you have received this in error, please disregard 
the contents, inform the sender of the misdirection, and remove it from 
your system. The copying, dissemination, or distribution of this message, 
if misdirected, is strictly prohibited.*

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CADp8UUSaEWCfjpsSnH4rk9N3inJ9a1Mj6oVoKy7r6mcErSjEBQ%40mail.gmail.com.

Reply via email to