Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
PuppetLabs PC1 (AIO Packages) repo support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmoll committed Mar 31, 2016
1 parent 11a0d39 commit 8eca3cf
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 29 deletions.
7 changes: 7 additions & 0 deletions kickstart/finish.erb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-fedora-<%= os_major -%>.no
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-el-<%= os_major -%>.noarch.rpm
<% end -%>
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
<% if @host.operatingsystem.name == 'Fedora' -%>
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-pc1-fedora-<%= os_major -%>.noarch.rpm
<% else -%>
rpm -ivh http://yum.puppetlabs.com/puppetlabs-release-pc1-el-<%= os_major -%>.noarch.rpm
<% end -%>
<% end -%>
<% end -%>

#update local time
Expand Down
22 changes: 18 additions & 4 deletions kickstart/provision.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This template accepts the following parameters:
- http-proxy-port: string (default="")
- force-puppet: boolean (default=false)
- enable-puppetlabs-repo: boolean (default=false)
- enable-puppetlabs-pc1-repo: boolean (default=false)
- salt_master: string (default=undef)
- ntp-server: string (default="0.fedora.pool.ntp.org")
- bootloader-append: string (default="nofb quiet splash=quiet")
Expand Down Expand Up @@ -67,16 +68,26 @@ realm join --one-time-password='<%= @host.otp || "$HOST[OTP]" %>' <%= @host.real
<% if @host.operatingsystem.name == 'Fedora' -%>
repo --name=fedora-everything --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=fedora-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %><%= proxy_string %>
<% if puppet_enabled && @host.param_true?('enable-puppetlabs-repo') -%>
<% if puppet_enabled -%>
<% if @host.param_true?('enable-puppetlabs-repo') -%>
repo --name=puppetlabs-products --baseurl=http://yum.puppetlabs.com/fedora/f<%= @host.operatingsystem.major %>/products/<%= @host.architecture %><%= proxy_string %>
repo --name=puppetlabs-deps --baseurl=http://yum.puppetlabs.com/fedora/f<%= @host.operatingsystem.major %>/dependencies/<%= @host.architecture %><%= proxy_string %>
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
repo --name=puppetlabs-pc1 --baseurl=http://yum.puppetlabs.com/fedora/f<%= @host.operatingsystem.major %>/PC1/<%= @host.architecture %><%= proxy_string %>
<% end -%>
<% end -%>
<% elsif rhel_compatible && os_major > 4 -%>
repo --name="EPEL" --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %><%= proxy_string %>
<% if puppet_enabled && @host.param_true?('enable-puppetlabs-repo') -%>
<% if puppet_enabled -%>
<% if @host.param_true?('enable-puppetlabs-repo') -%>
repo --name=puppetlabs-products --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/products/<%= @host.architecture %><%= proxy_string %>
repo --name=puppetlabs-deps --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/dependencies/<%= @host.architecture %><%= proxy_string %>
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
repo --name=puppetlabs-pc1 --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/PC1/<%= @host.architecture %><%= proxy_string %>
<% end -%>
<% end -%>
<% end -%>
<% if @host.operatingsystem.name == 'Fedora' and os_major <= 16 -%>
Expand Down Expand Up @@ -115,11 +126,14 @@ redhat-lsb-core
<% if rhel_compatible && os_major > 4 -%>
epel-release
<% end -%>
<% if puppet_enabled %>
puppet
<% if puppet_enabled -%>
<%= @host.param_true?('enable-puppetlabs-pc1-repo') ? 'puppet-agent' : 'puppet' %>
<% if @host.param_true?('enable-puppetlabs-repo') -%>
puppetlabs-release
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
puppetlabs-release-pc1
<% end -%>
<% end -%>
<% if salt_enabled %>
salt-minion
Expand Down
15 changes: 13 additions & 2 deletions kickstart/provision_rhel.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This template accepts the following parameters:
- http-proxy-port: string (default="")
- force-puppet: boolean (default=false)
- enable-puppetlabs-repo: boolean (default=false)
- enable-puppetlabs-pc1-repo: boolean (default=false)
- salt_master: string (default=undef)
- ntp-server: string (default="0.fedora.pool.ntp.org")
- bootloader-append: string (default="nofb quiet splash=quiet")
Expand Down Expand Up @@ -65,10 +66,15 @@ realm join --one-time-password='<%= @host.otp || "$HOST[OTP]" %>' <%= @host.real
<% if os_major > 4 -%>
repo --name="EPEL" --mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-<%= @host.operatingsystem.major %>&arch=<%= @host.architecture %><%= proxy_string %>
<% if puppet_enabled && @host.param_true?('enable-puppetlabs-repo') -%>
<% if puppet_enabled -%>
<% if @host.param_true?('enable-puppetlabs-repo') -%>
repo --name=puppetlabs-products --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/products/<%= @host.architecture %><%= proxy_string %>
repo --name=puppetlabs-deps --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/dependencies/<%= @host.architecture %><%= proxy_string %>
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
repo --name=puppetlabs-pc1 --baseurl=http://yum.puppetlabs.com/el/<%= @host.operatingsystem.major %>/PC1/<%= @host.architecture %><%= proxy_string %>
<% end -%>
<% end -%>
<% end -%>

bootloader --location=mbr --append="<%= @host.params['bootloader-append'] || 'nofb quiet splash=quiet' %>" <%= grub_pass %>
Expand Down Expand Up @@ -97,9 +103,14 @@ redhat-lsb-core
<% if os_major > 4 -%>
epel-release
<% end -%>
<% if puppet_enabled && @host.param_true?('enable-puppetlabs-repo') -%>
<% if puppet_enabled -%>
<% if @host.param_true?('enable-puppetlabs-repo') -%>
puppetlabs-release
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
puppetlabs-release-pc1
<% end -%>
<% end -%>
<% if salt_enabled %>
salt-minion
<% end -%>
Expand Down
1 change: 1 addition & 0 deletions preseed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The templates use some Host Parameters to contol the flow of the template. These
* `partitioning-vg-name`: LVM volume group name (default: `vg01` for `Preseed default lvm`)
* `partitioning-filesystem`: One of `ext4`, `ext4`, `btrfs`, ... (default: empty, the default is used)
* `enable-puppetlabs-repo`: Add the Puppet Labs APT repo to the APT sources during install (default: `false`)
* `enable-puppetlabs-pc1-repo`: Add the Puppet Labs PC1 APT repo to the APT sources during install (default: `false`)
* `enable-saltstack-repo`: Add the SaltStack APT repo to the APT sources during install (default: `false`)
* `salt_master`: SaltStack Master (default: empty)
* `salt_grains`: Salt client specific information, like facter (default: empty)
Expand Down
21 changes: 13 additions & 8 deletions preseed/provision.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ d-i passwd passwd/make-user boolean false
user-setup-udeb passwd/make-user boolean false

<% repos = 0 %>
<% if puppet_enabled && @host.param_true?('enable-puppetlabs-repo') -%>
<% if puppet_enabled -%>
<% if @host.param_true?('enable-puppetlabs-repo') -%>
# Puppetlabs products
d-i apt-setup/local<%= repos %>/repository string \
http://apt.puppetlabs.com <%= @host.operatingsystem.release_name %> main
Expand All @@ -97,6 +98,15 @@ d-i apt-setup/local<%= repos %>/source boolean true
d-i apt-setup/local<%= repos %>/key string http://apt.puppetlabs.com/pubkey.gpg
<% repos += 1 -%>
<% end -%>
<% if @host.param_true?('enable-puppetlabs-pc1-repo') -%>
# Puppetlabs PC1 <%= @host.operatingsystem.release_name %> Repository
d-i apt-setup/local<%= repos %>/repository string http://apt.puppetlabs.com <%= @host.operatingsystem.release_name %> PC1
d-i apt-setup/local<%= repos %>/comment string Puppetlabs PC1 <%= @host.operatingsystem.release_name %> Repository
d-i apt-setup/local<%= repos %>/source boolean true
d-i apt-setup/local<%= repos %>/key string http://apt.puppetlabs.com/pubkey.gpg
<% repos += 1 -%>
<% end -%>
<% end -%>
<% if salt_enabled -%>
<% salt_package = 'salt-minion' -%>
Expand All @@ -122,14 +132,9 @@ d-i apt-setup/local<%= repos %>/key string http://keyserver.ubuntu.com/pks/looku
tasksel tasksel/first multiselect minimal, ssh-server, openssh-server

<% if puppet_enabled %>
<% if @host.operatingsystem.name == 'Ubuntu' and @host.operatingsystem.major.to_i == 10 -%>
<% puppet_package = 'puppet/lucid-backports' -%>
d-i apt-setup/backports boolean true
<% else -%>
<% puppet_package = 'puppet' -%>
<% end -%>
<% puppet_package = @host.param_true?('enable-puppetlabs-pc1-repo') ? 'puppet-agent' : 'puppet' -%>
<% else -%>
<% puppet_package = '' -%>
<% puppet_package = '' -%>
<% end -%>

# Install some base packages
Expand Down
31 changes: 21 additions & 10 deletions snippets/puppet.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,33 @@
kind: snippet
name: puppet.conf
%>
<%
if @host.param_true?('enable-puppetlabs-pc1-repo') && (@host.operatingsystem.family == 'Debian' || @host.operatingsystem.family == 'Redhat')
var_dir = '/opt/puppetlabs/puppet/cache'
log_dir = '/var/log/puppetlabs/puppet'
run_dir = '/var/run/puppetlabs'
ssl_dir = '/etc/puppetlabs/puppet/ssl'
else
if @host.operatingsystem.family == 'Freebsd'
var_dir = '/var/puppet'
else
var_dir = '/var/lib/puppet'
end
log_dir = '/var/log/puppet'
run_dir = '/var/run/puppet'
ssl_dir = '\$vardir/ssl'
end
%>
[main]
<% if @host.operatingsystem.name == 'FreeBSD' -%>
vardir = /var/puppet
logdir = \$vardir/log
<% else -%>
vardir = /var/lib/puppet
logdir = /var/log/puppet
<% end -%>
rundir = /var/run/puppet
ssldir = \$vardir/ssl
vardir = <%= var_dir %>
logdir = <%= log_dir %>
rundir = <%= run_dir %>
ssldir = <%= ssl_dir %>

[agent]
pluginsync = true
report = true
ignoreschedules = true
daemon = false
<%- if @host.puppet_ca_server.strip -%>
ca_server = <%= @host.puppet_ca_server %>
<%- end -%>
Expand Down
23 changes: 18 additions & 5 deletions snippets/puppet_setup.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,35 @@ name: puppet_setup
description: this snippet will configure the Puppet agent
%>
<%
etc_path = (@host.operatingsystem.family == 'Freebsd') ? '/usr/local/etc/puppet' : '/etc/puppet'
bin_path = (@host.operatingsystem.family == 'Freebsd') ? '/usr/local/bin' : '/usr/bin'
if @host.operatingsystem.family == 'Freebsd'
freebsd_package = @host.param_true?('enable-puppet4') ? 'puppet4' : 'puppet38'
etc_path = '/usr/local/etc/puppet'
bin_path = '/usr/local/bin'
elsif @host.param_true?('enable-puppetlabs-pc1-repo')
linux_package = 'puppet-agent'
etc_path = '/etc/puppetlabs/puppet'
bin_path = '/opt/puppetlabs/bin'
else
linux_package = 'puppet'
etc_path = '/etc/puppet'
bin_path = '/usr/bin'
end
%>
<% if @host.operatingsystem.family == 'Debian' -%>
apt-get update
apt-get install -y puppet
apt-get install -y <%= linux_package %>
<% elsif @host.operatingsystem.family == 'Freebsd' -%>
pkg install -y puppet
pkg install -y <%= freebsd_package %>
<% elsif @host.operatingsystem.family == 'Redhat' -%>
yum -t -y install puppet
yum -t -y install <%= linux_package %>
<% end -%>

cat > <%= etc_path %>/puppet.conf << EOF
<%= snippet 'puppet.conf' %>
EOF

<% unless @host.param_true?('enable-puppetlabs-pc1-repo') -%>
<% if @host.operatingsystem.family == 'Debian' -%>
if [ -f "/etc/default/puppet" ]
then
Expand All @@ -42,5 +54,6 @@ then
fi
/sbin/chkconfig puppet on -f
<% end -%>
<% end -%>
<%= bin_path %>/puppet agent --config <%= etc_path %>/puppet.conf --onetime --tags no_such_tag <%= @host.puppetmaster.blank? ? '' : "--server #{@host.puppetmaster}" %> --no-daemonize

0 comments on commit 8eca3cf

Please sign in to comment.