maybe something like:

- set_fact:
     users: [ 'user1', 'user2', 'user3']

- name: Check paths
  stat:
     path: "/home/{{ item }}/Scripts"
  with_items: "{{ users}}"
  register: stat_results

On Thursday, December 21, 2017 at 10:43:54 AM UTC-6, John Harmon wrote:
>
> I need to check if certain paths exists.  More than one path may exist on 
> a server:
> /home/user1/Scripts
> /home/user2/Scripts
> /home/user3/Scripts
>
> If it exists, I want to define a variable.  For user1, variable user1 will 
> be defined, user2 for user2 and so on.
>
> I know I can easily check the paths in a loop, but how would I go about 
> setting a custom var for each in the same loop?
>
> - name: Check paths
>   stat:
>     path: {{ item.path }}
>   with_items:
>     - { path: '/home/user1/Scripts' } 
>     - { path: '/home/user2/Scripts' }
>     - { path: '/home/user3/Scripts' }
>
>
> As register isn't part of stat, I don't know how I would register 
> different vars.
>

-- 
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/b36de1dc-6db7-455b-a725-41a7d7157eef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to