checking of the file exists with stat is done like this:

---
- name: Check if path exists
  stat: path=/etc/monit/conf.d
  register: check_path

- name: It exists
  debug: msg='Yay, the path exists!'
  when: check_path.stat.exists


On Thursday, December 5, 2013 2:11:25 PM UTC-8, senorsmile wrote:
>
> Thanks all!  I had been trying to implement the "set_fact" module, but it 
> sets a different variable per host.  I need a global variable that is not 
> tied to a specific host.  So, it would end up running the last role 
> multiple times. 
>
> Sounds like the file and stat modules are what are going to do the trick.  
> It would be nice to have the option to set a global variable, sort of like 
> set_fact does, but NOT tied to any specific host, and all host plays could 
> access and modify it.  This would replace the need to write to disk during 
> a play.  
>
> Where can I get a list of all the possible parameters used with stat? 
>      e.g. the docs show when: p.stat.isdir is defined and p.stat.isdir == 
> true
> but I'm not sure how to run a task conditionally using stat to check for a 
> file existing.  
>
>
>
> On Thursday, December 5, 2013 1:45:29 PM UTC-8, Michael DeHaan wrote:
>>
>> You should probably touch a changed file on the system if something 
>> changes and use when with the stat module.
>>
>> -- Michael
>>
>> On Dec 5, 2013, at 1:35 PM, senorsmile <[email protected]> wrote:
>>
>> After trying to implement this workaround, I realize that this does NOT 
>> fix my issue.  I need to have a single task run at the very end, if any of 
>> other multiple roles have change. 
>>
>> Currently, I must duplicate the handler into the multiple roles, which 
>> means the handler gets run multiple times if multiple roles have changes.  
>> I need it to only run once at the very end.  
>>
>> Still searching for solution to OP...
>>
>> On Wednesday, December 4, 2013 2:44:40 PM UTC-8, senorsmile wrote:
>>>
>>> I have been thinking about this all wrong.  I just need to set up a 
>>> handler that includes the yml for the role I want, and put a notify on the 
>>> tasks of the other role.  
>>>
>>> If anyone has a better (more direct way from site.yml), feel free to 
>>> post. 
>>>
>>>
>>> On Wednesday, December 4, 2013 2:26:22 PM UTC-8, senorsmile wrote:
>>>>
>>>> I'm trying to come up with a seemingly simple logic, yet can't figure 
>>>> out how to do it in ansible: 
>>>>
>>>> I want to run the last role only if any previous roles have changes.  
>>>>
>>>  -- 
>> 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].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>

-- 
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].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to