]> Frank Brehm's Git Trees - pixelpark/create-vmware-tpl.git/commitdiff
Implementing install_puppet in bin/postinst
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 28 Mar 2018 15:23:20 +0000 (17:23 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 28 Mar 2018 15:23:20 +0000 (17:23 +0200)
bin/postinst

index f2e1b48d42a58bc251487895c2df68a7364dad1f..dfcdebef350968a982f9af42de92f8e2b4e52a9e 100644 (file)
@@ -309,9 +309,15 @@ install_epel() {
 
     #yum install -y "${url}"
 
+    echo
+    log "Cleaning YUM cache ..."
+    yum clean all
+
+    echo
     log "Updating YUM cache ..."
-    yum makecache
+    yum makecache fast
 
+    echo
     log "Installing perl-Config-IniFiles.noarch ..."
     yum install -y perl-Config-IniFiles.noarch
     sleep 3
@@ -399,11 +405,12 @@ create_motd() {
     log "Creating initial /etc/motd ..."
     local mk_script=$( mktemp -p /tmp "mk_create_motd.XXXXXXXXXX.ksh" )
     wget -O "${mk_script}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${url}"
-    ksh "${mk_script}" -i 192.168.88.0/23 \
-                       -p "Template VM" \
-                       -l "L105 VMWare" \
-                       -h "VM x86_64" \
-                       -o "Pixelpark GmbH" > /etc/motd
+    chmod 0755 "${mk_script}"
+    "${mk_script}" -i 192.168.88.0/23 \
+                   -p "Template VM" \
+                   -l "L105 VMWare" \
+                   -h "VM x86_64" \
+                   -o "Pixelpark GmbH" > /etc/motd
     rm -fv "${mk_script}"
 
 }
@@ -497,6 +504,90 @@ dist_upgrade() {
 
 }
 
+#-----------------------------------------------------------
+install_puppet() {
+
+    local pplabs_conf_dir="/etc/puppetlabs"
+    local puppet_conf_dir="${pplabs_conf_dir}/puppet"
+    local puppet_conf_file="${puppet_conf_dir}/puppet.conf"
+    local facter_conf_dir="${pplabs_conf_dir}/facter/facter.d"
+
+    echo
+    log "Installing Puppet agent ..."
+    echo
+
+    echo "Creating group puppet ..."
+    groupadd -g 63000 puppet
+    getent group puppet
+
+    echo "Creating user puppet ..."
+    useradd -u 63000 -g puppet -d /var/lib/puppet -c "Puppet configuration management" -s /sbin/nologin puppet
+    getent passwd puppet
+    id puppet
+
+    echo
+    echo "Installing puppet package ..."
+    yum install -y puppet-agent
+
+    echo
+    echo "Creating config dirs ..."
+    mkdir -pv "${puppet_conf_dir}" "${facter_conf_dir}"
+
+    echo
+    echo "Creating ${puppet_conf_file} ..."
+    cat <<-EOF >"${puppet_conf_file}"
+       [main]
+           ca_ttl = 10y
+       [agent]
+           # The file in which puppetd stores a list of the classes
+           # associated with the retrieved configuratiion.  Can be loaded in
+           # the separate "puppet" executable using the "--loadclasses"
+           # option.
+           # The default value is '\$confdir/classes.txt'.
+           classfile = \$vardir/classes.txt
+
+           environment  = production
+           report       = true
+           pluginsync   = true
+           splay        = true
+           use_srv_records  = true
+           srv_domain       = pixelpark.info
+           pluginsource     = puppet:///plugins
+           pluginfactsource = puppet:///pluginfacts
+
+       EOF
+
+    echo
+    echo "Creating ${facter_conf_dir}/customer.yaml"
+    cat <<-EOF >"${facter_conf_dir}/customer.yaml"
+       ---
+       customer: pixelpark
+       EOF
+
+    echo
+    echo "Creating ${facter_conf_dir}/host"
+    cat <<-EOF >"${facter_conf_dir}/host"
+       ---
+       pp_purpose: Unknown
+       pp_location: L105
+       pp_owner: Pixelpark AG
+       pp_contact: 8x5@pixelpark.com
+       pp_zonehost: Unknown
+       EOF
+
+    echo
+    echo "Creating ${facter_conf_dir}/tier.yaml"
+    cat <<-EOF >"${facter_conf_dir}/tier.yaml"
+       ---
+       tier: production
+       EOF
+
+    echo
+    echo "Enabling service puppet ..."
+    systemctl enable pappet
+
+}
+
 #-----------------------------------------------------------
 main() {
 
@@ -517,6 +608,7 @@ main() {
     install_ntp
     install_openvm_tools
     dist_upgrade
+    install_puppet
 
     tweak_grub