-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplaybook.yml
223 lines (208 loc) · 7.14 KB
/
playbook.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
---
- name: Install Foreman Server with Katello
hosts: foremanserver
become: true
gather_facts: true
roles:
- theforeman.operations.foreman_repositories
- theforeman.operations.puppet_repositories
- theforeman.operations.installer
tasks:
- name: "Setup DNS-Proxy for Domain"
theforeman.foreman.domain:
name: "localdomain"
description: "localdomain"
organizations:
- "{{ organization }}"
server_url: "{{ server_url }}"
username: "{{ username }}"
password: "{{ password }}"
dns_proxy: "foreman.localdomain"
state: present
- name: "Create Subnet foreman"
theforeman.foreman.subnet:
name: "foreman"
network_type: "IPv4"
network: "10.0.0.0"
cidr: "16"
mask: "255.255.0.0"
gateway: "10.0.0.1"
dns_primary: "10.0.0.2"
ipam: "DHCP"
boot_mode: "DHCP"
from_ip: "10.0.0.100"
to_ip: "10.0.0.200"
dhcp_proxy: "foreman.localdomain"
tftp_proxy: "foreman.localdomain"
dns_proxy: "foreman.localdomain"
domains:
- "localdomain"
server_url: "{{ server_url }}"
username: "{{ username }}"
password: "{{ password }}"
state: present
- name: "Copy private key SSH-Key to foreman user"
ansible.builtin.copy:
src: "files/id_rsa"
dest: "/usr/share/foreman/.ssh/id_rsa"
mode: "0600"
owner: foreman
group: foreman
- name: "Add host [email protected] to known_hosts"
ansible.builtin.known_hosts:
path: "/usr/share/foreman/.ssh/known_hosts"
name: "host.localdomain"
hash_host: false
key: "{{ lookup('pipe', 'ssh-keyscan -H -t rsa host.localdomain') | trim }}"
- name: "Add foreman-key to authorized keys for root user"
ansible.posix.authorized_key:
user: root
state: present
key: "{{ lookup('file', 'files/id_rsa.pub') }}"
delegate_to: localhost
- name: "Create libvirt compute resource"
theforeman.foreman.compute_resource:
name: "libvirt"
organizations:
- "{{ organization }}"
provider: "libvirt"
provider_params:
url: "qemu+ssh://[email protected]/system"
display_type: "vnc"
set_console_password: "false"
server_url: "{{ server_url }}"
username: "{{ username }}"
password: "{{ password }}"
state: present
- name: "Create Operating System Architecture x86_64"
theforeman.foreman.architecture:
name: "x86_64"
server_url: "{{ server_url }}"
username: "{{ username }}"
password: "{{ password }}"
state: "present"
- name: "Copy RedHat Manifest to Foreman Server"
ansible.builtin.copy:
src: "files/manifest.zip"
dest: "/root/manifest.zip"
mode: "0400"
owner: "root"
group: "root"
- name: "Upload the RedHat Developer Subscription for Individuals"
theforeman.foreman.subscription_manifest:
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
organization: "{{ organization }}"
state: present
manifest_path: "/tmp/manifest.zip"
- name: "Create Repository Set for RHEL 9"
theforeman.foreman.repository_set:
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
organization: "{{ organization }}"
product: "Red Hat Enterprise Linux for x86_64"
label: "{{ item.label }}"
repositories: "{{ item.repositories | default(omit) }}"
state: enabled
loop:
- label: "rhel-9-for-x86_64-appstream-kickstart"
repositories:
- releasever: "9.5"
- label: "rhel-9-for-x86_64-appstream-rpms"
repositories:
- releasever: "9"
- label: "rhel-9-for-x86_64-baseos-kickstart"
repositories:
- releasever: "9.5"
- label: "rhel-9-for-x86_64-baseos-rpms"
repositories:
- releasever: "9"
- name: "Sync Repository RHEL 9"
theforeman.foreman.repository_sync:
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
product: "Red Hat Enterprise Linux for x86_64"
organization: "{{ organization }}"
changed_when: false
- name: "Create Activation Key for RHEL9"
theforeman.foreman.activation_key:
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
name: "Red Hat Enterprise Linux 9"
organization: "{{ organization }}"
lifecycle_environment: "Library"
content_overrides:
- label: "rhel-9-for-x86_64-appstream-rpms"
override: enabled
- label: "rhel-9-for-x86_64-baseos-rpms"
override: enabled
- name: "Create Hostgroup"
theforeman.foreman.hostgroup:
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
name: "Red Hat Enterprise Linux 9"
architecture: "x86_64"
activation_keys: "Red Hat Enterprise Linux 9"
state: present
- name: "Update Compute Profile 1-Small"
theforeman.foreman.compute_profile:
name: "1-Small"
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
compute_attributes:
- compute_resource: "libvirt"
vm_attrs:
volumes_attributes:
0:
pool_name: default
capacity: "10G"
allocation: "0G"
format_type: "qcow2"
nics_attributes:
0:
type: "network"
network: "foreman"
bridge: "virbr1"
interface: "virtio"
- name: "Create Test Host"
theforeman.foreman.host:
username: "{{ username }}"
password: "{{ password }}"
server_url: "{{ server_url }}"
location: "Default Location"
organization: "{{ organization }}"
name: "test-rhel9.localdomain"
build: true
architecture: "x86_64"
content_source: "foreman.localdomain"
lifecycle_environment: "Library"
operatingsystem: "RedHat 9.5"
content_view: "Default Organization View"
compute_resource: "libvirt"
provision_method: "build"
ptable: "Kickstart default"
pxe_loader: "PXELinux BIOS"
root_pass: "{{ root_password }}"
compute_profile: "1-Small"
domain: "localdomain"
kickstart_repository: "Red Hat Enterprise Linux 9 for x86_64 - BaseOS Kickstart 9.5"
compute_attributes:
cpus: "4"
memory: "4294967296"
start: "1"
interfaces_attributes:
- type: "interface"
compute_attributes:
type: "network"
network: "foreman"
model: "virtio"
state: present
hostgroup: "Red Hat Enterprise Linux 9"
subnet: "foreman"
changed_when: false