Skip to content

Instantly share code, notes, and snippets.

@scarcry
Created April 28, 2015 11:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scarcry/b9fe26ad4f277f3ed84e to your computer and use it in GitHub Desktop.
Save scarcry/b9fe26ad4f277f3ed84e to your computer and use it in GitHub Desktop.
SmartOS puppet master bootstrap script
#!/bin/bash
# Populate ssh logins
cat <<EOF > /root/.ssh/authorized_keys
ssh-dss AAAAB3NzaC1kc3MAAACBAPasbrS7os8JmWaWidjRHmmz8cAJqS/hU8UC1ROue3+9pGBj/47zNSaoA3kJlx97SCO13jWzrye2H5tGnh6OGDBGuYRWJjG8SuRkceGFA8JE1gcBeZuLPN9hqr5VEY/d2nI2rM/icidYrOdhkV0HCfJpsDPbUNScouGX9myRN797AAAAFQDDn7jm/UYzAy0PqiqQkTpHVoJqxQAAAIEAoPy77TXCLtdnMt5Sw7n0diNhjtxEi1uq9saMDP4mIA8FPjoCK+8ZeEM7fiNCRo640l/B4hBAlx91TZyuLv7Fb5ZkCDl4XFnTxMU973rZfeQscKl3+6o9WkZvwTrNpLuKK2SVEcm1PD+bc1rvRtprfV51D7UXOk36vAftDb255qgAAACBAKx8jYblG2zzxfnGDI53wsBg4NERicC8KOJrHRieYx/nGRvdjKqTxzUwCLDs9lyzXSTQ6F+39A8ZBmOsenR45kmMOxYACdkYZ3zvgAMPBzYxSWZPZzXKWTncwzdoNK1TBGs9TJymHnIfYWDgVc29zj5BcpsB/6w28esFTt8Y0Peo root@scarlett.fritz.box
ssh-dss AAAAB3NzaC1kc3MAAACBANx/e9caQoJIKgmvln9yGivn/722YGQWOqc1iwCs2lWytTxe3gCcliQoc/685KUcyeO/DubLYnUU7hqIeT3GPzDfcJh3AQIogyhXUg6j5uxXlfV9nqAmRsVHbvEWZ+kAAiI/9lDhZ7TAkRtg23E+oU2YRFXKHaz4nSQVzrnQHOelAAAAFQC+z8D8W0fHXG4iq7srPqTDvChe4QAAAIA8/Mn0alAKrAfhUKhzMOhdyuD1OqNYCdtvrlt6Qf7VZ5/f00TxN/BfDoaQpF4/VLjdLvEGcQWgr0b9nFaJhHhVY43vwAYPuOeHp0wI3YnIGtZR+EXHFf58Zqt5O9pf8VM7lJXV0tCkU5TP3DgQj6TvRiNkCKFbL2JoQC6xysrJFQAAAIBdsALbhqf6XVhA9HEIcke0WVD0i61n36pf/bsladWPGFzyCIVeAB9XBu1+7n7eqe/EqV4oQ9L+hkPkE1zXfHMpFJC3LLbINnXJwZuYT6p72NHv9Mg1URuLwO99HEtq7LHplup82+y3WM1w/HRzO9YmNIhKCr24X4grDOqsjkEELw== marcovl@irssi
EOF
# setup IPv6
/usr/sbin/svccfg import /opt/setup-v6/etc/setup-v6.xml
svcadm enable ndp
# For installation of puppet by gem for smartos
RUBY=ruby193
PUPPETVERSION=3.7.4
# install ruby
pkgin -y in ${RUBY}
echo "attempting the puppet install via ruby gem"
gem install --no-ri --no-rdoc --version=${PUPPETVERSION} puppet
echo "let's ensure the puppet user and group is created"
puppet resource group puppet ensure=present
puppet resource user puppet ensure=present gid=puppet shell='/bin/false'
echo "we'll use the deep_merge behaviour for hiera so let's install the deep_merge gem"
gem install --no-ri --no-rdoc deep_merge
echo "let's create and populate our puppet.conf in /etc/puppet"
cat <<EOF > /etc/puppet/puppet.conf
[main]
dns_alt_names = puppet1,puppet1.fritz.box,puppet1.lordsith.net
logdir = /var/log/puppet
[master]
always_cache_features = true
autosign = true
[agent]
server = puppet1.fritz.box
EOF
echo "let's create and populate our hiera.yaml in /etc/puppet"
cat <<EOF > /etc/puppet/hiera.yaml
---
:backends:
- yaml
:hierarchy:
- "role/%{role}"
- "os/%{operatingsystem}"
- common
:yaml:
:datadir: '/var/lib/hiera'
# We add the deeper merge behaviour by default but it will only be enabled
# if the ruby gem deep_merge is installed
:merge_behaviour:
- deeper
EOF
echo "curl the SMF puppet master method and manifest files"
cd /opt/local/lib/svc/method ; curl -LO http://dl1.lordsith.net/SmartOS/smf/manifests/puppet/method/svc-puppetmasterd
cd /var/svc/manifest/ ; curl -LO http://dl1.lordsith.net/SmartOS/smf/manifests/puppet/manifest/puppetmasterd.xml
echo "import the SMF puppet master manifest"
chmod 0755 /opt/local/lib/svc/method/svc-puppetmasterd
/usr/sbin/svccfg import /var/svc/manifest/puppetmasterd.xml
echo "with all files in place, let's generate the CA certificate and the puppet master certificate, with the appropriate DNS names included by enabling the SMF puppet master service."
/usr/sbin/svcadm enable puppetmasterd
echo "and finally let's do a puppet agent run to talk to this local master"
puppet agent -t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment