-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-activation-keys.yml
253 lines (229 loc) · 8.12 KB
/
configure-activation-keys.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
- name: Perfom day-2 configuration of Satellite
hosts: satellite
gather_facts: yes
vars_files:
- vars/satellite.yml
tasks:
- name: Configure Satellite manifest
ansible.builtin.import_role:
name: redhat.satellite.manifest
- name: Configure Red Hat repositories
ansible.builtin.import_role:
name: redhat.satellite.repositories
- name: Configure Red Hat repositories sync plan
redhat.satellite.sync_plan:
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
server_url: "{{ satellite_server_url }}"
name: "RHEL Sync"
organization: "{{ satellite_organization }}"
interval: daily
enabled: yes
sync_date: "2023-11-10 07:00:00 UTC"
products: "{{ satellite_products | selectattr('name') | map(attribute='name') }}"
- name: Configure authentication source
redhat.satellite.auth_source_ldap:
name: LOCAL.LAB
host: idm.local.lab
port: 636
tls: yes
account: "{{ satellite_idm_account }}"
account_password: "{{ satellite_idm_account_password }}"
base_dn: dc=local,dc=lab
groups_base: cn=groups,cn=accounts,dc=local,dc=lab
server_type: free_ipa
attr_login: uid
attr_firstname: givenName
attr_lastname: sn
attr_mail: mail
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
state: present
- name: Configure admin user
redhat.satellite.user:
auth_source: LOCAL.LAB
admin: yes
default_organization: Lab
default_location: Gilbert
firstname: Mike
lastname: Allmen
login: mallmen
mail: [email protected]
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
state: present
- name: Configure IDM for provisioned hosts
block:
- name: Configure keytab for foreman-proxy user
ansible.builtin.copy:
src: /root/freeipa.keytab
dest: /etc/foreman-proxy/freeipa.keytab
remote_src: yes
owner: foreman-proxy
group: foreman-proxy
- name: Retrieve IDM CA certificate
ansible.builtin.get_url:
url: http://idm.local.lab/ipa/config/ca.crt
dest: /etc/pki/ca-trust/source/anchors/ca.crt
- name: Add CA certificate to CA trust
ansible.builtin.command: update-ca-trust enable
- name: Add CA certificate to CA trust
ansible.builtin.command: update-ca-trust
#- name: Install Satellite
# ansible.builtin.import_role:
# name: redhat.satellite_operations.installer
# vars:
# satellite_installer_scenario: satellite
# satellite_installer_package: satellite-installer
# satellite_installer_options:
# - '--foreman-proxy-realm true'
# - '--foreman-proxy-realm-keytab /et/foreman-proxy/freeipa.keytab'
# - '--foreman-proxy-realm-principal [email protected]'
# - '--foreman-proxy-realm-provider freeipa'
- name: Restart foreman-proxy
ansible.builtin.service:
name: foreman-proxy
state: restarted
- name: Create IDM realm
redhat.satellite.realm:
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
name: LOCAL.LAB
realm_proxy: satellite.local.lab
realm_type: Red Hat Identity Management
state: present
- name: Create vmware compute resource
redhat.satellite.compute_resource:
name: vmware
provider: vmware
provider_params:
caching_enabled: false
url: newcastle.local.lab
user: "{{ vmware_username }}"
password: "{{ vmware_password }}"
datacenter: homelab
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
state: present
- name: Configure libvirt compute resource
block:
- name: Create .ssh directory for foreman user
ansible.builtin.file:
path: /usr/share/foreman/.ssh
owner: foreman
group: foreman
mode: 0700
state: directory
- name: Create ssh-key pair
community.crypto.openssh_keypair:
path: /usr/share/foreman/.ssh/id_rsa
comment: [email protected]
owner: foreman
group: foreman
- name: Get pub file
ansible.builtin.fetch:
src: /usr/share/foreman/.ssh/id_rsa.pub
dest: files/id_rsa.pub
flat: yes
- name: copy key
delegate_to: arsenal.local.lab
ansible.posix.authorized_key:
user: root
state: present
key: "{{ lookup('file', 'files/id_rsa.pub') }}"
- name: Remove key
ansible.builtin.file:
path: "{{ playbook_dir }}/files/id_rsa.pub"
state: absent
- name: Create libvirt compute resource
redhat.satellite.compute_resource:
name: libvirt-arsenal
provider: libvirt
provider_params:
url: qemu+ssh://[email protected]/system
display_type: spice
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
state: present
- name: Configure lifecycle environment
redhat.satellite.lifecycle_environment:
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
name: "{{ item.name }}"
label: "{{ item.name }}"
prior: "{{ item.previous }}"
organization: Lab
state: present
loop: "{{ lifecycle_envs }}"
vars:
lifecycle_envs:
- name: dev
previous: Library
- name: test
previous: dev
- name: prod
previous: test
- name: Configure primary subnet
redhat.satellite.subnet:
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
name: 10.0.0.0
network: 10.0.0.0
cidr: 23
gateway: 10.0.0.1
from_ip: 10.0.1.1
to_ip: 10.0.1.254
boot_mode: DHCP
dhcp_proxy: satellite.local.lab
tftp_proxy: satellite.local.lab
domains:
- local.lab
organizations:
- Lab
locations:
- Gilbert
state: present
- name: Create activation keys
tags:
- keys
redhat.satellite.activation_key:
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
name: "{{ item.name }}"
organization: Lab
lifecycle_environment: "{{ item.le | default('Library') }}"
content_view: "{{ item.cv | default('Default Organization View') }}"
release_version: "{{ item.release | default(omit) }}"
service_level: "{{ item.level | default(omit) }}"
state: absent
loop: "{{ activation_keys }}"
vars:
activation_keys:
- name: rhel7
#release: 7Server
- name: rhel8
#release: 8Server
- name: rhel9
#release: 9Server
- name: Configure settings
redhat.satellite.setting:
server_url: "{{ satellite_server_url }}"
username: "{{ satellite_username }}"
password: "{{ satellite_password }}"
name: "{{ item.name }}"
value: "{{ item.value }}"
loop: "{{ settings }}"
vars:
settings:
- name: show_unsupported_templates
value: false
- name: destroy_vm_on_host_delete
value: true