Ansible scripts.
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Mon, 30 Jan 2017 22:13:52 +0000 (23:13 +0100)
committerGustavo Martin Morcuende <gustavo.martin@scmspain.com>
Sun, 5 Feb 2017 20:15:32 +0000 (21:15 +0100)
ansible/loopfiles.yml [new file with mode: 0644]

diff --git a/ansible/loopfiles.yml b/ansible/loopfiles.yml
new file mode 100644 (file)
index 0000000..1bf923a
--- /dev/null
@@ -0,0 +1,15 @@
+# Returns files in $HOME and fills result in fileoutput
+#
+# ansible-playbook loopfiles.yml -e 'filename=fileoutput'
+#
+---
+- hosts: localhost
+  connection: local
+  tasks:
+  - name: List files in directory
+    find:
+      paths: "{{ ansible_env.HOME }}"
+    register: result
+  - name: Fill file
+    shell: echo "{{ item.path }}" >> "{{ filename }}"
+    with_items: "{{ result.files }}"