I have a list of users defined as variable on my inventory. I want to create a task that checks if for each user exists a file in a folder if it exists will run a task if not will run an other task. I have a task that add the user with password if password exists and no ssh key is found and another that adds the user with both password and key.
This one checks if there is an ssh key defined for the client: - name: Add sftp users block: - name: Check if diapason folder exists stat: path: "SYMPHONY_HOME + '/config/ssh_keys/clients/keys/{{ item.ssh_key }}.pub" register: sshkey_status with_items: "{{ sftp_users }}" And then I want to use the info in a conditional - name: Add sftp users with ssh key user: name: "{{ item.remote_user }}" state: "{{ item.state | default('present') }}" shell: /usr/bin/false skeleton: yes group: "{{ item.remote_user }}" groups: - sftpgroup with_items: "{{ sftp_users }}" when: (item.state != "absent") and (sshkey_status.stat.exists == true) The problem is that sshkey_status is a variable with a list for each user from the user list and I cannot use it like that. I have te required info there but not sure how to get to it in the when statement. Can somebody point me towards a working direction. -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/0f5deb45-7895-49f7-acf6-02af9a88ba8f%40googlegroups.com.