1 | --- |
---|
2 | # This ansible-playbook reboots productive |
---|
3 | # servers |
---|
4 | # |
---|
5 | # What it does: |
---|
6 | # stop all services in need of manual stop |
---|
7 | # then reboot |
---|
8 | # then start all services in need of manual action. |
---|
9 | # |
---|
10 | # It will normally be run with ``ask-pass`` |
---|
11 | # |
---|
12 | # Sample: |
---|
13 | # |
---|
14 | # $ ansible-playbook -i host -K -l h5.waeup.org playbook-reboot.yml |
---|
15 | # |
---|
16 | |
---|
17 | # ########################################################## |
---|
18 | # PREPARE REBOOT |
---|
19 | # ########################################################## |
---|
20 | - hosts: h5.waeup.org |
---|
21 | become: yes |
---|
22 | become_user: root |
---|
23 | tasks: |
---|
24 | #- name: do something |
---|
25 | # file: state=touch path=/home/uli/123 |
---|
26 | # become_user: kofa |
---|
27 | - name: Stop odoo |
---|
28 | service: name=odoo-server state=stopped |
---|
29 | - name: Stop scientific african |
---|
30 | command: sudo -u henrik /home/henrik/zope/instances/sciafr/bin/zopectl stop |
---|
31 | - name: Stop uniben-staff |
---|
32 | command: sudo -u henrik /data/srp/instances/uniben-staff/bin/zopectl stop |
---|
33 | - name: Stop ngren plone |
---|
34 | command: sudo -u plone /data/plone/ngren/bin/instance stop |
---|
35 | - name: Stop waeup plone |
---|
36 | command: sudo -u plone /data/plone/waeup/bin/instance stop |
---|
37 | |
---|
38 | |
---|
39 | - hosts: h6.waeup.org |
---|
40 | become: yes |
---|
41 | become_user: root |
---|
42 | tasks: |
---|
43 | - name: Stop Ikoba PCN instance |
---|
44 | command: sudo -u ikoba /ikoba/pcn/bin/ikobactl stop |
---|
45 | args: |
---|
46 | chdir: /ikoba/pcn/ |
---|
47 | - name: Stop Kofa instances |
---|
48 | command: sudo -u kofa /kofa/scripts/kofactl_all.sh stop |
---|
49 | args: |
---|
50 | chdir: /kofa/scripts |
---|
51 | |
---|
52 | |
---|
53 | - hosts: h7.waeup.org |
---|
54 | become: yes |
---|
55 | become_user: root |
---|
56 | tasks: |
---|
57 | - name: Stop kofa instances |
---|
58 | command: sudo -u kofa /kofa/scripts/kofactl_all.sh stop |
---|
59 | args: |
---|
60 | chdir: /kofa/scripts |
---|
61 | |
---|
62 | |
---|
63 | # ########################################################## |
---|
64 | # REBOOT |
---|
65 | # ########################################################## |
---|
66 | - hosts: all |
---|
67 | become: yes |
---|
68 | become_user: root |
---|
69 | tasks: |
---|
70 | - name: Restart machine |
---|
71 | command: shutdown -r now "Ansible triggered reboot" |
---|
72 | async: 0 |
---|
73 | poll: 0 |
---|
74 | ignore_errors: true |
---|
75 | |
---|
76 | - name: Wait for server to come back |
---|
77 | become: no |
---|
78 | local_action: wait_for |
---|
79 | host={{ inventory_hostname }} |
---|
80 | state=started |
---|
81 | delay=30 |
---|
82 | timeout=300 |
---|
83 | connect_timeout=5 |
---|
84 | |
---|
85 | |
---|
86 | # ########################################################## |
---|
87 | # RESTART SERVICES |
---|
88 | # ########################################################## |
---|
89 | - hosts: h5.waeup.org |
---|
90 | become: true |
---|
91 | become_user: root |
---|
92 | tasks: |
---|
93 | - name: Start odoo |
---|
94 | service: name=odoo-server state=started |
---|
95 | - name: Start scientific african |
---|
96 | command: sudo -u henrik /home/henrik/zope/instances/sciafr/bin/zopectl start |
---|
97 | - name: Start uniben-staff |
---|
98 | command: sudo -u henrik /data/srp/instances/uniben-staff/bin/zopectl start |
---|
99 | - name: Start ngren plone |
---|
100 | command: sudo -u plone /data/plone/ngren/bin/instance start |
---|
101 | - name: Start waeup plone |
---|
102 | command: sudo -u plone /data/plone/waeup/bin/instance start |
---|
103 | |
---|
104 | - hosts: h6.waeup.org |
---|
105 | become: yes |
---|
106 | become_user: root |
---|
107 | tasks: |
---|
108 | - name: Start Ikoba PCN instance |
---|
109 | command: sudo -u ikoba /ikoba/pcn/bin/ikobactl start |
---|
110 | args: |
---|
111 | chdir: /ikoba/pcn/ |
---|
112 | - name: Start Kofa instances |
---|
113 | command: sudo -u kofa /kofa/scripts/kofactl_all.sh start |
---|
114 | args: |
---|
115 | chdir: /kofa/scripts |
---|
116 | |
---|
117 | |
---|
118 | - hosts: h7.waeup.org |
---|
119 | become: yes |
---|
120 | become_user: root |
---|
121 | tasks: |
---|
122 | - name: Start kofa instances |
---|
123 | command: sudo -u kofa /kofa/scripts/kofactl_all.sh start |
---|
124 | args: |
---|
125 | chdir: /kofa/scripts |
---|