Kapitel 10: Handler
This commit is contained in:
parent
5d13ae5cc3
commit
0a1a5d3440
21
10/alt/handler_test_1.yml
Normal file
21
10/alt/handler_test_1.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-debian10
|
||||
- tn00-debian11
|
||||
- tn00-ubu2004a
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- command: /bin/true
|
||||
when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler
|
||||
|
||||
- fail:
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
|
||||
|
27
10/alt/handler_test_2.yml
Normal file
27
10/alt/handler_test_2.yml
Normal file
|
@ -0,0 +1,27 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-debian10
|
||||
- tn00-debian11
|
||||
- tn00-ubu2004a
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- command: /bin/true
|
||||
when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler-via-listen
|
||||
|
||||
- fail:
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
listen: Echo-Handler-via-listen
|
||||
|
||||
- name: Echo-Handler 2
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
listen: Echo-Handler-via-listen
|
||||
|
||||
|
29
10/alt/handler_test_3.yml
Normal file
29
10/alt/handler_test_3.yml
Normal file
|
@ -0,0 +1,29 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-debian10
|
||||
- tn00-debian11
|
||||
- tn00-ubu2004a
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- command: /bin/true
|
||||
when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler-via-listen
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
- fail:
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
listen: Echo-Handler-via-listen
|
||||
|
||||
- name: Echo-Handler 2
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
listen: Echo-Handler-via-listen
|
||||
|
||||
|
32
10/alt/handler_test_4.yml
Normal file
32
10/alt/handler_test_4.yml
Normal file
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-debian10
|
||||
- tn00-debian11
|
||||
- tn00-ubu2004a
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- command: /bin/true
|
||||
when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler-via-listen
|
||||
|
||||
- meta: flush_handlers
|
||||
|
||||
- fail:
|
||||
when: ansible_distribution == "Ubuntu"
|
||||
|
||||
- command: /bin/true
|
||||
notify: Echo-Handler
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
listen: Echo-Handler-via-listen
|
||||
|
||||
- name: Echo-Handler 2
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
listen: Echo-Handler-via-listen
|
||||
|
||||
|
1
10/chrony.conf.j2
Symbolic link
1
10/chrony.conf.j2
Symbolic link
|
@ -0,0 +1 @@
|
|||
../05/chrony.conf.j2
|
24
10/chrony_mit_handler.yml
Normal file
24
10/chrony_mit_handler.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Install Chrony
|
||||
package: name=chrony state=latest
|
||||
notify: Restart Chrony
|
||||
|
||||
- name: Show pools
|
||||
debug: var=chrony_pools
|
||||
|
||||
- name: Template config file
|
||||
template: "src=chrony.conf.j2 dest='{{ chrony_config_path }}' mode=0644 owner=root group=root backup=yes"
|
||||
notify: Restart Chrony
|
||||
|
||||
- name: Enable Chrony at boot
|
||||
service: "name={{ chrony_service_name }} enabled=yes"
|
||||
|
||||
handlers:
|
||||
|
||||
- name: Restart Chrony
|
||||
service: "name='{{ chrony_service_name }}' state=restarted"
|
||||
|
22
10/handler_1_durchlauf.yml
Normal file
22
10/handler_1_durchlauf.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
|
31
10/handler_2_fail_ubuntu.yml
Normal file
31
10/handler_2_fail_ubuntu.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler
|
||||
|
||||
- name: Ubuntu geht kaputt
|
||||
debug:
|
||||
msg: "{{ 'Ubuntu kaputt' if ansible_distribution == 'Ubuntu' else 'Nix kaputt' }}"
|
||||
failed_when: ansible_distribution == "Ubuntu"
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
|
||||
|
||||
|
||||
|
31
10/handler_3_flush_handlers.yml
Normal file
31
10/handler_3_flush_handlers.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Ubuntu geht kaputt
|
||||
debug:
|
||||
msg: "{{ 'Ubuntu kaputt' if ansible_distribution == 'Ubuntu' else 'Nix kaputt' }}"
|
||||
failed_when: ansible_distribution == "Ubuntu"
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
|
37
10/handler_4_flush_handlers_weitere.yml
Normal file
37
10/handler_4_flush_handlers_weitere.yml
Normal file
|
@ -0,0 +1,37 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify: Echo-Handler
|
||||
|
||||
- name: Flush handlers
|
||||
meta: flush_handlers
|
||||
|
||||
- name: Ubuntu geht kaputt
|
||||
debug:
|
||||
msg: "{{ 'Ubuntu kaputt' if ansible_distribution == 'Ubuntu' else 'Nix kaputt' }}"
|
||||
failed_when: ansible_distribution == "Ubuntu"
|
||||
|
||||
- name: Handler notify 2
|
||||
debug:
|
||||
msg: "Handler wird benachrichtigt"
|
||||
changed_when: True
|
||||
notify: Echo-Handler
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der Handler wurde aufgerufen!"
|
||||
|
28
10/handler_5_notify_list.yml
Normal file
28
10/handler_5_notify_list.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify:
|
||||
- Echo-Handler
|
||||
- Echo-Handler Zwei
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der erste Handler wurde aufgerufen!"
|
||||
|
||||
- name: Echo-Handler Zwei
|
||||
debug:
|
||||
msg: "Der zweite Handler wurde aufgerufen!"
|
||||
|
28
10/handler_6_listen.yml
Normal file
28
10/handler_6_listen.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify: Mehrere Handler
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der erste Handler wurde aufgerufen!"
|
||||
listen: Mehrere Handler
|
||||
|
||||
- name: Echo-Handler Zwei
|
||||
debug:
|
||||
msg: "Der zweite Handler wurde aufgerufen!"
|
||||
listen: Mehrere Handler
|
||||
|
35
10/handler_7_notify_list_listen.yml
Normal file
35
10/handler_7_notify_list_listen.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- hosts:
|
||||
- tn00-ubu2204
|
||||
- tn00-debian12
|
||||
- tn00-alpine3i
|
||||
|
||||
tasks:
|
||||
- name: Handler notify
|
||||
debug:
|
||||
msg: "Handler wird ggf. benachrichtigt"
|
||||
changed_when: ansible_os_family == "Debian"
|
||||
notify:
|
||||
- Mehrere Handler
|
||||
- Zwei Handler
|
||||
- Echo-Handler
|
||||
|
||||
- name: Lebenszeichen
|
||||
debug:
|
||||
msg: "Ich lebe noch"
|
||||
|
||||
handlers:
|
||||
- name: Echo-Handler
|
||||
debug:
|
||||
msg: "Der erste Handler wurde aufgerufen!"
|
||||
listen:
|
||||
- Mehrere Handler
|
||||
- Zwei Handler
|
||||
|
||||
- name: Echo-Handler Zwei
|
||||
debug:
|
||||
msg: "Der zweite Handler wurde aufgerufen!"
|
||||
listen:
|
||||
- Mehrere Handler
|
||||
- Zwei Handler
|
||||
|
1
10/old.ntp/ntp.conf.j2
Symbolic link
1
10/old.ntp/ntp.conf.j2
Symbolic link
|
@ -0,0 +1 @@
|
|||
../../05/old.ntp/ntp.conf.j2
|
31
10/old.ntp/ntp_mit_handler.yml
Normal file
31
10/old.ntp/ntp_mit_handler.yml
Normal file
|
@ -0,0 +1,31 @@
|
|||
---
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
|
||||
- name: Install NTP
|
||||
package:
|
||||
name: ntp
|
||||
state: latest
|
||||
|
||||
- name: Debug
|
||||
debug: var=ntp_servers
|
||||
|
||||
- name: Copy ntp.conf
|
||||
template:
|
||||
src: ntp.conf.j2
|
||||
dest: /etc/ntp.conf
|
||||
backup: yes
|
||||
notify: Restart NTP
|
||||
|
||||
- name: Enable NTP
|
||||
service:
|
||||
name: "{{ ntp_service_name }}"
|
||||
enabled: yes
|
||||
state: started
|
||||
|
||||
|
||||
handlers:
|
||||
- name: Restart NTP
|
||||
service: "name={{ ntp_service_name }} state=\"restarted\""
|
||||
|
Loading…
Reference in a new issue