-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathprep-fog-capture.yml
More file actions
152 lines (128 loc) · 4.83 KB
/
Copy pathprep-fog-capture.yml
File metadata and controls
152 lines (128 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
### This standalone playbook can be used to prep a COBBLER-IMAGED testnode
### so that it can be used to capture an OS image for FOG.
### This playbook is needed for a couple reasons
### - NIC configs get hard coded into the captured FOG images so nodes reimaged by FOG don't come up with network
- hosts:
- testnodes
become: true
gather_facts: false
tasks:
# (Missing in RHEL8)
- name: Check for /usr/bin/python
shell: echo marco
register: polo
ignore_errors: true
- name: Set ansible_python_interpreter=/usr/bin/python3
set_fact:
ansible_python_interpreter: /usr/bin/python3
when: polo is failed
# Now that we know where python is, we can gather_facts
- setup:
# We need to leave /.cephlab_rc_local or else each FOG reimage would tell Cobbler to run ceph-cm-ansible
- name: Remove lock files and udev rules
file:
path: "{{ item }}"
state: absent
with_items:
- /etc/udev/rules.d/70-persistent-net.rules
- /.cephlab_net_configured
- /ceph-qa-ready
- name: Get list of ifcfg scripts from host used to capture image
shell: "ls -1 /etc/sysconfig/network-scripts/ifcfg-* | grep -v ifcfg-lo"
register: ifcfg_scripts
when: ansible_os_family == "RedHat"
ignore_errors: true
- name: Get list of ifcfg scripts from host used to capture image
shell: "ls -1 /etc/sysconfig/network/ifcfg-* | grep -v ifcfg-lo"
register: ifcfg_scripts
when: ansible_os_family == "Suse"
ignore_errors: true
- name: Delete ifcfg scripts
file:
path: "{{ item }}"
state: absent
with_items: "{{ ifcfg_scripts.stdout_lines|default([]) }}"
when: ifcfg_scripts is defined
- name: Remove /var/lib/ceph mountpoint from fstab
shell: sed -i '/\/var\/lib\/ceph/d' /etc/fstab
- name: Unmount /var/lib/ceph
ansible.posix.mount:
path: /var/lib/ceph
state: unmounted
- name: Get list of SSH host keys
shell: "ls -1 /etc/ssh/ssh_host_*"
register: ssh_host_keys
ignore_errors: true
# Key regeneration is done automatically on CentOS firstboot.
# For Ubuntu, we'll add `dpkg-reconfigure openssh-server` to rc.local
- name: Delete SSH host keys so they're generated during firstboot on cloned machines
file:
path: "{{ item }}"
state: absent
with_items: "{{ ssh_host_keys.stdout_lines|default([]) }}"
when: ssh_host_keys is defined
- name: Unsubscribe RHEL
command: subscription-manager unregister
when: ansible_distribution == "RedHat"
failed_when: false
# A file gets leftover when a testnode is registered with Satellite that caused
# each registered subsequent testnode to report the wrong hostname
- name: Clean up katello facts
file:
path: /etc/rhsm/facts/katello.facts
state: absent
when: ansible_distribution == "RedHat"
# https://bugzilla.redhat.com/show_bug.cgi?id=1814337
- name: Disable dnf-makecache service
service:
name: dnf-makecache.timer
state: stopped
enabled: no
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version|int >= 8
# Hopefully fixes https://github.com/ceph/ceph-cm-ansible/pull/544#issuecomment-599076564
- name: Clean DNF cache
shell: "dnf clean all && rm -rf /var/cache/dnf/*"
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version|int >= 8
- set_fact:
ntp_service: ntp
when: ansible_os_family == "Debian"
- set_fact:
ntp_service: ntpd
when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 7
- set_fact:
ntp_service: chronyd
when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 8) or
ansible_os_family == "Suse"
- name: "Stop {{ ntp_service }} service"
service:
name: "{{ ntp_service }}"
state: stopped
when: '"ntp" in ntp_service'
# The theory here is although we do have the ntp service running on boot,
# if the time is off, it slowly drifts back in sync. Since our testnodes
# are ephemeral, they don't ever have enough time to correctly drift
# back to the correct time. So we'll force it in the captured OS images.
- name: Force time synchronization using stepping | ntp
command: "ntpdate -b {{ ntp_servers|join(' ') }}"
when: '"ntp" in ntp_service'
- name: "Start {{ ntp_service }}"
service:
name: "{{ ntp_service }}"
state: started
# chronyd needs to be started in order to force time sync. This differs from ntpd.
- name: Force time synchronization using stepping | chrony
command: chronyc -a makestep
when: '"chrony" in ntp_service'
- name: Sync the hardware clock
command: "hwclock --systohc --verbose"
become: true
become_method: sudo
become_user: root
environment:
PATH: "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
ignore_errors: true