On Wednesday, 14 February 2018 15.57.02 CET [email protected] wrote:
> Hi Kai
> 
> You used the variable in a playbook, maybe that works. But I want to make 
> sure that the role is not being executed when someone forgets to set the 
> variable.
> So the trick here is: "{{ APPLICATIONNAME }}" is not set.
> Normaly this is a variable in vars/app1.yml
> Here is the full code:

The full code make is clear whats happening.


> /vars/app1.yml
> ---
> #APPLICATIONNAME: "app1"
> #normally this var is set, but we want to provoke an error
> 
> 
> 
> playbook.yml
> ---
>  - name: play1
>    hosts: app1
>    vars_files:
>    - "vars/app1.yml"
> 
>   tasks:
>   - include_role:
>       name: role1
>     vars:
>       applicationname: "{{ APPLICATIONNAME }}"
>       description: "{{ DESCRIPTION }}"
> 
> 
> /roles/defaults/main.yml
> ---
> required_vars:
>  - applicationname
> 
> applicationname: ""
> description: ""

role default will always set applicationname to "" and therefor always be 
defined.
So checking if that variable "is not defined" has no purpose since it will be 
defined.


-- 
Kai Stian Olstad

-- 
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/1556662.FaPZ0SOvf3%40x1.
For more options, visit https://groups.google.com/d/optout.

Reply via email to