Last active
June 19, 2017 18:45
-
-
Save fabiocruzcoelho/bf00db1e1962f8e962c9dc1bbd2e2b45 to your computer and use it in GitHub Desktop.
Foreman: Script Finish CentOS7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%# | |
name: Kickstart default finish CentOS7 | |
snippet: false | |
model: ProvisioningTemplate | |
kind: finish | |
oses: | |
- CentOS | |
%> | |
<%# | |
This template accepts the following parameters: | |
- bootloader-append: string (default="nofb quiet splash=quiet") | |
- force-puppet: boolean (default=false) | |
- ntp-server: string (default="0.fedora.pool.ntp.org") | |
- package_upgrade: boolean (default=true) | |
%> | |
<% if @host.subnet.respond_to?(:dhcp_boot_mode?) -%> | |
<%= snippet 'kickstart_networking_setup' %> | |
service network restart | |
<% end -%> | |
<%= snippet 'remote_execution_ssh_keys' %> | |
<% | |
rhel_compatible = @host.operatingsystem.family == 'Redhat' | |
os_major = @host.operatingsystem.major.to_i | |
pm_set = @host.puppetmaster.empty? ? false : true | |
puppet_enabled = pm_set || @host.param_true?('force-puppet') | |
%> | |
<% if @host.provision_method == 'image' && root_pass.present? -%> | |
# Install the root password | |
echo 'root:<%= root_pass -%>' | /usr/sbin/chpasswd -e | |
<% end -%> | |
echo <%= @host.ip %> <%= @host.certname %> >> /etc/hosts | |
echo "192.168.10.10 foreman.lab.local" >> /etc/hosts | |
#Change hostname | |
hostnamectl set-hostname <%= @host.certname %> | |
#update local time | |
echo "updating system time" | |
/usr/sbin/ntpdate -sub <%= @host.params['ntp-server'] || '0.fedora.pool.ntp.org' %> | |
/usr/sbin/hwclock --systohc | |
<% unless @host.param_false?('package_upgrade') -%> | |
# update all the base packages from the updates repository | |
if [ -f /usr/bin/dnf ]; then | |
dnf -y update | |
else | |
yum -t -y update | |
fi | |
<% end -%> | |
<% if puppet_enabled %> | |
<%= snippet 'puppetlabs_repo' %> | |
<%= snippet 'puppet_setup' %> | |
<% end -%> | |
sync | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment