diff --git a/10/block.yml b/10/block.yml new file mode 100644 index 0000000..664c7cb --- /dev/null +++ b/10/block.yml @@ -0,0 +1,17 @@ +--- +- hosts: localhost + tasks: + - block: + - debug: msg='OK' + - shell: /bin/false + - debug: msg='Niemals' + rescue: + - debug: msg='Im Fehlerfall' + - shell: /bin/false + - debug: msg='Niemals' + always: + - debug: msg='echo Immer' + when: ansible_os_family == 'Debian' + + - debug: 'msg="Nach dem Block"' + diff --git a/10/block_01_kein_Problem.yml b/10/block_01_kein_Problem.yml new file mode 100644 index 0000000..fbb4017 --- /dev/null +++ b/10/block_01_kein_Problem.yml @@ -0,0 +1,17 @@ +--- +- hosts: localhost + tasks: + - block: + - debug: msg='Block 1' + - command: /bin/true + - debug: msg='Block 2' + rescue: + - debug: msg='Rescue 1' + - command: /bin/true + - debug: msg='Rescue 2' + always: + - debug: msg='Always' + when: ansible_os_family == 'Debian' + + - debug: 'msg="Nach dem Block"' + diff --git a/10/block_02_Fehler_Block.yml b/10/block_02_Fehler_Block.yml new file mode 100644 index 0000000..bd57633 --- /dev/null +++ b/10/block_02_Fehler_Block.yml @@ -0,0 +1,17 @@ +--- +- hosts: localhost + tasks: + - block: + - debug: msg='Block 1' + - command: /bin/false + - debug: msg='Block 2' + rescue: + - debug: msg='Rescue 1' + - command: /bin/true + - debug: msg='Rescue 2' + always: + - debug: msg='Always' + when: ansible_os_family == 'Debian' + + - debug: 'msg="Nach dem Block"' + diff --git a/10/block_03_Fehler_Block_und_Rescue.yml b/10/block_03_Fehler_Block_und_Rescue.yml new file mode 100644 index 0000000..a2b9153 --- /dev/null +++ b/10/block_03_Fehler_Block_und_Rescue.yml @@ -0,0 +1,17 @@ +--- +- hosts: localhost + tasks: + - block: + - debug: msg='Block 1' + - command: /bin/false + - debug: msg='Block 2' + rescue: + - debug: msg='Rescue 1' + - command: /bin/false + - debug: msg='Rescue 2' + always: + - debug: msg='Always' + when: ansible_os_family == 'Debian' + + - debug: 'msg="Nach dem Block"' + diff --git a/10/block_04_Fehler_nur_Rescue.yml b/10/block_04_Fehler_nur_Rescue.yml new file mode 100644 index 0000000..97c9911 --- /dev/null +++ b/10/block_04_Fehler_nur_Rescue.yml @@ -0,0 +1,17 @@ +--- +- hosts: localhost + tasks: + - block: + - debug: msg='Block 1' + - command: /bin/true + - debug: msg='Block 2' + rescue: + - debug: msg='Rescue 1' + - command: /bin/false + - debug: msg='Rescue 2' + always: + - debug: msg='Always' + when: ansible_os_family == 'Debian' + + - debug: 'msg="Nach dem Block"' + diff --git a/10/block_09_Fehler_Block_und_Always.yml b/10/block_09_Fehler_Block_und_Always.yml new file mode 100644 index 0000000..95b4402 --- /dev/null +++ b/10/block_09_Fehler_Block_und_Always.yml @@ -0,0 +1,19 @@ +--- +- hosts: localhost + tasks: + - block: + - debug: msg='Block 1' + - command: /bin/false + - debug: msg='Block 2' + rescue: + - debug: msg='Rescue 1' + - command: /bin/true + - debug: msg='Rescue 2' + always: + - debug: msg='Always 1' + - command: /bin/false + - debug: msg='Always 2' + when: ansible_os_family == 'Debian' + + - debug: 'msg="Nach dem Block"' + diff --git a/10/playbook_pre_post_tasks_roles_handlers.yml b/10/playbook_pre_post_tasks_roles_handlers.yml new file mode 100644 index 0000000..15015d3 --- /dev/null +++ b/10/playbook_pre_post_tasks_roles_handlers.yml @@ -0,0 +1,32 @@ +--- +- hosts: localhost + gather_facts: False + + pre_tasks: + - debug: + msg: "Schritt 1" + notify: Handler Schritt 1 + + roles: + - { role: schritt2 } + + tasks: + - debug: + msg: "Schritt 3" + notify: Handler Schritt 3 + + post_tasks: + - debug: + msg: "Schritt 4" + notify: Handler Schritt 4 + + handlers: + - name: Handler Schritt 1 + debug: msg="Handler Schritt 1" + + - name: Handler Schritt 3 + debug: msg="Handler Schritt 3" + + - name: Handler Schritt 4 + debug: msg="Handler Schritt 4" + diff --git a/10/playbook_pre_post_tasks_roles_handlers_really.yml b/10/playbook_pre_post_tasks_roles_handlers_really.yml new file mode 100644 index 0000000..a7525f1 --- /dev/null +++ b/10/playbook_pre_post_tasks_roles_handlers_really.yml @@ -0,0 +1,35 @@ +--- +- hosts: localhost + gather_facts: False + + pre_tasks: + - debug: + msg: "Schritt 1" + changed_when: True + notify: Handler Schritt 1 + + roles: + - { role: schritt2really } + + tasks: + - debug: + msg: "Schritt 3" + changed_when: True + notify: Handler Schritt 3 + + post_tasks: + - debug: + msg: "Schritt 4" + changed_when: True + notify: Handler Schritt 4 + + handlers: + - name: Handler Schritt 1 + debug: msg="Handler Schritt 1" + + - name: Handler Schritt 3 + debug: msg="Handler Schritt 3" + + - name: Handler Schritt 4 + debug: msg="Handler Schritt 4" + diff --git a/roles/schritt2/handlers/main.yml b/roles/schritt2/handlers/main.yml new file mode 100644 index 0000000..4a31abe --- /dev/null +++ b/roles/schritt2/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: Handler Schritt 2 + debug: msg="Handler Schritt 2" + diff --git a/roles/schritt2/tasks/main.yml b/roles/schritt2/tasks/main.yml new file mode 100644 index 0000000..12025ba --- /dev/null +++ b/roles/schritt2/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- debug: msg="Schritt 2" + notify: Handler Schritt 2 diff --git a/roles/schritt2really/handlers/main.yml b/roles/schritt2really/handlers/main.yml new file mode 100644 index 0000000..4a31abe --- /dev/null +++ b/roles/schritt2really/handlers/main.yml @@ -0,0 +1,4 @@ +--- +- name: Handler Schritt 2 + debug: msg="Handler Schritt 2" + diff --git a/roles/schritt2really/tasks/main.yml b/roles/schritt2really/tasks/main.yml new file mode 100644 index 0000000..6c3577d --- /dev/null +++ b/roles/schritt2really/tasks/main.yml @@ -0,0 +1,4 @@ +--- +- debug: msg="Schritt 2" + changed_when: True + notify: Handler Schritt 2