A glimpse into Solaris 11.2 specific Puppet components

Now you have a working Puppet testbed in your Solaris 11.2 beta installation it’s time to try some Solaris specific stuff. Oracle a number of additional stuff in order to control Solaris specifics like boot environments, VNICs or SMF. You can find the respective code at java.net.

The examples from Manuels blog entry

Let’s try at first the puppet commands Manuel Zach wrote about in his blog a few days ago in his blog I added some lines to my nodes.pp from the last article. I want to install tmux and introduce an zfs quota on the pool/export dataset

root@master:/etc/puppet/manifests# cat nodes.pp
import 'etchosts'

node 'default' {
 include etchosts
}

node 'agent3.puppet.c0t0d0s0' {
 include etchosts
 zfs { 'rpool/export':
  quota  => '1G',
 }
 package { 'tmux':
  ensure  => 'present',
 }
}

When you try this on agent3, the puppet agent will set the quota and install the package.

root@agent3:~# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for agent3.puppet.c0t0d0s0.org
Info: Applying configuration version '1400838109'
Notice: /Stage[main]/Main/Node[agent3.puppet.c0t0d0s0]/Zfs[rpool/export]/quota: quota changed 'none' to '1G'
Notice: /Stage[main]/Main/Node[agent3.puppet.c0t0d0s0]/Package[tmux]/ensure: created
Notice: Finished catalog run in 21.76 seconds
root@agent3:~#

Try the same on agent1 and nothing will happen. Obviously, we’ve limited it by configuration to agent3. Would be a problem if the system would behave otherwise :)

root@agent1:~# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for agent1.puppet.c0t0d0s0.org
Info: Applying configuration version '1400838109'
Notice: Finished catalog run in 0.33 seconds
root@agent1:~#

Let’s add the creation of a boot environment and put it in the default node:

import 'etchosts'

node 'default' {
 include etchosts
  boot_environment { 'solaris-beforepuppet':
  description => 'creating a backup of the bootenvironment',
  ensure => 'present',
}
}

node 'agent3.puppet.c0t0d0s0' {
 include etchosts
 zfs { 'rpool/export':
  quota  => '1G',
}

package { 'tmux':
  ensure  => 'present',
}

}

However, when executing it on agent3 nothing will happen.

root@agent3:~# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for agent3.puppet.c0t0d0s0.org
Info: Applying configuration version '1400845195'
Notice: Finished catalog run in 2.49 seconds

This is a nice example what is meant with my comment that the default node doesn’t define whats done on each node by default, but what is done on a node that doesn’t have it’s own definition of things to do. In order to execute it on each node, remove it from the default node. I’ve put it just in the site.pp like:

root@master:/etc/puppet/manifests# cat site.pp
boot_environment { 'solaris-beforepuppet':
  description => 'creating a backup of the bootenvironment',
  ensure => 'present',
}

import 'nodes.pp'

When you now trigger it manually on agent3, you see that now the boot environment is created by Puppet.

root@agent3:~# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for agent3.puppet.c0t0d0s0.org
Info: Applying configuration version '1400845435'
Notice: /Stage[main]/Main/Boot_environment[solaris-beforepuppet]/ensure: created
Notice: Finished catalog run in 4.08 seconds

Let’s repeat it on agent1

root@slave1:~# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for agent1.puppet.c0t0d0s0.org
Info: Applying configuration version '1400846294'
Notice: /Stage[main]/Main/Boot_environment[solaris-beforepuppet]/ensure: created
Notice: Finished catalog run in 1.92 seconds

Changing DNS

Another example is changing the DNS server by puppet, for example when you want to migrate 300 zones from one DNS server to another. Simply add the necessary statements to the site.pp

root@master:/etc/puppet/manifests# cat site.pp
boot_environment { 'solaris-beforepuppet':
  description => 'creating a backup of the bootenvironment',
  ensure => 'present',
}

dns { 'Google Nameserver':
 nameserver => '8.8.8.8',
 search => 'puppet.c0t0d0s0.org'
}
import 'nodes.pp'

Now trigger puppet on on of the servers - for example agent3 and check the correct DNS configuration:

root@sagent3:~# puppet agent --test
Info: Retrieving plugin
Info: Caching catalog for agent3.puppet.c0t0d0s0.org
Info: Applying configuration version '1400846900'
Notice: /Stage[main]/Main/Dns[Google Nameserver]/nameserver: nameserver changed '8.8.8.8' to '8.8.8.8'
Notice: /Stage[main]/Main/Dns[Google Nameserver]/search: search changed '' to 'puppet.c0t0d0s0.org'
Notice: Finished catalog run in 3.76 seconds
root@agent3:~# nslookup www.c0t0d0s0.org
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   www.c0t0d0s0.org
Address: 178.63.69.146

Conclusion

As indicated by the link to java.net there are a lot more available providers, but that is stuff for more blog entries