Puppet - vghn/docs GitHub Wiki

Puppet

1.1. Control Repo

# Check newest modules
ber puppet:puppetfile_inspect

# Update fixtures from Puppetfile
ber puppet:generate_fixtures # DEPRECATED in favour of r10k

# Update modules from Puppetfile
ber puppet:r10k_install_modules

# Complete acceptance command
BEAKER_PUPPET_COLLECTION=puppet \
BEAKER_destroy=onpass \
BEAKER_provision=yes \
BEAKER_debug=yes \
BEAKER_set=docker_bionic \
BEAKER_class=role::none \
bundle exec rake puppet:integration

# If BEAKER_destroy=no the container/image stays on for further debugging:
docker exec -it $(dl) /opt/puppetlabs/bin/puppet apply --test -e 'include ::role::none'
# OR
vagrant global-status && vagrant ssh XX
sudo /opt/puppetlabs/bin/puppet apply --test -e 'include ::role::none'

1.2. Agent

Note: Might need to run apt-get update!

docker run --rm -it \
  --link puppet:puppet \
  -v /tmp/puppet/cache:/opt/puppetlabs/puppet/cache \
  vladgh/puppet agent --test --report --summarize

Create a CSR file

cat > /tmp/csr_attributes.yaml <<CSR
custom_attributes:
  challengePassword: 'myProjectPassword'
extension_requests:
  pp_role: 'none'
  pp_project: 'myProject'
  pp_application: 'testapp'
  pp_instance_id: 'i-12345678'
  pp_image_name: 'ami-12345678'
CSR

docker run --rm -it \
  --link puppet:puppet \
  -v /tmp/csr_attributes.yaml:/etc/puppetlabs/puppet/csr_attributes.yaml \
  -v /tmp/puppet/cache:/opt/puppetlabs/puppet/cache \
  vladgh/puppet agent --test --report --summarize

1.3. Server

Simple puppet server with autosign and the control repo mounted directly in production

( cd puppet; r10k puppetfile install --verbose )
docker run --rm -it --name puppet -p 8140:8140 -e AUTOSIGN=true -v $(pwd)/puppet:/etc/puppetlabs/code/environments/production vladgh/puppetserver

Puppet server with defined autosign config, with the control repo mounted directly in production

( cd puppet; r10k puppetfile install --verbose )
( cd docker_images; ber docker:ps:build )
docker run --rm -it --name puppet -p 8140:8140 -e AUTOSIGN=/ps/csr-sign -e AUTOSIGN_CFG=/ps/csr_config.yaml.sample -v ~/.aws:/opt/puppetlabs/server/data/puppetserver/.aws -v $(pwd)/docker_images/ps:/ps -v $(pwd)/puppet:/etc/puppetlabs/code/environments/production vladgh/ps

1.4. DB

Dashboard tunnel

ssh rhea -L 8080:localhost:8080

Migrate databases

brew install postgresql
pg_dump -C -h abcd.efgh.us-east-1.rds.amazonaws.com -U vgh puppetdb > /tmp/backup_puppetdb.pgsql
psql -h abcd.efgh.us-east-1.rds.amazonaws.com -U vgh puppetdb < /tmp/backup_puppetdb.pgsql

1.5. CA

On the puppet server (RHEA), where vpm_server_1 is the Puppet Server container

docker exec vpm_server_1 puppet cert list --all

1.6. Update

MacOS

updt

Mini

sudo apt-get -y update && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove --purge
( cd mini; /bin/update ) # Upgrade containers

Rhea

sudo apt-get -y update && sudo apt-get -y dist-upgrade && sudo apt-get -y autoremove --purge