Skip to content

Commit ca82ff0

Browse files
author
Dario Tranchitella
committed
Logic separation of tasks for node bootstrap
1 parent c5e9b52 commit ca82ff0

File tree

4 files changed

+70
-29
lines changed

4 files changed

+70
-29
lines changed

roles/nodes-bootstrap/tasks/main.yml

Lines changed: 6 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,9 @@
11
---
2-
- name: Disabling SELinux
3-
selinux:
4-
policy: targeted
5-
state: permissive
6-
register: selinux
2+
- name: SELinux
3+
import_tasks: selinux.yml
74

8-
- name: Reboot the system to enable new SELinux policy
9-
shell: sleep 2 && shutdown -r now 'Reboot after SELinux policy' removes=/var/run/reboot-required
10-
async: 1
11-
poll: 0
12-
when: selinux.changed
13-
ignore_errors: true
14-
15-
- name: Wait for the server to come back online (part 1)
16-
set_fact:
17-
wait_for_host: "{{ ansible_host }}"
18-
when: selinux.changed
19-
- name: Wait for the server to come back online (part 2)
20-
local_action:
21-
module: wait_for
22-
host="{{ wait_for_host }}"
23-
state=started
24-
delay=10
25-
timeout=600
26-
port=22
27-
become: no
28-
when: selinux.changed
5+
- name: Time sync
6+
import_tasks: time-sync.yml
297

30-
- name: Updating clock without NTPD
31-
shell: |
32-
date -u --set="$(curl -H 'Cache-Control: no-cache' -sD - http://google.com |grep '^Date:' |cut -d' ' -f3-6)"
8+
- name: Swap space
9+
import_tasks: swap.yml
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
- name: Disabling SELinux
3+
selinux:
4+
policy: targeted
5+
state: permissive
6+
register: selinux
7+
8+
- name: Reboot the system to enable new SELinux policy
9+
shell: sleep 2 && shutdown -r now 'Reboot after SELinux policy' removes=/var/run/reboot-required
10+
async: 1
11+
poll: 0
12+
when: selinux.changed
13+
ignore_errors: true
14+
15+
- name: Wait for the server to come back online (part 1)
16+
set_fact:
17+
wait_for_host: "{{ ansible_host }}"
18+
on_port: "{{ ansible_port|default(22) }}"
19+
when: selinux.changed
20+
21+
- name: Wait for the server to come back online (part 2)
22+
local_action:
23+
module: wait_for
24+
host="{{ wait_for_host }}"
25+
state=started
26+
delay=10
27+
timeout=600
28+
port={{ on_port }}
29+
become: no
30+
when: selinux.changed

roles/nodes-bootstrap/tasks/swap.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
- name: Remove swapfile from /etc/fstab
3+
mount:
4+
name: swap
5+
fstype: swap
6+
state: absent
7+
8+
- name: Disable swap
9+
shell: |
10+
swapoff -a
11+
when: ansible_swaptotal_mb > 0
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
- name: Installing NTPD
3+
package:
4+
name: ntp
5+
state: present
6+
7+
- name: Enabling NTPD
8+
systemd:
9+
daemon_reload: yes
10+
service: ntpd
11+
enabled: yes
12+
state: started
13+
14+
- name: Updating clock with NTP
15+
shell: |
16+
ntpdate -u pool.ntp.org
17+
ignore_errors: yes
18+
register: ntpd
19+
20+
- name: Updating clock without NTPD (fallback)
21+
shell: |
22+
date -u --set="$(curl -H 'Cache-Control: no-cache' -sD - http://google.com |grep '^Date:' |cut -d' ' -f3-6)"
23+
when: ntpd.rc != 0

0 commit comments

Comments
 (0)