It is not the problem of existence. The var exists all the time. It is about 
the wrong state

Von meinem iPad gesendet

> Am 05.01.2022 um 18:18 schrieb Wei-Yen Tan <[email protected]>:
> 
> 
> You could use the assert task to check that the variable exist before 
> starting the run 
> 
> Get Outlook for iOS
> From: 'Neil Young' via Ansible Project <[email protected]>
> Sent: Thursday, January 6, 2022 6:16:28 AM
> To: Ansible Project <[email protected]>
> Subject: [ansible-project] Variable state depending on existence of a file on 
> host system - possible?
>  
> I'm currently having a var in my ./vars/default.yml, which is used at several 
> points in my playbook for branching installation operations.
> 
> boolean_var: true
> 
> Depending on this I'm performing (or not) install steps
> 
> ....
> when: not boolean_var
> 
> So far so good. I'm also using this var in some j2 templates like so:
> 
> 
> {% if boolean_var %}
> 
> ...
> 
> 
> 
> {% endif %}
> 
> 
> 
> 
> 
> 
> My problem is, that I mostly forget to set this variable to a proper state, 
> which reflects the real status on the host system, so I have to abort an 
> update.
> 
> I would rather like to derive it from a pre_task, checking the existence of a 
> particular file on the host before starting all operations.
> 
> 
> 
> 
> Is there a way to define a variable with the same scope (playbook and 
> templates) at runtime?
> 
> 
> 
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/5da6e38e-ae18-4b28-98f9-4341465c2cbfn%40googlegroups.com.
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Ansible Project" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/ansible-project/MWKwiX9ICR8/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/SYBP282MB35259E19C8AA647EF3B46381AD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/01C05F93-94B6-4412-A639-6B22D5AD6415%40googlemail.com.

Reply via email to