Looks pretty verbose. I have some doubts to be able to use this in a .j2 file.
> Am 05.01.2022 um 19:08 schrieb Wei-Yen Tan <[email protected]>: > > It is the example. Register > > Get Outlook for iOS <https://aka.ms/o0ukef> > From: [email protected] <[email protected]> on > behalf of decades software <[email protected]> > Sent: Thursday, January 6, 2022 7:06:59 AM > To: [email protected] <[email protected]> > Subject: Re: [ansible-project] Variable state depending on existence of a > file on host system - possible? > > Well, yes. I know, how to stat a file. I don't know how to create a variable > from that with the same scope as a variable defined in default.yml. > > I thought I was precise enough. Never mind. Disregard my question. Will find > it out. > > >> Am 05.01.2022 um 18:34 schrieb Wei-Yen Tan <[email protected] >> <mailto:[email protected]>>: >> >> Use stat module to get your required facts. Bring it into assert or fail >> >> https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html >> >> <https://docs.ansible.com/ansible/latest/collections/ansible/builtin/stat_module.html> >> >> Get Outlook for iOS <https://aka.ms/o0ukef> >> From: 'Neil Young' via Ansible Project <[email protected] >> <mailto:[email protected]>> >> Sent: Thursday, January 6, 2022 6:26:54 AM >> To: [email protected] >> <mailto:[email protected]> <[email protected] >> <mailto:[email protected]>> >> Subject: Re: [ansible-project] Variable state depending on existence of a >> file on host system - possible? >> >> 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] >>> <mailto:[email protected]>>: >>> >>> >>> You could use the assert task to check that the variable exist before >>> starting the run >>> >>> Get Outlook for iOS <https://aka.ms/o0ukef> >>> From: 'Neil Young' via Ansible Project <[email protected] >>> <mailto:[email protected]>> >>> Sent: Thursday, January 6, 2022 6:16:28 AM >>> To: Ansible Project <[email protected] >>> <mailto:[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] >>> <mailto:[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 >>> >>> <https://groups.google.com/d/msgid/ansible-project/5da6e38e-ae18-4b28-98f9-4341465c2cbfn%40googlegroups.com?utm_medium=email&utm_source=footer>. >>> >>> -- >>> 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 >>> <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] >>> <mailto:[email protected]>. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/ansible-project/SYBP282MB35259E19C8AA647EF3B46381AD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM >>> >>> <https://groups.google.com/d/msgid/ansible-project/SYBP282MB35259E19C8AA647EF3B46381AD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>. >> >> -- >> 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] >> <mailto:[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 >> >> <https://groups.google.com/d/msgid/ansible-project/01C05F93-94B6-4412-A639-6B22D5AD6415%40googlemail.com?utm_medium=email&utm_source=footer>. >> >> -- >> 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 >> <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] >> <mailto:[email protected]>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/SYBP282MB3525B92047533293BE36CDDBAD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM >> >> <https://groups.google.com/d/msgid/ansible-project/SYBP282MB3525B92047533293BE36CDDBAD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>. > > > -- > 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] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/6151BEBF-2100-47D4-BEBB-8B7DAFA015E0%40freenet.de > > <https://groups.google.com/d/msgid/ansible-project/6151BEBF-2100-47D4-BEBB-8B7DAFA015E0%40freenet.de?utm_medium=email&utm_source=footer>. > > -- > 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 > <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] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/SYBP282MB35253A0A94C37D3B58787DE8AD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM > > <https://groups.google.com/d/msgid/ansible-project/SYBP282MB35253A0A94C37D3B58787DE8AD4B9%40SYBP282MB3525.AUSP282.PROD.OUTLOOK.COM?utm_medium=email&utm_source=footer>. -- 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/0BC29B56-FBB8-4806-9A93-0A26B283FDBC%40freenet.de.
