diff --git a/08/copy_3files_debug.yml b/08/copy_3files_debug.yml new file mode 100644 index 0000000..fded4dc --- /dev/null +++ b/08/copy_3files_debug.yml @@ -0,0 +1,11 @@ +--- +- hosts: localhost + tasks: + - name: "[DEBUG] Copy 3 files" + ansible.builtin.debug: + msg: "src={{ item.0 }} dest={{ item.1 }}" + loop: + - [config1.cfg, /etc/config1.cfg] + - [config2.cfg, /etc/config2.cfg] + - [config3.cfg, /etc/daemon/config3.cfg] + diff --git a/08/copy_3files_debug_filter.yml b/08/copy_3files_debug_filter.yml new file mode 100644 index 0000000..21e453d --- /dev/null +++ b/08/copy_3files_debug_filter.yml @@ -0,0 +1,11 @@ +--- +- hosts: localhost + tasks: + - name: "[DEBUG] Copy 3 files" + ansible.builtin.debug: + msg: "src={{ item|basename }} dest={{ item }}" + loop: + - /etc/config1.cfg + - /etc/config2.cfg + - /etc/daemon/config3.cfg + diff --git a/08/loop_include.yml b/08/loop_include.yml new file mode 100644 index 0000000..d37e418 --- /dev/null +++ b/08/loop_include.yml @@ -0,0 +1,10 @@ +--- +- hosts: localhost + tasks: + - include_tasks: loop_include_sub.yml + loop: + - Aussen-1 + - Aussen-2 + loop_control: + loop_var: outer + diff --git a/08/loop_include_sub.yml b/08/loop_include_sub.yml new file mode 100644 index 0000000..3b9abc3 --- /dev/null +++ b/08/loop_include_sub.yml @@ -0,0 +1,9 @@ +--- +- debug: "msg='Innen: {{ item }}, Außen: {{ outer }} - {{ loop_index }}'" + loop: + - Innen-1 + - Innen-2 + loop_control: + label: "Aktueller Durchlauf {{ item }} - {{ loop_index }}" + index_var: loop_index + diff --git a/08/uebung_lookup.yml b/08/uebung_lookup.yml new file mode 100644 index 0000000..515cf06 --- /dev/null +++ b/08/uebung_lookup.yml @@ -0,0 +1,38 @@ +--- +- hosts: localhost + gather_facts: no + + tasks: + - name: File-Loopup /etc/timezone + debug: + msg: "/etc/timezone: {{ lookup('file', '/etc/timezone') }}" + + - name: Password-Lookup 1 + debug: + msg: "Passwort: {{ lookup('password', '/tmp/.secret.pw') }}" + + - name: Password-Lookup 2 + debug: + msg: "Passwort: {{ lookup('password', '/tmp/.secret.pw') }}" + + - name: rm /tmp/.secret.pw + file: + dest: /tmp/.secret.pw + state: absent + + - name: Password-Lookup 3 + debug: + msg: "Passwort: {{ lookup('password', '/tmp/.secret.pw') }}" + + - name: Password-Lookup 4 + debug: + msg: "Passwort: {{ lookup('password', '/tmp/.secret.pw') }}" + + - name: dig-Lookup + debug: + var: "lookup('dig', 'heinlein-akademie.de', 'qtype=MX')" + + - name: dig-Query + debug: + var: "query('dig', 'heinlein-akademie.de', 'qtype=MX')" +