<commit_before># About  
This is a bleeding edge playground repository to get more familiar with Puppet 4, future parser, cfacter, PuppetDB 3, MCollective and puppetserver 2.  
It is intended to be a quick way to spawn up a fully working Puppet 4 environment.  
It will automatically install the latest version of the full above stack.  
If it breaks because of a new version, let me know and I'll try to fix it.  

In the Vagrantfile there are 2 VMs defined.  
A puppetserver ("puppet") and a puppet node ("node1") both running CentOS 7.0.  
Classes get configured via hiera (see `code/environments/production/hieradata/*`).  

# Requirements
I'm using Vagrant 1.7.3 and VirtualBox as the provisioner.  
I'm running this on Mac OS X but it should also run on other operating systems, but I haven't tested it.  
Older versions of Vagrant are not supported, as Puppet 4 support was only [added in 1.7.3](https://github.com/mitchellh/vagrant/issues/3740) 

Also tested and working on: SLES 11.3, VirtualBox-4.3-4.3.28_100309_sles11.0-1.  

The puppetserver VM is configured to use 3GB of RAM.  
The node is using the default (usually 512MB).  

# Usage
After cloning the repository make sure the submodules are also updated:  
```
$ git clone https://github.com/roman-mueller/puppet4-sandbox
$ cd puppet4-sandbox
$ git submodule update --init --recursive
```

Whenever you `git pull` this repository you should also update the submodules again.  

Now you can simply run `vagrant up puppet` to get a fully set up puppetserver.  
The `code/` folder will be a synced folder and gets mounted to `/etc/puppetlabs/code` inside the VM.  

If you want to attach a node to the puppetserver simply run `vagrant up node1`.  
Once provisioned you only need to sign the certificate request on the puppetserver.  
For that login to the puppet VM (`vagrant ssh puppet`).  
Then check the queued certificate requests and sign it:  
```
[vagrant@puppet ~]$ sudo /opt/puppetlabs/bin/puppet cert list
  "node1" (SHA256) E3:97:CE:74:78:0E:77:1C:9C:97:AC:77:BC:4B:27:19:9D:7F:6D:B1:7F:18:07:7A:DA:B8:77:D7:2F:15:4D:42
[vagrant@puppet ~]$ sudo /opt/puppetlabs/bin/puppet cert sign node1
Notice: Signed certificate request for node1
Notice: Removing file Puppet::SSL::CertificateRequest node1 at '/etc/puppetlabs/puppet/ssl/ca/requests/node1.pem'
```
After that puppet will run automatically every 30 minutes on the node and apply your changes.  
You can also run it manually:  
```
$ vagrant ssh node1
[vagrant@node1 ~]$ sudo /opt/puppetlabs/bin/puppet agent -t
Info: Caching certificate for node1
Info: Caching certificate_revocation_list for ca
Info: Caching certificate for node1
Info: Retrieving pluginfacts
Info: Retrieving plugin
(...)
Notice: Applied catalog in 0.52 seconds
```

PuppetDB gets installed and started by default.  
The local port 8080 gets forwarded to the Vagrant VM to port 8080.  
So you can access the PuppetDB dashboard via http://127.0.0.1:8080/dashboard/index.html.  
All necessary keys get created when it starts for the first time.  
The puppetserver is configured to store reports in the DB, so you can start playing with that too right away.  

Also MCollective gets installed and configured.  
It should also work out of the box, also node1 will register after the initial Puppet run:  
```
[root@puppet vagrant]# /opt/puppetlabs/bin/mco ping
node1                                    time=29.86 ms
puppet                                   time=67.98 ms


---- ping statistics ----
2 replies max: 67.98 min: 29.86 avg: 48.92 
```

# Hacks
I wrote a shell provisioner ("puppetupgrade.sh") which updates `puppet-agent` before running it for the first time.  
That way newly spawned Vagrant environments will always use the latest available version.  

There is no DNS server running in the private network.  
All nodes have each other in their `/etc/hosts` files.  

Starting the puppetserver sometimes hits the systemd timeout (https://tickets.puppetlabs.com/browse/SERVER-557).  
To work around this, the file `/etc/systemd/system/puppetserver.service.d/local.conf` gets created which overrides the timeout and sets it to 500 seconds.
<commit_msg>Clarify MCollective module usage<commit_after># About  
This is a bleeding edge playground repository to get more familiar with Puppet 4, future parser, cfacter, PuppetDB 3, MCollective and puppetserver 2.  
It is intended to be a quick way to spawn up a fully working Puppet 4 environment.  
It will automatically install the latest version of the full above stack.  
If it breaks because of a new version, let me know and I'll try to fix it.  

In the Vagrantfile there are 2 VMs defined.  
A puppetserver ("puppet") and a puppet node ("node1") both running CentOS 7.0.  
Classes get configured via hiera (see `code/environments/production/hieradata/*`).  

# Requirements
I'm using Vagrant 1.7.3 and VirtualBox as the provisioner.  
I'm running this on Mac OS X but it should also run on other operating systems, but I haven't tested it.  
Older versions of Vagrant are not supported, as Puppet 4 support was only [added in 1.7.3](https://github.com/mitchellh/vagrant/issues/3740) 

Also tested and working on: SLES 11.3, VirtualBox-4.3-4.3.28_100309_sles11.0-1.  

The puppetserver VM is configured to use 3GB of RAM.  
The node is using the default (usually 512MB).  

# Usage
After cloning the repository make sure the submodules are also updated:  
```
$ git clone https://github.com/roman-mueller/puppet4-sandbox
$ cd puppet4-sandbox
$ git submodule update --init --recursive
```

Whenever you `git pull` this repository you should also update the submodules again.  

Now you can simply run `vagrant up puppet` to get a fully set up puppetserver.  
The `code/` folder will be a synced folder and gets mounted to `/etc/puppetlabs/code` inside the VM.  

If you want to attach a node to the puppetserver simply run `vagrant up node1`.  
Once provisioned you only need to sign the certificate request on the puppetserver.  
For that login to the puppet VM (`vagrant ssh puppet`).  
Then check the queued certificate requests and sign it:  
```
[vagrant@puppet ~]$ sudo /opt/puppetlabs/bin/puppet cert list
  "node1" (SHA256) E3:97:CE:74:78:0E:77:1C:9C:97:AC:77:BC:4B:27:19:9D:7F:6D:B1:7F:18:07:7A:DA:B8:77:D7:2F:15:4D:42
[vagrant@puppet ~]$ sudo /opt/puppetlabs/bin/puppet cert sign node1
Notice: Signed certificate request for node1
Notice: Removing file Puppet::SSL::CertificateRequest node1 at '/etc/puppetlabs/puppet/ssl/ca/requests/node1.pem'
```
After that puppet will run automatically every 30 minutes on the node and apply your changes.  
You can also run it manually:  
```
$ vagrant ssh node1
[vagrant@node1 ~]$ sudo /opt/puppetlabs/bin/puppet agent -t
Info: Caching certificate for node1
Info: Caching certificate_revocation_list for ca
Info: Caching certificate for node1
Info: Retrieving pluginfacts
Info: Retrieving plugin
(...)
Notice: Applied catalog in 0.52 seconds
```

PuppetDB gets installed and started by default.  
The local port 8080 gets forwarded to the Vagrant VM to port 8080.  
So you can access the PuppetDB dashboard via http://127.0.0.1:8080/dashboard/index.html.  
All necessary keys get created when it starts for the first time.  
The puppetserver is configured to store reports in the DB, so you can start playing with that too right away.  

Also MCollective gets installed and configured.  
It should also work out of the box, also node1 will register after the initial Puppet run:  
```
[root@puppet vagrant]# /opt/puppetlabs/bin/mco ping
node1                                    time=29.86 ms
puppet                                   time=67.98 ms


---- ping statistics ----
2 replies max: 67.98 min: 29.86 avg: 48.92 
```

# Hacks
I use a MCollective module provided by camptocamp which they decided to discontinue.  
I plan to migrate this to another module in the future, but at the moment it uses my fork of that module.

I wrote a shell provisioner ("puppetupgrade.sh") which updates `puppet-agent` before running it for the first time.  
That way newly spawned Vagrant environments will always use the latest available version.  

There is no DNS server running in the private network.  
All nodes have each other in their `/etc/hosts` files.  

Starting the puppetserver sometimes hits the systemd timeout (https://tickets.puppetlabs.com/browse/SERVER-557).  
To work around this, the file `/etc/systemd/system/puppetserver.service.d/local.conf` gets created which overrides the timeout and sets it to 500 seconds.

{'fraction_non_alphanumeric': 0.07540752902544857, 'fraction_numerical': 0.035182361909229506, 'mean_word_length': 3.791011235955056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1905464', 'n_tokens_mistral': 2871, 'n_tokens_neox': 2620, 'n_words': 1136}