-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImage Mode Kickstart default finish
101 lines (82 loc) · 3.27 KB
/
Image Mode Kickstart default finish
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
<%#
kind: finish
name: Kickstart default finish
model: ProvisioningTemplate
oses:
- AlmaLinux
- CentOS
- CentOS_Stream
- Fedora
- Rocky
description: |
A finish template executed at the end of the image based provisioning
using the image without user data. Foreman connects to the VM over SSH
and runs the script rendered from this template. It is meant to be run
on RPM based distributons.
This template accepts the following parameters:
- bootloader-append: string (default="nofb quiet splash=quiet")
- force-puppet: boolean (default=false)
- skip-puppet-setup: boolean (default=false)
- use-ntp: boolean (default depends on OS release)
- ntp-server: string (default=undef)
- package_upgrade: boolean (default=true)
- salt_master: string (default=undef)
- enable-remote-execution-pull: boolean (default=false)
-%>
<%
rhel_compatible = @host.operatingsystem.family == 'Redhat' && @host.operatingsystem.name != 'Fedora'
os_major = @host.operatingsystem.major.to_i
puppet_enabled = !host_param_true?('skip-puppet-setup') && (host_puppet_server.present? || host_param_true?('force-puppet'))
salt_enabled = host_param('salt_master') ? true : false
chef_enabled = @host.respond_to?(:chef_proxy) && @host.chef_proxy
%>
<%= snippet_if_exists(template_name + " custom pre") -%>
<% if @host.subnet.respond_to?(:dhcp_boot_mode?) -%>
<%= snippet 'kickstart_networking_setup' %>
<% if (rhel_compatible && os_major >= 8) -%>
systemctl restart NetworkManager
<% else -%>
service network restart
<% end -%>
<% end -%>
<% if @host.provision_method == 'image' && root_pass.present? -%>
# Install the root password
echo 'root:<%= root_pass -%>' | /usr/sbin/chpasswd -e
<% end -%>
<%= snippet 'yum_proxy' %>
<%= snippet 'ntp' %>
<% if rhel_compatible && host_param_true?('enable-epel') -%>
<%= snippet 'epel' -%>
<% end -%>
<%= snippet 'redhat_register' %>
<% if host_enc['parameters']['realm'] && @host.realm && (@host.realm.realm_type == 'FreeIPA' || @host.realm.realm_type == 'Red Hat Identity Management') -%>
<%= snippet 'freeipa_register' %>
<% end -%>
<%= snippet('remote_execution_ssh_keys_image_mode') %>
<% if plugin_present?('katello') && host_param_true?('enable-remote-execution-pull') -%>
<%= save_to_file('/root/remote_execution_pull_setup.sh', snippet('remote_execution_pull_setup'), verbatim: true) %>
chmod +x /root/remote_execution_pull_setup.sh
/root/remote_execution_pull_setup.sh
<% end -%>
<%= snippet "blacklist_kernel_modules" %>
<%= snippet_if_exists(template_name + " custom post") -%>
<% if chef_enabled %>
<%= snippet 'chef_client' %>
<% end -%>
<% if puppet_enabled %>
<% if host_param_true?('enable-puppetlabs-repo') || host_param_true?('enable-official-puppet8-repo') || host_param_true?('enable-official-puppet7-repo') || host_param_true?('enable-puppetlabs-puppet6-repo') || host_param_true?('enable-puppetlabs-puppet5-repo') -%>
<%= snippet 'puppetlabs_repo' %>
<% end -%>
<%= snippet 'puppet_setup' %>
<% end -%>
<% if salt_enabled %>
<%= snippet 'saltstack_setup' %>
<% end -%>
<% if host_param_true?('ansible_tower_provisioning') -%>
<%= save_to_file('/root/ansible_provisioning_call.sh', snippet('ansible_tower_callback_script')) %>
chmod +x /root/ansible_provisioning_call.sh
/root/ansible_provisioning_call.sh
<% end -%>
sync
<%= snippet 'schedule_reboot' -%>
exit 0