On 12. nov. 2016 02:25, Felix Gao wrote:
- hosts: test
remote_user: ec2-user
sudo: yes
tasks:
#using the shell command because we need * expansion, otherwise if we
know the exact directory we can use command module instead
- name: list log directory to find main directory name
find:
paths: [ "/var/log/" ]
patterns: "file-main*"
file_type: directory
register: out_directories
When you use register with find the result is a list in files.
You can check the content of out_directories with
- debug: var=out_directories
- debug: var="{{ item }}"
Var takes the variable and not the content of the variable, correct use
is var=item.
with_items: "{{ out_directories }}"
Register with find, the result is list of dictionaries in
out_directories.files, so you'll need to write it like this
- debug: var=item.path
with_items: "{{ out_directories.files }}"
--
Kai Stian Olstad
--
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/3eb177e3-21ab-2044-fb67-2598aa4644c0%40olstad.com.
For more options, visit https://groups.google.com/d/optout.