I think it has to do with variable precedence.

Use a diferent variable name. set value as default value.
Overwrite it with specific value for each host and use that one to decide 
if the task is going to be done or skipped.

El martes, 24 de noviembre de 2020 a la(s) 14:56:40 UTC-6, 
[email protected] escribió:

> Update - here's what I've tried so far.  It runs successfully, but the 
> facts don't persist after the playbook is done.  I want them to persist so 
> that we can re-run the patch job as needed until all of them are successful 
> without manually going and selecting hosts.
>
> - hosts: "{{ env|default('all') }}"
>   gather_facts: no
>   become: no
>   tasks:
>     - set_fact:
>         needs_patch: False
>         needs_reboot: False
>         cacheable: yes
>
> On Tuesday, November 24, 2020 at 2:09:51 PM UTC-6 Chad Campbell wrote:
>
>> I'm trying to automate our monthly patch process for CentOS servers.  We 
>> receive a list of servers from our Linux team each month that says which 
>> servers need to be patched and/or rebooted.  I'm wanting to have 
>> needs_patch and needs_reboot variables attached to each host.  So, each 
>> month we would have a playbook reset all of those to false, and then using 
>> the list from the Linux team, another playbook would set the necessary ones 
>> to true.  Then the actual patch/reboot playbook would do the work based on 
>> the true variables and set the variables back to false upon success.  I'm 
>> having trouble determining if this is possible, and if so, what the correct 
>> way is of doing this in the YAML.  If anyone has suggestions or perhaps a 
>> better way of achieving the same result, that would be greatly appreciated.
>>
>> Thanks!
>>
>> Chad
>>
>

-- 
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/67cdfe74-a814-43e5-8741-6735e5446a2dn%40googlegroups.com.

Reply via email to