-
Notifications
You must be signed in to change notification settings - Fork 12
/
ensure-satellite.yml
204 lines (182 loc) · 5.37 KB
/
ensure-satellite.yml
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
---
# building VM based on requirements here
# https://access.redhat.com/documentation/en-us/red_hat_satellite/6.11/html/installing_satellite_server_in_a_connected_network_environment/preparing_your_environment_for_installation_satellite
#
- import_playbook: ensure-vm-state.yml
vars:
template: rhel_8_5_image
memory_mb: 20480
num_cpus: 4
vm_state: poweredon
net_name: RH-seg-2991
short_name: "{{ short_name }}"
net_type: static
ip: "{{ satellite_ip }}"
netmask: 255.255.255.0
gateway: 10.128.1.1
domain: "{{ ipaserver_domain }}"
dns_servers:
- "{{ ipaserver_master_ip }}"
- "{{ ipaserver_replica_ip }}"
tags: vm
- name: update inventory
hosts: localhost
connection: local
gather_facts: false
tasks:
- name: debug host ip
debug:
var: host_ip
- name: fix in-memory inventory with client
add_host:
name: "{{ host_ip }}"
# become: true
ansible_ssh_user: root
groups:
- ipaclients
- new_satellite
- name: Play checks if disks are done previously
hosts: "{{ host_ip | default('new_satellite')}}"
tasks:
- name: check if we can skip disks part
lineinfile:
path: /etc/mtab
regexp: ^/dev/mapper/satellite--reqs-logs
state: absent
check_mode: true
register: disks_already_done
changed_when: false
# satellite reqs: psql 20GB + pulp 300GB + swap 4G + logs 10GB
- import_playbook: vmware_add_disk_to_vm.yml
vars:
vm_disksize: "334 GB"
tags:
- vm
- disks
when: not disks_already_done.found
- name: setup stuff at vm
hosts: "{{ host_ip | default('new_satellite')}}"
collections:
- redhat.rhel_system_roles
- community.general
pre_tasks:
- name: Subscribe to Red Hat
redhat_subscription:
state: present
username: "{{ rh_subs_username }}"
password: "{{ rh_subs_password }}"
autosubscribe: false
pool: 'Red Hat Satellite Infrastructure Subscription'
tags: subs
- name: Enable required repositories
rhsm_repository:
# yamllint disable-line rule:line-length
name:
- rhel-8-for-x86_64-baseos-rpms
- rhel-8-for-x86_64-appstream-rpms
- satellite-6.11-for-rhel-8-x86_64-rpms
- satellite-maintenance-6.11-for-rhel-8-x86_64-rpms
state: enabled
tags: regs
- name: set yum module
command:
cmd: yum module enable -y satellite:el8
warn: false
tags: yum
- name: install some pre-req stuff
yum:
name:
# - python3-blivet
- insights-client
state: present
tags: packages
- name: Register unused disk to variable
find_unused_disk:
min_size: '1g'
register: vm_unused_disk
tags: disks
when: not disks_already_done.found
- name: Unused disk output debug
debug:
msg: "{{ vm_unused_disk }}"
tags: disks
when: not disks_already_done.found
- name: Unused disks debug
debug:
msg: "{{ vm_unused_disk.disks[0] }}"
tags: disks
when: not disks_already_done.found
- name: Check if there is empty disks
when:
- not disks_already_done.found
- vm_unused_disk.disks[0] == "Unable to find unused disk"
fail:
msg: "Unable to find unused disk from the VM."
tags: disks
tasks:
- name: Create filesystems on the new disk
ansible.builtin.include_role:
name: redhat.rhel_system_roles.storage
tags: disks
when: not disks_already_done.found
vars:
storage_pools:
- name: "satellite-reqs"
type: lvm
disks:
- "{{ vm_unused_disk.disks[0] }}"
# satellite reqs: psql 20GB + pulp 300GB + swap 4G + logs 10GB
volumes:
- name: psql
size: 20GB
mount_point: /var/lib/pgsql
fs_type: xfs
state: present
- name: pulp
size: 300GB
mount_point: "/var/lib/pulp"
fs_type: xfs
state: present
- name: swap
size: 4GB
fs_type: swap
state: present
- name: logs
size: 10GB
mount_point: "/var/log_new"
fs_type: xfs
state: present
- name: ensure fqdn hostname
hostname:
name: "{{ short_name }}.{{ ipaserver_domain }}"
use: systemd
- name: Move logs
tags: disks
ansible.builtin.shell: |
cp -ar /var/logs /var/logs_new/
rm -rf /var/logs
when: not disks_already_done.found
- name: umount logs
tags: disks
ansible.posix.mount:
path: /var/lib/logs_new
src: /dev/mapper/satellite--reqs-logs
state: absent
when: not disks_already_done.found
- name: replace logs
tags: disks
ansible.posix.mount:
path: /var/log
src: /dev/mapper/satellite--reqs-logs
fstype: xfs
state: present
when: not disks_already_done.found
- name: Fix logs selinux labels
tags: disks
ansible.builtin.shell:
restorecon -r /var/log
when: not disks_already_done.found
- name: Reboot the machine
tags: disks
ansible.builtin.reboot:
when: not disks_already_done.found