Created
July 6, 2014 21:11
-
-
Save jtopjian/095ccb31eda4132de30a to your computer and use it in GitHub Desktop.
Third revision of puppet master bootstrap script
This file contains hidden or 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
| #!/bin/bash | |
| echo "Installing curl and wget" | |
| apt-get update | |
| apt-get install -y curl wget | |
| echo "Installing the PuppetLabs apt repo" | |
| cd /root | |
| wget https://apt.puppetlabs.com/puppetlabs-release-trusty.deb | |
| dpkg -i puppetlabs-release-trusty.deb | |
| rm puppetlabs-release-trusty.deb | |
| apt-get update | |
| echo "Installing Puppet, Rake, Ruby 1.9" | |
| apt-get install -y git rake ruby puppet | |
| mkdir -p /etc/facter/facts.d | |
| echo "Initial changes to puppet.conf" | |
| sed -i '/templatedir/d' /etc/puppet/puppet.conf | |
| puppet config set --section main parser future | |
| puppet config set --section main evaluator current | |
| puppet config set --section main ordering manifest | |
| echo "Checking if SSL cert exists." | |
| echo "and generating one if it doesnt." | |
| if [ ! -e "$(puppet config print hostcert)" ]; then | |
| puppet cert generate $(puppet config print certname) | |
| fi | |
| echo "Installing PuppetDB" | |
| cd /root | |
| wget -O puppetdb.tar.gz https://github.com/puppetlabs/puppetlabs-puppetdb/archive/master.tar.gz | |
| puppet module install puppetdb.tar.gz | |
| rm puppetdb.tar.gz | |
| echo include puppetdb > pdb.pp | |
| echo include puppetdb::master::config >> pdb.pp | |
| puppet apply --verbose pdb.pp | |
| rm pdb.pp | |
| rm -rf /etc/puppet/modules/* | |
| echo "Setting up Directory Environments" | |
| PROD="/etc/puppet/environments/production" | |
| SITE="${PROD}/modules/site" | |
| puppet config set --section main environmentpath \$confdir/environments | |
| mkdir -p $PROD/{modules,manifests} | |
| mkdir -p $SITE/{files,templates,manifests,ext,data} | |
| mkdir $SITE/manifests/{roles,profiles} | |
| mv /etc/puppet/puppet.conf $SITE/ext | |
| ln -s $SITE/ext/puppet.conf /etc/puppet | |
| echo "Installing puppet-librarian-simple" | |
| mkdir /root/dev | |
| cd /root/dev | |
| git clone https://github.com/bodepd/librarian-puppet-simple | |
| cd librarian-puppet-simple | |
| gem build librarian-puppet-simple.gemspec | |
| gem install librarian-puppet-simple-0.0.3.gem | |
| echo "Configuring Hiera" | |
| gem install deep_merge | |
| cat > $SITE/ext/hiera.yaml <<EOF | |
| --- | |
| :backends: | |
| - yaml | |
| :hierarchy: | |
| - "nodes/%{::fqdn}" | |
| - "osfamily/%{::osfamily}" | |
| - "locations/%{::location}" | |
| - "common" | |
| :yaml: | |
| :datadir: "/etc/puppet/environments/%{::environment}/modules/site/data" | |
| EOF | |
| mkdir $SITE/data/nodes | |
| mkdir $SITE/data/locations | |
| ln -s $SITE/ext/hiera.yaml /etc/puppet | |
| rm /etc/hiera.yaml | |
| ln -s $SITE/ext/hiera.yaml /etc | |
| echo "Creating a Puppetfile" | |
| cat > $SITE/ext/Puppetfile <<EOF | |
| forge 'http://forge.puppetlabs.com' | |
| mod 'apache', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-apache' | |
| mod 'apt', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-apt', | |
| :ref => '1.5.0' | |
| mod 'vcsrepo', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-vcsrepo', | |
| :ref => '1.0.2' | |
| mod 'concat', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-concat', | |
| :ref => '1.1.0' | |
| mod 'ntp', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-ntp', | |
| :ref => '3.1.1' | |
| mod 'puppetdb', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-puppetdb' | |
| mod 'postgresql', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-postgresql', | |
| :ref => '3.3.3' | |
| mod 'stdlib', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-stdlib', | |
| :ref => '4.2.2' | |
| mod 'inifile', | |
| :git => 'https://github.com/puppetlabs/puppetlabs-inifile', | |
| :ref => '1.0.4' | |
| mod 'puppet', | |
| :git => 'https://github.com/jtopjian/puppet-puppet' | |
| EOF | |
| ln -s $SITE/ext/Puppetfile $PROD | |
| echo "Running the Puppetfile" | |
| cd $PROD | |
| librarian-puppet install | |
| echo "Configuring the Puppet Master" | |
| cat > $SITE/manifests/roles/base.pp <<EOF | |
| class site::roles::base { | |
| } | |
| EOF | |
| mkdir -p $SITE/manifests/profiles/puppet | |
| mkdir -p $SITE/manifests/roles/puppet | |
| cat > $SITE/manifests/profiles/puppet/master.pp <<EOF | |
| class site::profiles::puppet::master { | |
| include ::apache | |
| include ::apache::mod::ssl | |
| include ::apache::mod::passenger | |
| include ::puppet | |
| include ::puppet::master | |
| include ::puppetdb | |
| include ::puppetdb::master::config | |
| } | |
| EOF | |
| cat > $SITE/manifests/roles/puppet/master.pp <<EOF | |
| class site::roles::puppet::master { | |
| include site::profiles::puppet::master | |
| } | |
| EOF | |
| fqdn=$(facter fqdn) | |
| cat > $SITE/data/common.yaml <<EOF | |
| puppet::settings: | |
| server: '${fqdn}' | |
| environmentpath: '\$confdir/environments' | |
| parser: 'future' | |
| evaluator: 'current' | |
| ordering: 'manifest' | |
| pluginsync: true | |
| logdir: '/var/log/puppet' | |
| vardir: '/var/lib/puppet' | |
| ssldir: '/var/lib/puppet/ssl' | |
| rundir: '/var/run/puppet' | |
| puppet::agent::settings: | |
| certname: "%{::fqdn}" | |
| show_diff: true | |
| splay: false | |
| configtimeout: 360 | |
| usecacheonfailure: true | |
| report: true | |
| environment: "%{::environment}" | |
| EOF | |
| cat > $SITE/data/nodes/${fqdn}.yaml <<EOF | |
| puppet::master::servertype: 'passenger' | |
| puppet::master::settings: | |
| ca: true | |
| EOF | |
| cat > $SITE/ext/site.pp <<EOF | |
| node base { | |
| include site::roles::base | |
| } | |
| node '${fqdn}' inherits base { | |
| include site::roles::puppet::master | |
| } | |
| EOF | |
| ln -s $SITE/ext/site.pp $PROD/manifests/ | |
| puppet apply --verbose /etc/puppet/environments/production/manifests/site.pp | |
| echo "Running puppet agent" | |
| puppet agent -t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment