forked from Qikfix/satellite_foreman_easy-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsatellite.yml
306 lines (248 loc) · 11.9 KB
/
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
---
#
# Main upstream projects here
#
# https://github.com/RedHatSatellite/satellite-operations-collection
# https://github.com/RedHatSatellite/satellite-ansible-collection
#
- name: Satellite Installer Playbook here
hosts: "{{ server_group }}"
remote_user: root
collections:
- redhat.satellite_operations
- redhat.satellite
vars:
# RHSM Credentials
rhsm_username: "your_portal_username_here"
rhsm_password: "your_portal_password_here"
# Satellite Information
sat_user: "admin"
sat_pass: "redhat"
sat_org: "ACME"
def_scenario: "satellite"
# Standard Values
sat_version: "6.10"
base_os: "rhel7"
tasks:
# If you would like to see the list of facts, just disable the section below and enjoy it.
# - name: checking some variables
# ansible.builtin.debug:
# var: ansible_facts
# Firewall
- name: Disabling and Stopping firewalld
systemd:
name: firewalld
state: stopped
enabled: no
# Local Name Resolution
- name: Adding the entry to /etc/hosts
lineinfile:
path: /etc/hosts
line: "{{ ansible_facts.default_ipv4['address'] }} {{ ansible_facts['nodename'] }} {{ ansible_facts['hostname'] }}"
# Disabling it on rhel7 in case of the script rerun
- name: Disabling foreman-protector ">/etc/yum/pluginconf.d/foreman-protector.conf"
command: bash -c '>/etc/yum/pluginconf.d/foreman-protector.conf'
when: base_os == "rhel7"
# Manifest File
- name: Copying the manifest
copy:
src: manifest.zip
dest: /root/manifest.zip
# Removing the katello-ca-consumer package, in case it is still around
- name: Removing the katello-ca-consumer package package for rhel7
yum:
name: 'katello-ca-consumer*'
state: absent
when: base_os == "rhel7"
# - name: Removing the katello-ca-consumer package for rhel8
# dnf:
# name: 'katello-ca-consumer*'
# state: absent
# when: base_os == "rhel8"
# The above command didn't work properly when the machine has no repo. It was failing
# when trying to download the repodata/repomd.xml ... why?
- name: Removing the katello-ca-consumer package for rhel8
command: bash -c 'aux=$(rpm -qa | grep katello-ca-consumer); count=$(echo $aux | wc -w); if [ $count -ne 0 ]; then rpm -e $aux; fi'
when: base_os == "rhel8"
# Removing the puppet-agent package
- name: Removing the puppet-agent package
yum:
name: 'puppet-agent'
state: absent
when: base_os == "rhel7"
# fatal: [10.8.29.194]: FAILED! => {"changed": false, "msg": "Failed to download metadata for repo 'rhel-8-for-x86_64-baseos-rpms': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried", "rc": 1, "results": []}
# - name: Removing the puppet-agent package
# command: bash -c 'aux=$(rpm -qa | grep puppet-agent); count=$(echo $aux | wc -w); if [ $count -ne 0 ]; then rpm -e $aux --nodeps; fi'
# when: base_os == "rhel8"
# Cleaning the subsman cache
- name: Subscription-manager clean
command: subscription-manager clean
# Register to RHSM
- name: Register to RHSM
redhat_subscription:
state: present
username: "{{ rhsm_username }}"
password: "{{ rhsm_password }}"
force_register: yes
# Attaching the Employee Subscription
- name: Attach the correct entitlement
shell: |
pool_id=$(subscription-manager list --all --available --matches="Employee SKU" | grep Pool | head -n1 | awk '{print $3}') && subscription-manager attach --pool $pool_id
# Repositories
- name: Disabling all the repos
rhsm_repository:
name: '*'
state: disabled
- name: Enabling the Satellite repos for Satellite 6.5
rhsm_repository:
name: rhel-7-server-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-satellite-6.5-rpms,rhel-7-server-satellite-maintenance-6-rpms,rhel-7-server-ansible-2.6-rpms
state: enabled
when: sat_version == "6.5"
- name: Enabling the Satellite repos for Satellite 6.6
rhsm_repository:
name: rhel-7-server-rpms,rhel-7-server-satellite-6.6-rpms,rhel-7-server-satellite-maintenance-6-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-ansible-2.8-rpms
state: enabled
when: sat_version == "6.6"
- name: Enabling the Satellite repos for Satellite 6.7
rhsm_repository:
name: rhel-7-server-rpms,rhel-7-server-satellite-6.7-rpms,rhel-7-server-satellite-maintenance-6-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-ansible-2.8-rpms
state: enabled
when: sat_version == "6.7"
- name: Enabling the Satellite repos for Satellite 6.8
rhsm_repository:
name: rhel-7-server-rpms,rhel-7-server-satellite-6.8-rpms,rhel-7-server-satellite-maintenance-6-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-ansible-2.9-rpms
state: enabled
when: sat_version == "6.8"
- name: Enabling the Satellite repos for Satellite 6.9
rhsm_repository:
name: rhel-7-server-rpms,rhel-7-server-satellite-6.9-rpms,rhel-7-server-satellite-maintenance-6-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-ansible-2.9-rpms
state: enabled
when: sat_version == "6.9"
- name: Enabling the Satellite repos for Satellite 6.10
rhsm_repository:
name: rhel-7-server-rpms,rhel-7-server-satellite-6.10-rpms,rhel-7-server-satellite-maintenance-6-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-ansible-2.9-rpms
state: enabled
when: sat_version == "6.10"
- name: Enabling the Satellite repos for Satellite 6.11 on RHEL7
rhsm_repository:
name: rhel-7-server-rpms,rhel-server-rhscl-7-rpms,rhel-7-server-ansible-2.9-rpms,rhel-7-server-satellite-6.11-rpms,rhel-7-server-satellite-maintenance-6.11-rpms
state: enabled
when: sat_version == "6.11" and base_os == "rhel7"
- name: Enabling the Satellite repos for Satellite 6.11 on RHEL8
rhsm_repository:
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
when: sat_version == "6.11" and base_os == "rhel8"
- name: Updating the server
command: yum update -y
- name: Enabling the dnf module "dnf module enable satellite:el8"
command: dnf module enable satellite:el8 -y
when: sat_version == "6.11" and base_os == "rhel8"
# Packages
- name: Installing Satellite Package
yum:
name: satellite
state: present
# Add this here, before runing the installer
- name: Removing puppetlabs ssl directory "/etc/puppetlabs/puppet/ssl/"
command: rm -rf /etc/puppetlabs/puppet/ssl/
# # Calling the installer
# - import_role:
# name: redhat.satellite_operations.installer
# vars:
# satellite_installer_scenario: "{{ def_scenario }}"
# satellite_installer_options:
# - '--foreman-initial-organization "{{ sat_org }}"'
# - '--foreman-admin-password {{ sat_pass }}'
# when: sat_version == "6.5" or sat_version == "6.6"
# Sometimes seeing sat611 failing during the installation because the server was unresponsive. It probably will fix this behavior.
# when rerunning the playbook/installer.
# 404 Client Error: Not Found for url: https://wallsat611-rhel8.d.sysmgmt.cee.********.com/apidoc/v2.json
- name: Foreman-rake apipie:cache
# command: foreman-rake apipie:cache
# Adding only the en version to speed up this process, instead of a lot of idioms
command: bash -c 'export FOREMAN_APIPIE_LANGS=en && foreman-rake apipie:cache --trace'
when: base_os == "rhel8"
# Calling the installer
# When using the collection, it's failing for 6.7 or less because of the flag "--detailed something"
- name: Satellite Installer, versions equal or older than 6.6
command: bash -c 'satellite-installer --scenario "{{ def_scenario }}" --foreman-initial-organization "{{ sat_org }}" --foreman-admin-password {{ sat_pass }}'
when: sat_version == "6.5" or sat_version == "6.6"
# Calling the installer
# When using the collection, it's failing for 6.7 or less because of the flag "--detailedsomething"
- name: Satellite Installer, version equal to 6.7
command: bash -c 'satellite-installer --scenario "{{ def_scenario }}" --foreman-initial-organization "{{ sat_org }}" --foreman-initial-admin-password {{ sat_pass }}'
when: sat_version == "6.7"
# Calling the installer
# changing the call to the admin-password, adding "-initial-"
- import_role:
name: redhat.satellite_operations.installer
vars:
satellite_installer_scenario: "{{ def_scenario }}"
satellite_installer_options:
- '--foreman-initial-organization "{{ sat_org }}"'
- '--foreman-initial-admin-password {{ sat_pass }}'
when: sat_version == "6.8" or sat_version == "6.9" or sat_version == "6.10" or sat_version == "6.11"
# Importing the manifest
- import_role:
name: redhat.satellite.manifest
vars:
- satellite_organization: "{{ sat_org }}"
- satellite_manifest_path: "/root/manifest.zip"
- satellite_server_url: "https://{{ ansible_facts['nodename'] }}"
- satellite_username: "{{ sat_user }}"
- satellite_password: "{{ sat_pass }}"
# Refreshing the manifest
- name: Refreshing the Manifest
command: hammer -u "{{ sat_user }}" -p "{{ sat_pass }}" subscription refresh-manifest --organization "{{ sat_org }}"
# Repository actions
- import_role:
name: redhat.satellite.repositories
vars:
satellite_organization: "{{ sat_org }}"
satellite_server_url: "https://{{ ansible_facts['nodename'] }}"
satellite_username: "{{ sat_user }}"
satellite_password: "{{ sat_pass }}"
satellite_products:
- name: Red Hat Enterprise Linux Server
repository_sets:
- name: Red Hat Enterprise Linux 7 Server (RPMs)
basearch: x86_64
releasever: 7Server
- name: Red Hat Satellite Tools 6.10 (for RHEL 7 Server) (RPMs)
basearch: x86_64
- name: Red Hat Enterprise Linux for x86_64
repository_sets:
- name: Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)
releasever: 8
- name: Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)
releasever: 8
- name: Red Hat Satellite Tools 6.10 for RHEL 8 x86_64 (RPMs)
# This call will trigger the sync process and will move on
- name: Syncronizing repos via hammer "--async"
command: bash -c 'for b in $(hammer --csv --no-headers repository list | cut -d, -f1); do echo - $b; hammer repository synchronize --id $b --async; done'
# The call below doesn't have any "--async" feature at this moment. Keeping it commented until we get this feature done.
# - name: "Repo Sync - Red Hat Enterprise Linux for x86_64"
# redhat.satellite.repository_sync:
# username: "{{ sat_user }}"
# password: "{{ sat_pass }}"
# server_url: "https://{{ ansible_facts['nodename'] }}"
# organization: "{{ sat_org }}"
# product: "Red Hat Enterprise Linux for x86_64"
# - name: "Repo Sync - Red Hat Enterprise Linux"
# redhat.satellite.repository_sync:
# username: "{{ sat_user }}"
# password: "{{ sat_pass }}"
# server_url: "https://{{ ansible_facts['nodename'] }}"
# organization: "{{ sat_org }}"
# product: "Red Hat Enterprise Linux Server"
# Activation Key actions
- import_role:
name: redhat.satellite.activation_keys
vars:
satellite_organization: "{{ sat_org }}"
satellite_server_url: "https://{{ ansible_facts['nodename'] }}"
satellite_username: "{{ sat_user }}"
satellite_password: "{{ sat_pass }}"
satellite_activation_keys:
- name: "ak_rhel"