Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-08 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
Read this article for a more thorough explanation of import vs include and how 
conditions on them are handled.

https://www.devopsschool.com/blog/ansible-include-and-import-with-differences-explanined/

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Feb 8, 2023, at 8:28 AM, Walter P. Rowe (Fed)  wrote:

task path: /etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
skipping: [wc2-stage] => {
   "changed": false,
   "skip_reason": "Conditional result was False"
}

Look at the red text above. You have a prod task file. Your wc2env variable has 
a value of 'stage'. Your task in the prod file has a condition of when wc2env 
== 'prod'. Since wc2env == 'stage' this 'prod' task is the one being skipped.

The skipping message means the task itself is being skipping because the 
condition you place on it evaluated to false. The task would only execute if 
the condition evaluated to true.

You provided these two tasks in a prior message.

- name: "deploy prod"
  ansible.builtin.import_playbook: add_carrier_prod.yaml
  when: wc2env == 'prod'

- name: "deploy stage"
  ansible.builtin.import_playbook: add_carrier_stage.yaml
  when: wc2env == 'stage'

You are using 'include_playbook'. When you place a condition on 
'import_playbook' it does not skip importing the playbook when the condition is 
false. It effectively places that condition on every task inside the imported 
playbook. If you want to skip the import itself you should use include vs 
import. In one of my playbooks I have a series of include_tasks tasks. The task 
files included are also ansible yaml files. Some of the include_tasks tasks in 
my playbook have when clauses on them. If one of those 'when' clauses evaluates 
to false, the task file is NOT included. In your case if one of your 
include_playbook 'when' clauses evaluates to false the playbook is still 
imported and all of the tasks are assigned the added condition from your 
import_playbook task.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Feb 8, 2023, at 7:56 AM, SysAdmin EM  wrote:

This is the entire output:

ansible-playbook [core 2.12.9]
 config file = /etc/ansible/ansible.cfg
 configured module search path = ['/home/emanuel/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
 ansible python module location = /usr/lib/python3/dist-packages/ansible
 ansible collection location = 
/home/emanuel/.ansible/collections:/usr/share/ansible/collections
 executable location = /usr/bin/ansible-playbook
 python version = 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
 jinja version = 2.10.1
 libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
verify_file() method
script declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
verify_file() method
auto declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
verify_file() method
Not replacing invalid character(s) "{'-'}" in group name (kiucargo-servers)
[WARNING]: Invalid characters were found in group names but not replaced, use 
- to see details
Parsed /etc/ansible/webcheckin/hosts inventory source with yaml plugin
Loading collection community.mysql from 
/usr/lib/python3/dist-packages/ansible_collections/community/mysql
Loading collection community.general from 
/usr/lib/python3/dist-packages/ansible_collections/community/general
Loading callback plugin default of type stdout, v2.0 from 
/usr/lib/python3/dist-packages/ansible/plugins/callback/default.py
Attempting to use 'default' callback.
Skipping callback 'default', as we already have a stdout callback.
Attempting to use 'junit' callback.
Attempting to use 'minimal' callback.
Skipping callback 'minimal', as we already have a stdout callback.
Attempting to use 'oneline' callback.
Skipping callback 'oneline', as we already have a stdout callback.
Attempting to use 'tree' callback.

PLAYBOOK: tasks_target.yaml 

Positional arguments: alta_carrier/playbook/tasks_target.yaml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/webcheckin/hosts',)
extra_vars: ('wc2env=stage carrier=LL',)
forks: 50
step: True
4 plays in alta_carrier/playbook/tasks_target.yaml

PLAY [Seleccionamos el destino] 

META: ran handlers
META: ran handlers
META: ran handlers

PLAY [Creando DNS para nuevo carrier WC2 STAGE] 

META: ran handlers
Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: yes

Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: 

Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-08 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
task path: /etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
skipping: [wc2-stage] => {
   "changed": false,
   "skip_reason": "Conditional result was False"
}

Look at the red text above. You have a prod task file. Your wc2env variable has 
a value of 'stage'. Your task in the prod file has a condition of when wc2env 
== 'prod'. Since wc2env == 'stage' this 'prod' task is the one being skipped.

The skipping message means the task itself is being skipping because the 
condition you place on it evaluated to false. The task would only execute if 
the condition evaluated to true.

You provided these two tasks in a prior message.

- name: "deploy prod"
  ansible.builtin.import_playbook: add_carrier_prod.yaml
  when: wc2env == 'prod'

- name: "deploy stage"
  ansible.builtin.import_playbook: add_carrier_stage.yaml
  when: wc2env == 'stage'

You are using 'include_playbook'. When you place a condition on 
'import_playbook' it does not skip importing the playbook when the condition is 
false. It effectively places that condition on every task inside the imported 
playbook. If you want to skip the import itself you should use include vs 
import. In one of my playbooks I have a series of include_tasks tasks. The task 
files included are also ansible yaml files. Some of the include_tasks tasks in 
my playbook have when clauses on them. If one of those 'when' clauses evaluates 
to false, the task file is NOT included. In your case if one of your 
include_playbook 'when' clauses evaluates to false the playbook is still 
imported and all of the tasks are assigned the added condition from your 
import_playbook task.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Feb 8, 2023, at 7:56 AM, SysAdmin EM  wrote:

This is the entire output:

ansible-playbook [core 2.12.9]
 config file = /etc/ansible/ansible.cfg
 configured module search path = ['/home/emanuel/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
 ansible python module location = /usr/lib/python3/dist-packages/ansible
 ansible collection location = 
/home/emanuel/.ansible/collections:/usr/share/ansible/collections
 executable location = /usr/bin/ansible-playbook
 python version = 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
 jinja version = 2.10.1
 libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
verify_file() method
script declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
verify_file() method
auto declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
verify_file() method
Not replacing invalid character(s) "{'-'}" in group name (kiucargo-servers)
[WARNING]: Invalid characters were found in group names but not replaced, use 
- to see details
Parsed /etc/ansible/webcheckin/hosts inventory source with yaml plugin
Loading collection community.mysql from 
/usr/lib/python3/dist-packages/ansible_collections/community/mysql
Loading collection community.general from 
/usr/lib/python3/dist-packages/ansible_collections/community/general
Loading callback plugin default of type stdout, v2.0 from 
/usr/lib/python3/dist-packages/ansible/plugins/callback/default.py
Attempting to use 'default' callback.
Skipping callback 'default', as we already have a stdout callback.
Attempting to use 'junit' callback.
Attempting to use 'minimal' callback.
Skipping callback 'minimal', as we already have a stdout callback.
Attempting to use 'oneline' callback.
Skipping callback 'oneline', as we already have a stdout callback.
Attempting to use 'tree' callback.

PLAYBOOK: tasks_target.yaml 

Positional arguments: alta_carrier/playbook/tasks_target.yaml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/webcheckin/hosts',)
extra_vars: ('wc2env=stage carrier=LL',)
forks: 50
step: True
4 plays in alta_carrier/playbook/tasks_target.yaml

PLAY [Seleccionamos el destino] 

META: ran handlers
META: ran handlers
META: ran handlers

PLAY [Creando DNS para nuevo carrier WC2 STAGE] 

META: ran handlers
Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: yes

Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: 
***

TASK [Creating DataBase] 
***
task path: /etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
skipping: [wc2-stage] => {
   

Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-08 Thread Todd Lewis
You still haven't shown us a task with the name "Creating DataBase", which 
is what's being skipped. Until you show us the tasks and their conditionals 
that go with the outputs, we can only guess.

On Wednesday, February 8, 2023 at 7:57:22 AM UTC-5 ema...@gmail.com wrote:

> This is the entire output:
>
> ansible-playbook [core 2.12.9] 
>  config file = /etc/ansible/ansible.cfg 
>  configured module search path = 
> ['/home/emanuel/.ansible/plugins/modules', 
> '/usr/share/ansible/plugins/modules'] 
>  ansible python module location = /usr/lib/python3/dist-packages/ansible 
>  ansible collection location = 
> /home/emanuel/.ansible/collections:/usr/share/ansible/collections 
>  executable location = /usr/bin/ansible-playbook 
>  python version = 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0] 
>  jinja version = 2.10.1 
>  libyaml = True 
> Using /etc/ansible/ansible.cfg as config file 
> setting up inventory plugins 
> host_list declined parsing /etc/ansible/webcheckin/hosts as it did not 
> pass its verify_file() method 
> script declined parsing /etc/ansible/webcheckin/hosts as it did not pass 
> its verify_file() method 
> auto declined parsing /etc/ansible/webcheckin/hosts as it did not pass its 
> verify_file() method 
> Not replacing invalid character(s) "{'-'}" in group name (kiucargo-servers) 
> [WARNING]: Invalid characters were found in group names but not replaced, 
> use - to see details 
> Parsed /etc/ansible/webcheckin/hosts inventory source with yaml plugin 
> Loading collection community.mysql from 
> /usr/lib/python3/dist-packages/ansible_collections/community/mysql 
> Loading collection community.general from 
> /usr/lib/python3/dist-packages/ansible_collections/community/general 
> Loading callback plugin default of type stdout, v2.0 from 
> /usr/lib/python3/dist-packages/ansible/plugins/callback/default.py 
> Attempting to use 'default' callback. 
> Skipping callback 'default', as we already have a stdout callback. 
> Attempting to use 'junit' callback. 
> Attempting to use 'minimal' callback. 
> Skipping callback 'minimal', as we already have a stdout callback. 
> Attempting to use 'oneline' callback. 
> Skipping callback 'oneline', as we already have a stdout callback. 
> Attempting to use 'tree' callback. 
>
> PLAYBOOK: tasks_target.yaml 
> 
>  
>
> Positional arguments: alta_carrier/playbook/tasks_target.yaml 
> verbosity: 5 
> connection: smart 
> timeout: 10 
> become_method: sudo 
> tags: ('all',) 
> inventory: ('/etc/ansible/webcheckin/hosts',) 
> extra_vars: ('wc2env=stage carrier=LL',) 
> forks: 50 
> step: True 
> 4 plays in alta_carrier/playbook/tasks_target.yaml 
>
> PLAY [Seleccionamos el destino] 
> 
>  
>
> META: ran handlers 
> META: ran handlers 
> META: ran handlers 
>
> PLAY [Creando DNS para nuevo carrier WC2 STAGE] 
> 
>  
>
> META: ran handlers 
> Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: yes 
>
> Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: 
> ***
>  
>
>
> TASK [Creating DataBase] 
> ***
>  
>
> task path: 
> /etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6 
> skipping: [wc2-stage] => { 
>"changed": false, 
>"skip_reason": "Conditional result was False" 
> }
>
> Does this skipping: [wc2-stage] mean the playbook is skipping the stage 
> server? 
>
> This is my hosts file:
>
> kiucargo-servers:
>   hosts:
> wc2-stage:
>   ansible_host: 172.x.x.x
> wc2-prod:
>   ansible_host: 172.x.x.x
>
> I understand that the import_playbook parameter function should not matter 
> the prod playbook, am I right?
>
> On Wed, Feb 8, 2023 at 9:19 AM 'Rowe, Walter P. (Fed)' via Ansible Project 
>  wrote:
>
>> We need to see the entire output. This excerpt does not provide enough 
>> context. From what I see it is skipping the PROD because your wc2end is 
>> 'stage'. That is expected.
>>
>> Walter
>> --
>> Walter Rowe, Division Chief
>> Infrastructure Services, OISM
>> Mobile: 202.355.4123 <(202)%20355-4123>
>>
>> On Feb 7, 2023, at 7:55 PM, SysAdmin EM  wrote:
>>
>> I’ve tried that way, but it doesn’t work either: 
>>
>> nsible-playbook -i hosts --extra-vars "wc2env=stage carrier=LL" 
>> alta_carrier/playbook/tasks_targe
>> t.yaml
>>
>> PLAYBOOK: tasks_target.yaml 
>> 
>>  
>>
>> Positional arguments: alta_carrier/playbook/tasks_target.yaml 
>> 

Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-08 Thread SysAdmin EM
This is the entire output:

ansible-playbook [core 2.12.9]
 config file = /etc/ansible/ansible.cfg
 configured module search path = ['/home/emanuel/.ansible/plugins/modules',
'/usr/share/ansible/plugins/modules']
 ansible python module location = /usr/lib/python3/dist-packages/ansible
 ansible collection location =
/home/emanuel/.ansible/collections:/usr/share/ansible/collections
 executable location = /usr/bin/ansible-playbook
 python version = 3.8.10 (default, Nov 14 2022, 12:59:47) [GCC 9.4.0]
 jinja version = 2.10.1
 libyaml = True
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
host_list declined parsing /etc/ansible/webcheckin/hosts as it did not pass
its verify_file() method
script declined parsing /etc/ansible/webcheckin/hosts as it did not pass
its verify_file() method
auto declined parsing /etc/ansible/webcheckin/hosts as it did not pass its
verify_file() method
Not replacing invalid character(s) "{'-'}" in group name (kiucargo-servers)
[WARNING]: Invalid characters were found in group names but not replaced,
use - to see details
Parsed /etc/ansible/webcheckin/hosts inventory source with yaml plugin
Loading collection community.mysql from
/usr/lib/python3/dist-packages/ansible_collections/community/mysql
Loading collection community.general from
/usr/lib/python3/dist-packages/ansible_collections/community/general
Loading callback plugin default of type stdout, v2.0 from
/usr/lib/python3/dist-packages/ansible/plugins/callback/default.py
Attempting to use 'default' callback.
Skipping callback 'default', as we already have a stdout callback.
Attempting to use 'junit' callback.
Attempting to use 'minimal' callback.
Skipping callback 'minimal', as we already have a stdout callback.
Attempting to use 'oneline' callback.
Skipping callback 'oneline', as we already have a stdout callback.
Attempting to use 'tree' callback.

PLAYBOOK: tasks_target.yaml


Positional arguments: alta_carrier/playbook/tasks_target.yaml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/webcheckin/hosts',)
extra_vars: ('wc2env=stage carrier=LL',)
forks: 50
step: True
4 plays in alta_carrier/playbook/tasks_target.yaml

PLAY [Seleccionamos el destino]


META: ran handlers
META: ran handlers
META: ran handlers

PLAY [Creando DNS para nuevo carrier WC2 STAGE]


META: ran handlers
Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue: yes

Perform task: TASK: Creating DataBase (N)o/(y)es/(c)ontinue:
***


TASK [Creating DataBase]
***

task path:
/etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
skipping: [wc2-stage] => {
   "changed": false,
   "skip_reason": "Conditional result was False"
}

Does this skipping: [wc2-stage] mean the playbook is skipping the stage
server?

This is my hosts file:

kiucargo-servers:
  hosts:
wc2-stage:
  ansible_host: 172.x.x.x
wc2-prod:
  ansible_host: 172.x.x.x

I understand that the import_playbook parameter function should not matter
the prod playbook, am I right?

On Wed, Feb 8, 2023 at 9:19 AM 'Rowe, Walter P. (Fed)' via Ansible Project <
ansible-project@googlegroups.com> wrote:

> We need to see the entire output. This excerpt does not provide enough
> context. From what I see it is skipping the PROD because your wc2end is
> 'stage'. That is expected.
>
> Walter
> --
> Walter Rowe, Division Chief
> Infrastructure Services, OISM
> Mobile: 202.355.4123
>
> On Feb 7, 2023, at 7:55 PM, SysAdmin EM  wrote:
>
> I’ve tried that way, but it doesn’t work either:
>
> nsible-playbook -i hosts --extra-vars "wc2env=stage carrier=LL"
> alta_carrier/playbook/tasks_targe
> t.yaml
>
> PLAYBOOK: tasks_target.yaml
> 
>
> Positional arguments: alta_carrier/playbook/tasks_target.yaml
> verbosity: 5
> connection: smart
> timeout: 10
> become_method: sudo
> tags: ('all',)
> inventory: ('/etc/ansible/webcheckin/hosts',)
> extra_vars: ('wc2env=stage carrier=XX',)
> forks: 50
> step: True
> 4 plays in alta_carrier/playbook/tasks_target.yaml
>
> TASK [Creating DataBase]
> ***
>
> task path:
> /etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
> skipping: [wc2-stage] => {
>"changed": false,
>"skip_reason": 

Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-08 Thread 'Rowe, Walter P. (Fed)' via Ansible Project
We need to see the entire output. This excerpt does not provide enough context. 
From what I see it is skipping the PROD because your wc2end is 'stage'. That is 
expected.

Walter
--
Walter Rowe, Division Chief
Infrastructure Services, OISM
Mobile: 202.355.4123

On Feb 7, 2023, at 7:55 PM, SysAdmin EM  wrote:

I’ve tried that way, but it doesn’t work either:

nsible-playbook -i hosts --extra-vars "wc2env=stage carrier=LL" 
alta_carrier/playbook/tasks_targe
t.yaml

PLAYBOOK: tasks_target.yaml 

Positional arguments: alta_carrier/playbook/tasks_target.yaml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/webcheckin/hosts',)
extra_vars: ('wc2env=stage carrier=XX',)
forks: 50
step: True
4 plays in alta_carrier/playbook/tasks_target.yaml

TASK [Creating DataBase] 
***
task path: /etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
skipping: [wc2-stage] => {
   "changed": false,
   "skip_reason": "Conditional result was False"
}


Here the playbook:

- name: "select target"
 hosts: all
 gather_facts: no
 tasks:
- name: "deploy prod"
 ansible.builtin.import_playbook: add_carrier_prod.yaml
 when: wc2env == 'prod'

- name: "deploy stage"
 ansible.builtin.import_playbook: add_carrier_stage.yaml
 when: wc2env == 'stage'

any sugestions?

--
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/CAGUDtnmFjQJEhgbj_iae392139qeKz4SnRTaBOa3ne5x5PaXWA%40mail.gmail.com.

-- 
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/08B7D983-0FC8-4C45-96C2-F423AE3626A3%40nist.gov.


Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-07 Thread SysAdmin EM
I’ve tried that way, but it doesn’t work either:

nsible-playbook -i hosts --extra-vars "wc2env=stage carrier=LL"
alta_carrier/playbook/tasks_targe
t.yaml

PLAYBOOK: tasks_target.yaml


Positional arguments: alta_carrier/playbook/tasks_target.yaml
verbosity: 5
connection: smart
timeout: 10
become_method: sudo
tags: ('all',)
inventory: ('/etc/ansible/webcheckin/hosts',)
extra_vars: ('wc2env=stage carrier=XX',)
forks: 50
step: True
4 plays in alta_carrier/playbook/tasks_target.yaml

TASK [Creating DataBase]
***

task path:
/etc/ansible/webcheckin/alta_carrier/playbook/add_carrier_prod.yaml:6
skipping: [wc2-stage] => {
   "changed": false,
   "skip_reason": "Conditional result was False"
}


Here the playbook:

- name: "select target"
 hosts: all
 gather_facts: no
 tasks:
- name: "deploy prod"
 ansible.builtin.import_playbook: add_carrier_prod.yaml
 when: wc2env == 'prod'

- name: "deploy stage"
 ansible.builtin.import_playbook: add_carrier_stage.yaml
 when: wc2env == 'stage'

any sugestions?

-- 
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/CAGUDtnmFjQJEhgbj_iae392139qeKz4SnRTaBOa3ne5x5PaXWA%40mail.gmail.com.


Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-07 Thread Brian Coca
Alex pointed out your first mistake, but you also are using moustaches in
'when' when you shouldn't

when: wc2env == 'prod'


conditionals are already in an implied template context.

-- 
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/CACVha7eftv4CXTYy9f09TdNTHNDmwsYHY%2BoDy70hWYTxA8dMcw%40mail.gmail.com.


Re: [ansible-project] Comparing command line variable in import_playbook

2023-02-07 Thread Alex Wanderley
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  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
> 
> .
>


-- 



[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.