| LEFT | RIGHT |
| 1 Adblock Plus infrastructure | 1 Adblock Plus infrastructure |
| 2 =========================== | 2 =========================== |
| 3 | 3 |
| 4 The Adblock Plus infrastructure uses [Puppet](http://puppetlabs.com/) | 4 The Adblock Plus infrastructure uses [Puppet](http://puppetlabs.com/) |
| 5 to set up servers, and to have a realistic development environment. | 5 to set up servers, and to have a realistic development environment. |
| 6 | 6 |
| 7 Our Puppet manifests are only tested with Ubuntu 12.04 right now. | 7 Our Puppet manifests are only tested with Ubuntu 12.04 right now. |
| 8 | 8 |
| 9 Host specific setup | 9 Environment specific setup |
| 10 ------------------- | 10 -------------------------- |
| 11 | 11 |
| 12 Some infrastructure parts are specific to the environment (such as e.g. | 12 Some infrastructure parts are specific to the environment (such as e.g. |
| 13 *development*, *test* and *production*) whilst passwords, for example, | 13 *development*, *test* and *production*) whilst passwords, for example, |
| 14 are confidential. In order to allow for such specific configuration, the | 14 are confidential. In order to allow for such specific configuration, the |
| 15 repository requires a set of manual operations during the initial setup: | 15 repository requires a set of manual operations during the initial setup: |
| 16 | 16 |
| 17 ### `modules/private` | 17 ### `modules/private` |
| 18 | 18 |
| 19 The `private` module is destined to store confidential information such as | 19 The `private` module is destined to store confidential information such as |
| 20 [RSA](http://en.wikipedia.org/wiki/RSA_%28cryptosystem%29) keys, `htpasswd` | 20 [RSA](http://en.wikipedia.org/wiki/RSA_%28cryptosystem%29) keys, `htpasswd` |
| 21 files and so on. The repository provides a `private-stub` module containing | 21 files and so on. The repository provides a `private-stub` module containing |
| 22 defaults suitable for development and testing purpose. One can create a | 22 defaults suitable for development and testing purposes. One can create a |
| 23 symbolic link to start using the resource: | 23 symbolic link to start using the resource: |
| 24 | 24 |
| 25 # UNIX-oid | 25 #### UNIX-like |
| 26 user@host:~/infrastructure$ ln -s private-stub modules/private | 26 |
| 27 | 27 ln -s private-stub modules/private |
| 28 # Windows | 28 |
| 29 C:\infrastructure\> MKLINK /D modules\private private-stub | 29 #### Windows |
| 30 |
| 31 MKLINK /D modules\private private-stub |
| 30 | 32 |
| 31 When creating a custom version, one may inspect the `modules/private-stub` | 33 When creating a custom version, one may inspect the `modules/private-stub` |
| 32 directory to determine which resources have to be provided. | 34 directory to determine which resources have to be provided. |
| 33 | 35 |
| 34 ### `hiera/environment` | 36 ### `hiera/private` |
| 35 | 37 |
| 36 [Hiera](https://docs.puppetlabs.com/hiera/1/) configuration files specific | 38 Analogous to `modules/private`, [Hiera](https://docs.puppetlabs.com/hiera/1/) |
| 37 to the current environment are expected to be found in `hiera/environment`. | 39 configuration files specific to the current environment are expected to be |
| 38 Default resources for development (and testing) purpose are provided within | 40 found in `hiera/private`. Default resources for development (and testing) |
| 39 `hiera/development`: | 41 purposes are provided within `modules/private-stub/hiera`: |
| 40 | 42 |
| 41 # UNIX-oid | 43 #### UNIX-like |
| 42 user@host:~/infrastructure$ ln -s development hiera/environment | 44 |
| 43 | 45 ln -s ../modules/private-stub/hiera hiera/private |
| 44 # Windows | 46 |
| 45 C:\infrastructure\> MKLINK /D hiera\environment development | 47 #### Windows |
| 48 |
| 49 MKLINK /D ..\modules\private-stub\hiera hiera\private |
| 46 | 50 |
| 47 Note that custom versions are recommended to be tracked together with the | 51 Note that custom versions are recommended to be tracked together with the |
| 48 custom `private` module, if any. | 52 custom `private` module, if any. |
| 49 | 53 |
| 50 Development environment | 54 Development environment |
| 51 ----------------------- | 55 ----------------------- |
| 52 | 56 |
| 53 As with our other projects, all changes to our infrastructure should | 57 As with our other projects, all changes to our infrastructure should |
| 54 be made in a local development environment, and reviewed before | 58 be made in a local development environment, and reviewed before |
| 55 deployment. Thanks to Puppet, we can easily set up local VMs that | 59 deployment. Thanks to Puppet, we can easily set up local VMs that |
| 56 mirror our production environment. | 60 mirror our production environment. |
| 57 | 61 |
| 58 The most convenient way to do this is to use Vagrant, as described | 62 The most convenient way to do this is to use Vagrant, as described |
| 59 below. | 63 below. |
| 60 | 64 |
| 61 ### Requirements | 65 ### Requirements |
| 62 | 66 |
| 63 * [VirtualBox](https://www.virtualbox.org/) | 67 * [VirtualBox](https://www.virtualbox.org/) |
| 64 * [Vagrant](http://vagrantup.com/) | 68 * [Vagrant](http://vagrantup.com/) |
| 65 * _modules/private_ exists (see above) | 69 * Both `modules/private` and `hiera/private` exist (see above) |
| 66 | 70 |
| 67 ### Start a VM | 71 ### Start a VM |
| 68 | 72 |
| 69 For each production server, we have a Vagrant VM with the same host | 73 For each production server, we have a Vagrant VM with the same host |
| 70 name. | 74 name. |
| 71 | 75 |
| 72 To start the _filter1_ VM: | 76 To start the _filter1_ VM: |
| 73 | 77 |
| 74 vagrant up filter1 | 78 vagrant up filter1 |
| 75 | 79 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 86 | 90 |
| 87 vagrant ssh server5 | 91 vagrant ssh server5 |
| 88 | 92 |
| 89 If you want to test "real" SSH access you can use the test user account defined | 93 If you want to test "real" SSH access you can use the test user account defined |
| 90 in _private-stub_: | 94 in _private-stub_: |
| 91 | 95 |
| 92 ssh -i modules/private/files/id_rsa test@10.8.0.100 | 96 ssh -i modules/private/files/id_rsa test@10.8.0.100 |
| 93 | 97 |
| 94 The default password for this user (required for the _sudo_ command) is "test". | 98 The default password for this user (required for the _sudo_ command) is "test". |
| 95 | 99 |
| 96 Adding a server | 100 Adding a host |
| 97 --------------- | 101 ------------- |
| 98 | 102 |
| 99 To set up a new server, you should first add it to the development | 103 To set up a new host, extend the custom `hiera/private/host.yaml` by another |
| 100 environment and test the setup, then set up a corresponding production | 104 `servers:` item, e.g.: |
| 101 server. | 105 |
| 102 | 106 # ... |
| 103 ### Development environment | 107 custom1: |
| 104 | 108 ip: [10.8.0.254] |
| 105 1. Add entries in _Vagrantfile_ and _manifests/vagrant.pp_ | 109 dns: foobar.example.com |
| 106 | 110 ssh_public_key: AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAA... |
| 107 2. Add the host name to one of the manifests imported by | 111 role: codereviewserver |
| 108 _manifests/nodes.pp_ | 112 |
| 109 | 113 See `modules/base/manifests/init.pp`, especially the definition of the named |
| 110 3. Make sure the server uses the _nagios::client_ class and add a | 114 type `explicit_host_record()` within class `base`, for more information on the |
| 111 _nagios\_host_ to _manifests/monitoringserver.pp_ | 115 possible option keys and values. |
| 112 | 116 |
| 113 ### Production environment | 117 In development, this is all that needs to be done before the new box can be |
| 118 started using `vagrant up ...`. Production servers, however, need a working |
| 119 Puppet configuration first (see below). |
| 120 |
| 121 Configuring Puppet |
| 122 ------------------ |
| 123 |
| 124 ### Prerequisites |
| 114 | 125 |
| 115 1. Install Ubuntu Server 12.04 LTS | 126 1. Install Ubuntu Server 12.04 LTS |
| 116 2. Perform an update and install Puppet | 127 2. Run `hiera/install_precise.py` as user `root` to install Puppet and Hiera |
| 117 | |
| 118 » apt-get -y update && apt-get -y upgrade && apt-get -y install puppet | |
| 119 | |
| 120 3. Enable pluginsync (Add the following to the _main_ section in | 128 3. Enable pluginsync (Add the following to the _main_ section in |
| 121 _/etc/puppet/puppet.conf_) | 129 _/etc/puppet/puppet.conf_) |
| 122 | 130 |
| 123 pluginsync=true | 131 pluginsync=true |
| 124 | 132 |
| 125 4. Configure the master address (Add the following to the bottom of | 133 4. Configure the master address (Add the following to the bottom of |
| 126 _/etc/puppet/puppet.conf_) | 134 _/etc/puppet/puppet.conf_) |
| 127 | 135 |
| 128 [agent] | 136 [agent] |
| 129 server = puppetmaster.adblockplus.org | 137 server = puppetmaster.adblockplus.org |
| 130 | 138 |
| 131 Now you can either set it up as a pure agent or as a master. The | 139 Now you can either set it up as a pure agent or as a master. The |
| 132 master provides the configuration, agents fetch it from the master and | 140 master provides the configuration, agents fetch it from the master and |
| 133 apply it locally. The master is also an agent, fetching configuration | 141 apply it locally. The master is also an agent, fetching configuration |
| 134 from itself. | 142 from itself. |
| 135 | 143 |
| 136 #### Puppet agent | 144 ### Puppet agent |
| 137 | 145 |
| 138 1. Attempt an initial provisioning, this will fail | 146 1. Attempt an initial provisioning, this will fail |
| 139 | 147 |
| 140 puppet agent --test | 148 puppet agent --test |
| 141 | 149 |
| 142 2. On the master: List the certificates to get the name of the new | 150 2. On the master: List the certificates to get the name of the new |
| 143 agent's certificate | 151 agent's certificate |
| 144 | 152 |
| 145 puppet cert list | 153 puppet cert list |
| 146 | 154 |
| 147 3. Still on the master: Sign the certificate, e.g. for serverx: | 155 3. Still on the master: Sign the certificate, e.g. for serverx: |
| 148 | 156 |
| 149 puppet cert sign serverx | 157 puppet cert sign serverx |
| 150 | 158 |
| 151 4. Back on the agent: Attempt another provisioning, it should work now | 159 4. Back on the agent: Attempt another provisioning, it should work now |
| 152 | 160 |
| 153 puppet agent --test | 161 puppet agent --test |
| 154 | 162 |
| 155 #### Puppet master | 163 ### Puppet master |
| 156 | 164 |
| 157 1. Configure the certificate name (Add the following to the _master_ | 165 1. Configure the certificate name (Add the following to the _master_ |
| 158 section in _/etc/puppet/puppet.conf_) | 166 section in _/etc/puppet/puppet.conf_) |
| 159 | 167 |
| 160 certname = puppetmaster.adblockplus.org | 168 certname = puppetmaster.adblockplus.org |
| 161 | 169 |
| 162 2. Install the required packages | 170 2. Install the required packages |
| 163 | 171 |
| 164 apt-get install puppetmaster mercurial | 172 apt-get install puppetmaster mercurial |
| 165 | 173 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 Monitoring is fully functional in any environment, including development. | 205 Monitoring is fully functional in any environment, including development. |
| 198 Here, after bootstrapping the `server4` box, one can access the Nagios GUI | 206 Here, after bootstrapping the `server4` box, one can access the Nagios GUI |
| 199 from the host machine via <https://nagiosadmin:nagiosadmin@10.8.0.99/>. | 207 from the host machine via <https://nagiosadmin:nagiosadmin@10.8.0.99/>. |
| 200 | 208 |
| 201 The monitoring service of our production environment, however, is accessible | 209 The monitoring service of our production environment, however, is accessible |
| 202 via <https://monitoring.adblockplus.org/>. | 210 via <https://monitoring.adblockplus.org/>. |
| 203 Add yourself to _files/nagios-htpasswd_ in the _private_ module used on the | 211 Add yourself to _files/nagios-htpasswd_ in the _private_ module used on the |
| 204 server, or have someone add you if you don't have access. | 212 server, or have someone add you if you don't have access. |
| 205 | 213 |
| 206 | 214 |
| LEFT | RIGHT |