diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..76e579a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +test + diff --git a/loop.yml b/loop.yml new file mode 100644 index 0000000..2df388c --- /dev/null +++ b/loop.yml @@ -0,0 +1,8 @@ +- hosts: "{{ target }}" + vars_files: + - loop_files.yml + gather_facts: false + remote_user: pi + roles: + - loop + diff --git a/loop_files.yml b/loop_files.yml new file mode 100644 index 0000000..47206fe --- /dev/null +++ b/loop_files.yml @@ -0,0 +1,7 @@ +testfiles: + - test1.txt + - test1.json + - test2.txt + - test3.txt + - test4.dat + diff --git a/noloop.yml b/noloop.yml new file mode 100644 index 0000000..b8433ee --- /dev/null +++ b/noloop.yml @@ -0,0 +1,8 @@ +- hosts: "{{ target }}" + vars_files: + - loop_files.yml + gather_facts: false + remote_user: pi + roles: + - noloop + diff --git a/roles/loop/tasks/main.yml b/roles/loop/tasks/main.yml new file mode 100644 index 0000000..4079fce --- /dev/null +++ b/roles/loop/tasks/main.yml @@ -0,0 +1,7 @@ +- include: ../subtasks/setuploop.yml + +- name: erzeuge Testdateien + ansible.builtin.file: + path: "test/{{ item }}" + state: touch + loop: "{{ testfiles }}" diff --git a/roles/noloop/tasks/main.yml b/roles/noloop/tasks/main.yml new file mode 100644 index 0000000..891a0df --- /dev/null +++ b/roles/noloop/tasks/main.yml @@ -0,0 +1,21 @@ +- include: ../subtasks/setuploop.yml +- name: erzeuge test1.txt + ansible.builtin.file: + path: "test/test1.txt" + state: touch +- name: erzeuge test1.json + ansible.builtin.file: + path: "test/test1.json" + state: touch +- name: erzeuge test2.txt + ansible.builtin.file: + path: "test/test2.txt" + state: touch +- name: erzeuge test3.txt + ansible.builtin.file: + path: "test/test3.txt" + state: touch +- name: erzeuge testr4.dat + ansible.builtin.file: + path: "test/test4.dat" + state: touch diff --git a/roles/subtasks/setuploop.yml b/roles/subtasks/setuploop.yml new file mode 100644 index 0000000..d54b551 --- /dev/null +++ b/roles/subtasks/setuploop.yml @@ -0,0 +1,10 @@ +--- +- name: create test dir + ansible.builtin.file: + path: test + state: directory +- name: delete test files + ansible.builtin.file: + path: "test/*" + state: absent + diff --git a/roles/with_items/tasks/main.yml b/roles/with_items/tasks/main.yml new file mode 100644 index 0000000..1ad637e --- /dev/null +++ b/roles/with_items/tasks/main.yml @@ -0,0 +1,13 @@ +- include: ../subtasks/setuploop.yml + +- name: erzeuge Testdateien + ansible.builtin.file: + path: "test/{{ item }}" + state: touch + with_items: + - test1.txt + - test1.json + - test2.txt + - test3.txt + - test4.dat + diff --git a/with_items.yml b/with_items.yml new file mode 100644 index 0000000..f3c2cb8 --- /dev/null +++ b/with_items.yml @@ -0,0 +1,8 @@ +- hosts: "{{ target }}" + vars_files: + - loop_files.yml + gather_facts: false + remote_user: pi + roles: + - with_items +