Skip to content

Commit 9a876a6

Browse files
author
Gary Larizza
committed
Merge pull request #9 from npwalker/2015_3_prep
Changes for PE2015.3.0
2 parents a9d3be5 + 752f2ef commit 9a876a6

File tree

18 files changed

+436
-148
lines changed

18 files changed

+436
-148
lines changed

Puppetfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ mod 'r10k',
3434
mod 'gms',
3535
:git => 'https://github.com/npwalker/abrader-gms',
3636
:branch => 'gitlab_disable_ssl_verify_support'
37+
38+
mod 'pltraining-rbac',
39+
:git => 'https://github.com/puppetlabs/pltraining-rbac',
40+
:ref => '2f60e1789a721ce83f8df061e13f8bf81cd4e4ce'

README.md

Lines changed: 94 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,44 @@
1-
# Before Starting:
1+
Table of Contents
2+
=================
3+
4+
* [Before Starting](#before-starting)
5+
* [What You Get From This control\-repo](#what-you-get-from-this-control-repo)
6+
* [How To Set It All Up](#how-to-set-it-all-up)
7+
* [Setup a Trusted Fact On Your PE Master](#setup-a-trusted-fact-on-your-pe-master)
8+
* [If You Have Not Installed PE](#if-you-have-not-installed-pe)
9+
* [If You Have Already Installed PE](#if-you-have-already-installed-pe)
10+
* [Copy This Repo Into Your Own Git Server](#copy-this-repo-into-your-own-git-server)
11+
* [Gitlab](#gitlab)
12+
* [Stash](#stash)
13+
* [Github](#github)
14+
* [Configure PE to Use the Control\-Repo](#configure-pe-to-use-the-control-repo)
15+
* [Install PE](#install-pe)
16+
* [Get the Control\-Repo Deployed On Your Master](#get-the-control-repo-deployed-on-your-master)
17+
* [Test Code Manager](#test-code-manager)
18+
* [Updating From a Previous Version of PE](#updating-from-a-previous-version-of-pe)
19+
* [Upgrading to PE2015\.3\.z from PE 2015\.2\.z](#upgrading-to-pe20153z-from-pe-20152z)
20+
* [Appendix](#appendix)
21+
* [Test The Zack/r10k Webhook](#test-the-zackr10k-webhook)
22+
23+
# Before Starting
224

325
This control repo and the steps below are intended to be used during a new installation of PE.
426

5-
This control repo has only been tested against PE2015.2.z, it's likely close to working on PE3.8.z but has not been tested.
27+
The instructions are geared towards a new installation of PE2015.3.z. However, the control-repo should work just fine on [PE2015.2.z](#upgrading-to-pe20153z-from-pe-20152z)
628

7-
If you intend to use it on an existing installation then be warned that if you've already written or downloaded modules when you start using r10k it will remove all of the existing modules and replace them with what you define in your Puppetfile. Please copy or move your existing modules to another directory to ensure you do not lose any work you've already started.
29+
If you intend to use this control-repo on an existing installation then be warned that if you've already written or downloaded modules when you start using r10k it will remove all of the existing modules and replace them with what you define in your Puppetfile. Please copy or move your existing modules to another directory to ensure you do not lose any work you've already started.
30+
31+
# What You Get From This control-repo
32+
33+
As a result of following the instructions below you will receive at least the beginning of a best-practices installation of PE including...
34+
35+
- A git server
36+
- The ability to push code to your git server and have it automatically deployed to your PE Master
37+
- A config_version script to output the commit of code that your agent just applied
38+
- Optimal tuning of PE settings for this configuration
39+
- Working and example roles/profiles code
40+
41+
# How To Set It All Up
842

943
## Setup a Trusted Fact On Your PE Master
1044

@@ -17,15 +51,15 @@ extension_requests:
1751
1.3.6.1.4.1.34380.1.1.13: 'all_in_one_pe'
1852
```
1953

20-
### If You Have Not Installed PE
54+
### If You Have Not Installed PE
2155

22-
Good then you can proceed forward and the trusted fact will be used when you get to the install step.
56+
Good then you can proceed forward and the trusted fact will be used when you get to the install step.
2357

2458
### If You Have Already Installed PE
2559

26-
Trusted facts are created at the time a CSR is generated. So, we need to regenerate the certificate on the master for the above trusted fact to be created.
60+
Trusted facts are created at the time a CSR is generated. So, we need to regenerate the certificate on the master for the above trusted fact to be created.
2761

28-
Follow this document to regenerate the certificate on your master.
62+
Follow this document to regenerate the certificate on your master.
2963

3064
http://docs.puppetlabs.com/pe/latest/regenerate_certs_master.html
3165

@@ -53,20 +87,20 @@ http://docs.puppetlabs.com/pe/latest/regenerate_certs_master.html
5387
- In the left hand pane, select memembers
5488
- Add the `r10k_api_user` with `master` permissions
5589

56-
7. Add your user to the `puppet` group as well
90+
7. Add your user to the `puppet` group as well
5791

5892
8. Create a project called `control-repo` and set the Namespace to be the `puppet` group
5993

6094
9. Logout of root and login as the `r10k_api_user`
6195
- Go to profile settings -> account ( https://<your_gitlab_server>/profile/account )
6296
- Copy the api token
63-
97+
6498
10. Clone this control repository to your laptop/workstation
6599
- `git clone <repository url>`
66100
- `cd control-repo`
67101

68102
11. `git mv hieradata/nodes/example-puppet-master.yaml hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
69-
- Open `hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
103+
- Open `hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
70104
- edit `gms_api_token` to be your api token
71105
- edit `git_management_system` to be 'gitlab'
72106
- edit the `gms_server_url`
@@ -99,7 +133,7 @@ Coming soon!
99133
###Install PE
100134

101135
1. Download the latest version of the PE installer for your platform and copy it to your master
102-
- https://puppetlabs.com/download-puppet-enterprise
136+
- https://puppetlabs.com/download-puppet-enterprise
103137
2. Expand the tarball and `cd` into the directory
104138
3. Run `puppet-enterprise-installer` to install
105139

@@ -109,70 +143,76 @@ http://docs.puppetlabs.com/pe/latest/install_basic.html
109143

110144
###Get the Control-Repo Deployed On Your Master
111145

112-
At this point you have my control-repo code deployed into your git server. However, we have one final challenge getting that code onto your puppet master. In the end state the master will pull code from the git server via r10k, however, at this moment your puppet master doesn't have credentials to get code from the git server.
146+
At this point you have our control-repo code deployed into your git server. However, we have one final challenge: getting that code onto your puppet master. In the end state the master will pull code from the git server via r10k, however, at this moment your puppet master doesn't have credentials to get code from the git server.
113147

114-
So, we'll set up a deploy key in the git server that will allow a ssh-key we make to deploy the code and configure everything else.
148+
So, we'll set up a deploy key in the git server that will allow a ssh-key we make to deploy the code and configure everything else.
115149

116150
1. On your puppet master, make an ssh key for r10k to connect to gitlab
117-
- `/usr/bin/ssh-keygen -t rsa -b 2048 -C 'r10k' -f /root/.ssh/r10k_rsa -q -N ''`
151+
- `/usr/bin/ssh-keygen -t rsa -b 2048 -C 'code_manager' -f /etc/puppetlabs/puppetserver/code_manager.key -q -N ''`
118152
- http://doc.gitlab.com/ce/ssh/README.html
119153
- https://help.github.com/articles/generating-ssh-keys/
120154
2. Create a deploy key on the `control-repo` project in Gitlab
121155
- Paste in the public key from above
122-
- `cat /root/.ssh/r10k_rsa.pub`
123-
3. Follow https://docs.puppetlabs.com/pe/latest/r10k_config_console.html
124-
- The remote is on the front page of the project in the gitlab UI
125-
- git_settings should be:
126-
- `{"provider": "rugged",
127-
"private_key": "/root/.ssh/r10k_rsa"}`
128-
3. Run `puppet agent -t`
156+
- `cat /etc/puppetlabs/puppetserver/code_manager.key.pub`
157+
3. Login to the PE console
158+
7. Navigate to the Classification page
159+
- Click on the PE Master group
160+
- Click the Classes tab
161+
- Add the `puppet_enterprise::profile::master`
162+
- Set the `r10k_remote` to the ssh url from the front page of your gitlab repo
163+
- Set the `r10k_private_key` parameter to `/etc/puppetlabs/puppetserver/code_manager.key`
164+
- Commit your changes
165+
8. Run `puppet agent -t`
129166
- Expect to see changes to `r10k.yaml`
130-
3. Run `r10k deploy environment -pv`
131-
4. Run `puppet agent -t`
167+
9. Run `r10k deploy environment -pv`
168+
10. Run `puppet agent -t`
169+
- Expect to see code manager enabled
170+
10. `echo 'code_manager_mv_old_code=true' > /opt/puppetlabs/facter/facts.d/code_manager_mv_old_code.txt`
171+
11. Run `puppet agent -t`
132172
- Now you should see many more changes
173+
- Your code has been deployed with code manager now
133174

175+
## Test Code Manager
134176

135-
## Test The Zack/r10k Webhook
136-
137-
One of the components setup by this control-repo is that when you "push" code to your git server, the git server will inform the puppet master to run `r10k deploy environment -p`.
177+
One of the components setup by this control-repo is that when you "push" code to your git server, the git server will inform the puppet master to deploy branch you just pushed.
138178

139-
1. Edit README.md
140-
- Just add something to it
141-
2. `git add README.md`
142-
3. `git commit -m "edit README"`
143-
4. `git push origin production`
144-
5. Allow the push to complete and then give it few seconds to complete
145-
- Open `/etc/puppetlabs/code/environments/production/README.md` and confirm your change is present
146-
147-
179+
1. In one terminal window, `tail -f /var/log/puppetlabs/puppetserver/puppetserver.log`
180+
2. In a second terminal window
181+
- Add a new file, `touch test_file`
182+
- `git add test_file`
183+
- `git commit -m "adding a test_file"`
184+
- `git push origin production`
185+
3. Allow the push to complete and then wait a few seconds for everything to sync over
186+
- `ls -l /etc/puppetlabs/code/environments/production`
187+
- Confirm test_file is present
188+
4. In your first terminal window review the `puppetserver.log` to see the type of logging each sync will create
148189

149190
----
150-
#Miscellaneous
151-
152-
## If You Want to Install Pointing To This Repo on Github
191+
# Updating From a Previous Version of PE
153192

154-
### Setting Up Gitlab
193+
## Upgrading to PE2015.3.z from PE 2015.2.z
155194

156-
1. Install Gitlab on a server by specifying the following trusted fact on the soon-to-be Gitlab server and then [install the PE agent](http://docs.puppetlabs.com/pe/latest/install_agents.html#using-the-puppet-agent-package-installation-script).
195+
Remove `pe_r10k` from the PE master group in the console and instead add the following two parameters to the `puppet_enterprise::profile::master` class under the PE master group.
157196

158-
```
159-
---
160-
extension_requests:
161-
#pp_role
162-
1.3.6.1.4.1.34380.1.1.13: 'gitlab'
163-
```
197+
- `r10k_remote` = the ssh url for your internal repo
198+
- `r10k_private_key` = `/etc/puppetlabs/puppetserver/code_manager.key`
164199

165-
### Setting up Github
200+
When upgrading the `puppet_enterprise::profile::master` class has the `file_sync_enabled` parameter set to `false`. This parameter should be removed so that code manager can configure file sync.
166201

167-
Not yet completed.
202+
Finally, you’ll need to `echo 'code_manager_mv_old_code=true' > /opt/puppetlabs/facter/facts.d/code_manager_mv_old_code.txt` so that my puppet code will redeploy all of your code with code manager.
168203

169-
### Setting up Stash
204+
# Appendix
170205

171-
Not yet completed.
172-
173-
174-
#TODO
175-
Flush out generating an answer file and then appending extra answers onto the end of it.
206+
## Test The Zack/r10k Webhook
176207

208+
If you are using PE2015.2.z or if you've forced the use of the zack/r10k webhook then you'll want to test that it works.
177209

210+
One of the components setup by this control-repo is that when you "push" code to your git server, the git server will inform the puppet master to run `r10k deploy environment -p`.
178211

212+
1. Edit README.md
213+
- Just add something to it
214+
2. `git add README.md`
215+
3. `git commit -m "edit README"`
216+
4. `git push origin production`
217+
5. Allow the push to complete and then give it few seconds to complete
218+
- Open `/etc/puppetlabs/code/environments/production/README.md` and confirm your change is present

hieradata/common.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ message: "This node is using common data"
33

44
#Puppet Server Tuning
55
puppet_enterprise::master::puppetserver::jruby_max_requests_per_instance: 10000
6+
#Enable code manager
7+
puppet_enterprise::profile::master::code_manager_auto_configure: true
8+
puppet_enterprise::master::code_manager::authenticate_webhook: false
69

710
#pe-console-services tuning
811
#https://docs.puppetlabs.com/pe/latest/console_config.html#tuning-the-classifier-synchronization-period

manifests/site.pp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,9 @@
1111

1212
## Active Configurations ##
1313

14-
# PRIMARY FILEBUCKET
15-
# This configures puppet agent and puppet inspect to back up file contents when
16-
# they run. The Puppet Enterprise console needs this to display file contents
17-
# and differences.
18-
19-
# Define filebucket 'main':
20-
filebucket { 'main':
21-
#server should point to one master that will be the file bucket
22-
server => "${settings::server}",
23-
path => false,
24-
}
25-
26-
# Make filebucket 'main' the default backup location for all File resources:
27-
File { backup => 'main' }
14+
# Disable filebucket by default for all File resources:
15+
#http://docs.puppetlabs.com/pe/latest/release_notes.html#filebucket-resource-no-longer-created-by-default
16+
File { backup => false }
2817

2918
# DEFAULT NODE
3019
# Node definitions in this file are merged with node data from the console. See
@@ -40,7 +29,7 @@
4029
#incude a role on any node that specifies it's role via a trusted fact at provision time
4130
#https://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html#trusted-facts
4231
#https://docs.puppetlabs.com/puppet/latest/reference/ssl_attributes_extensions.html#aws-attributes-and-extensions-population-example
43-
32+
4433
if !empty( $trusted['extensions']['pp_role'] ) {
4534
include "role::${trusted['extensions']['pp_role']}"
4635
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
require 'json'
2+
3+
environmentpath = ARGV[0]
4+
environment = ARGV[1]
5+
6+
r10k_deploy_file_path = File.join(environmentpath, environment, '.r10k-deploy.json')
7+
8+
#output the sha1 from the control-repo
9+
puts JSON.parse(File.read(r10k_deploy_file_path))['signature']

scripts/config_version.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
2-
if [ -e /opt/puppetlabs/server/pe_version ]
2+
if [ -e $1/$2/.r10k-deploy.json ]
3+
then
4+
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/code_manager_config_version.rb $1 $2
5+
elif [ -e /opt/puppetlabs/server/pe_version ]
36
then
47
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
58
else
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
require 'puppet/file_system'
2+
3+
Puppet::Parser::Functions::newfunction(
4+
:no_fail_file, :arity => -2, :type => :rvalue,
5+
:doc => "Loads a file from a module and returns its contents as a string.
6+
7+
This is a replacement to the file function that returns nothing
8+
if the file specified cannot be found instead of erroring out.
9+
10+
The argument to this function should be a `<MODULE NAME>/<FILE>`
11+
reference, which will load `<FILE>` from a module's `files`
12+
directory. (For example, the reference `mysql/mysqltuner.pl` will load the
13+
file `<MODULES DIRECTORY>/mysql/files/mysqltuner.pl`.)
14+
15+
This function can also accept:
16+
17+
* An absolute path, which can load a file from anywhere on disk.
18+
* Multiple arguments, which will return the contents of the **first** file
19+
found, skipping any files that don't exist.
20+
"
21+
) do |vals|
22+
path = nil
23+
vals.each do |file|
24+
found = Puppet::Parser::Files.find_file(file, compiler.environment)
25+
if found && Puppet::FileSystem.exist?(found)
26+
path = found
27+
break
28+
end
29+
end
30+
31+
if path
32+
Puppet::FileSystem.read_preserve_line_endings(path)
33+
else
34+
nil
35+
end
36+
end
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class profile::git_webhook (
2+
$force_zack_r10k_webhook = false
3+
) {
4+
5+
if versioncmp( $::pe_server_version, '2015.2.99' ) <= 0 or $force_zack_r10k_webhook {
6+
include profile::git_webhook::zack_r10k_webhook
7+
} else {
8+
include profile::git_webhook::code_manager
9+
include profile::git_webhook::zack_r10k_webhook_disable
10+
}
11+
12+
}

0 commit comments

Comments
 (0)