Posted over 8 years ago
Vagrant plugin: vagrant-puppetconf |
Our puppet setup has slightly different configs depending on what environments (test, staging, and production) we are provisioning a server in. We key our config settings for each environment off the puppet ‘environment’ config in puppet.conf.
An example puppet.conf
[main]
environment=test
The issue is that we want our vagrant box to be able to assume the configs for any environment. For example, during development, we may want to provision a web server for the test environment, then switch it to staging, and make sure the changes that we expect are actually applied.
The workflow for doing this prior to vagrant-puppetconf was…
$ vagrant up --no-provision
$ vagrant ssh
$ vi /etc/puppet/puppet.conf #update the environment config
$ exit
$ vagrant provision
Introducing vagrant-puppetconf
vagrant-puppetconf is a vagrant plugin that allows setting puppet.conf config values from your Vagrantfile. Using this plugin, the workflow becomes…
$ vi Vagrantfile #edit the puppetconf environment config
$ vagrant up
Check out the project on Github for more information.
Other stuff I learned
augtool
augtool is a convenience tool for updating config files. It uses an xpath-like syntax for identifying config keys and setting/updating/viewing their values. It can be invoked via the command line, and also has API bindings for several programming languages including, ruby, puppet, and C.
ow to use augtool (command line):
$ cat /etc/puppet/puppet.conf
[main]
environment=test
$ echo -e "set /files/etc/puppet/puppet.conf/main/environment test \n save" | sudo augtool -b
$ diff /etc/puppet/puppet.conf /etc/puppet/puppet.conf.augsave
10c10
< environment=test
---
> environment=production
$ cat /etc/puppet/puppet.conf
[main]
environment=test