Skip to content

Commit 10732cf

Browse files
author
Gary Larizza
committed
Merge pull request #4 from npwalker/merge_npwalker_control_repo
Merge npwalker/control-repo in puppetlabs/control-repo
2 parents 869a5c3 + 1fd5334 commit 10732cf

File tree

20 files changed

+470
-22
lines changed

20 files changed

+470
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hieradata/nodes/example-puppet-master.yaml

Puppetfile

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ forge "http://forge.puppetlabs.com"
66
mod "puppetlabs/inifile", :latest
77
mod "puppetlabs/stdlib", :latest
88
mod "puppetlabs/concat", :latest
9+
mod "puppetlabs/ntp", :latest
10+
mod "saz/ssh", :latest
11+
mod "puppetlabs/postgresql", '4.5.0'
12+
mod "puppet/stash", '1.3.0'
13+
mod "puppetlabs/java", '1.4.1'
914

1015
#An example of using a specific forge module version instead of latest
1116
#Notice the addition of single quotes
@@ -14,15 +19,18 @@ mod "puppetlabs/concat", :latest
1419
# Modules from Github using various references
1520
# Further examples: https://github.com/puppetlabs/r10k/blob/master/doc/puppetfile.mkd#examples
1621
# update the tag to the most current release when implementing
17-
#mod 'hiera',
18-
# :git => 'https://github.com/hunner/puppet-hiera',
19-
# :tag => '1.3.1'
22+
mod 'hiera',
23+
:git => 'https://github.com/hunner/puppet-hiera',
24+
:tag => '1.3.1'
2025

21-
#mod 'notifyme',
22-
# :git => 'git://github.com/glarizza/puppet-notifyme',
23-
# :ref => '50c01703b2e3e352520a9a2271ea4947fe17a51f'
26+
mod 'gitlab',
27+
:git => 'https://github.com/vshn/puppet-gitlab',
28+
:ref => '00397b86dfb3487d9df768cbd3698d362132b5bf'
2429

25-
#mod 'profiles',
26-
# :git => 'git://github.com/glarizza/puppet-profiles',
27-
# :ref => '3611ae4253ff01762f9bda1d93620edf8f9a3b22'
30+
mod 'r10k',
31+
:git => 'https://github.com/acidprime/r10k',
32+
:tag => 'v3.1.1'
2833

34+
mod 'gms',
35+
:git => 'https://github.com/npwalker/abrader-gms',
36+
:branch => 'gitlab_disable_ssl_verify_support'

README.md

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,178 @@
1-
# control-repo
2-
A control repository template
1+
# Before Starting:
2+
3+
This control repo and the steps below are intended to be used during a new installation of PE.
4+
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.
6+
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.
8+
9+
## Setup a Trusted Fact On Your PE Master
10+
11+
This control repository is setup to manage certain portions of your PE installation for you if you create a trusted fact called `pp_role`. In order to do so, lay down a file that looks exactly like the below in `/etc/puppetlabs/puppet/csr_attributes.yaml`
12+
13+
```
14+
---
15+
extension_requests:
16+
#pp_role
17+
1.3.6.1.4.1.34380.1.1.13: 'all_in_one_pe'
18+
```
19+
20+
### If You Have Not Installed PE
21+
22+
Good then you can proceed forward and the trusted fact will be used when you get to the install step.
23+
24+
### If You Have Already Installed PE
25+
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.
27+
28+
Follow this document to regenerate the certificate on your master.
29+
30+
http://docs.puppetlabs.com/pe/latest/regenerate_certs_master.html
31+
32+
##Copy This Repo Into Your Own Git Server
33+
34+
###Gitlab
35+
36+
1. Install Gitlab
37+
- https://about.gitlab.com/downloads/
38+
39+
2. After Gitlab is installed you may sign if with the `root` user and password `5iveL!fe`
40+
41+
3. Make an user for yourself
42+
43+
4. Make an ssh key to link with your user. You’ll want to do this on the machine you intend to edit code from ( most likely not your puppet master but your local workstation / laptop )
44+
- http://doc.gitlab.com/ce/ssh/README.html
45+
- https://help.github.com/articles/generating-ssh-keys/
46+
47+
5. Create a group called `puppet` ( this is case sensitive )
48+
- http://doc.gitlab.com/ce/workflow/groups.html
49+
50+
6. Create a user called `r10k_api_user` and add them to the `puppet` group
51+
- From the landing page, select groups
52+
- Choose the puppet group
53+
- In the left hand pane, select memembers
54+
- Add the `r10k_api_user` with `master` permissions
55+
56+
7. Add your user to the `puppet` group as well
57+
58+
8. Create a project called `control-repo` and set the Namespace to be the `puppet` group
59+
60+
9. Logout of root and login as the `r10k_api_user`
61+
- Go to profile settings -> account ( https://<your_gitlab_server>/profile/account )
62+
- Copy the api token
63+
64+
10. Clone this control repository to your laptop/workstation
65+
- `git clone <repository url>`
66+
- `cd control-repo`
67+
68+
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`
70+
- edit `gms_api_token` to be your api token
71+
- edit `git_management_system` to be 'gitlab'
72+
- edit the `gms_server_url`
73+
74+
12. `git add hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
75+
76+
13. `git commit -m "renaming example-puppet-master.yaml"`
77+
78+
14. Rename my repository as the upstream remote
79+
- `git remote rename origin upstream`
80+
81+
15. Add your internal repository as the origin remote
82+
- `git remote add origin <url of your gitlab repository>`
83+
84+
16. Push the production branch of the repository from your machine up to your git server
85+
- `git push origin production`
86+
87+
17. `git branch --set-upstream-to origin/production`
88+
89+
###Stash
90+
91+
Coming soon!
92+
93+
###Github
94+
95+
Coming soon!
96+
97+
##Configure PE to Use the Control-Repo
98+
99+
###Install PE
100+
101+
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
103+
2. Expand the tarball and `cd` into the directory
104+
3. Run `puppet-enterprise-installer` to install
105+
106+
If you run into any issues or have more questions about the installer you can see our docs here:
107+
108+
http://docs.puppetlabs.com/pe/latest/install_basic.html
109+
110+
###Get the Control-Repo Deployed On Your Master
111+
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.
113+
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.
115+
116+
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 ''`
118+
- http://doc.gitlab.com/ce/ssh/README.html
119+
- https://help.github.com/articles/generating-ssh-keys/
120+
2. Create a deploy key on the `control-repo` project in Gitlab
121+
- 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`
129+
- Expect to see changes to `r10k.yaml`
130+
3. Run `r10k deploy environment -pv`
131+
4. Run `puppet agent -t`
132+
- Now you should see many more changes
133+
134+
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`.
138+
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+
148+
149+
----
150+
#Miscellaneous
151+
152+
## If You Want to Install Pointing To This Repo on Github
153+
154+
### Setting Up Gitlab
155+
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).
157+
158+
```
159+
---
160+
extension_requests:
161+
#pp_role
162+
1.3.6.1.4.1.34380.1.1.13: 'gitlab'
163+
```
164+
165+
### Setting up Github
166+
167+
Not yet completed.
168+
169+
### Setting up Stash
170+
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.
176+
177+
178+

environment.conf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
modulepath = modules:site:$basemodulepath
22
config_version = 'scripts/config_version.sh $environmentpath $environment'
3-
4-
# Environment timeout should be set to unlimited. When set to zero it is less performant.
5-
# When code is deployed the admin API of puppetserver should be used to force a refresh of code from disk.
6-
# https://docs.puppetlabs.com/puppetserver/1.0/release_notes.html#new-feature-admin-api-for-refreshing-environments
7-
# https://docs.puppetlabs.com/puppet/3.7/reference/environments_configuring.html#environmenttimeout
8-
environment_timeout = 0

hieradata/common.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
---
22
message: "This node is using common data"
3+
4+
#Puppet Server Tuning
5+
puppet_enterprise::master::puppetserver::jruby_max_requests_per_instance: 10000
6+
7+
#pe-console-services tuning
8+
#https://docs.puppetlabs.com/pe/latest/console_config.html#tuning-the-classifier-synchronization-period
9+
#disable classifier scheduled sync and rely on r10k postrun command to sync the classes
10+
puppet_enterprise::profile::console::classifier_synchronization_period: 0
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
git_management_system: 'gitlab'
3+
gms_server_url: 'https://gitlab-server'
4+
gms_api_token: 'BDkZfWWnk4LVTLHdAywd'
5+
6+
#setup r10k to update classes in the console after code deploy
7+
pe_r10k::postrun:
8+
- '/usr/local/bin/update-classes.sh'

hieradata/virtual/virtualbox.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#These setting are intended for low memory testing VMs
2+
#Not intended for general usage
3+
---
4+
#Drop puppetdb Java Heap Size
5+
#PE3.2 and above
6+
pe_puppetdb::pe::java_args:
7+
-Xmx: '256m'
8+
-Xms: '64m'
9+
#PE3.1 and below
10+
pe_puppetdb::java_args:
11+
-Xmx: '256m'
12+
-Xms: '64m'
13+
#Drop the activemq java heap size
14+
pe_mcollective::role::master::activemq_heap_mb: '96'
15+
#Allow access to the puppetdb performance dashboard from non-localhost
16+
#This is insecure and also allows access to all API endpoints without verification
17+
pe_puppetdb::pe::listen_address: '0.0.0.0'
18+
19+
#PE3.7+
20+
#Allow access to the puppetdb performance dashboard from non-localhost
21+
#This is insecure and also allows access to all API endpoints without verification
22+
puppet_enterprise::profile::puppetdb::listen_address: '0.0.0.0'
23+
puppet_enterprise::profile::amq::broker::heap_mb: '96'
24+
puppet_enterprise::profile::master::java_args:
25+
Xmx: '192m'
26+
Xms: '128m'
27+
'XX:MaxPermSize': '=96m'
28+
'XX:PermSize': '=64m'
29+
puppet_enterprise::profile::puppetdb::java_args:
30+
Xmx: '96m'
31+
Xms: '96m'
32+
'XX:MaxPermSize': '=96m'
33+
'XX:PermSize': '=64m'
34+
puppet_enterprise::profile::console::java_args:
35+
Xmx: '64m'
36+
Xms: '64m'
37+
'XX:MaxPermSize': '=96m'
38+
'XX:PermSize': '=64m'
39+
puppet_enterprise::master::puppetserver::jruby_max_active_instances: 1 #PE3.7.2 only
40+
puppet_enterprise::profile::console::delayed_job_workers: 1
41+
#shared_buffers takes affect during install but is not managed after
42+
puppet_enterprise::profile::database::shared_buffers: '4MB'

manifests/site.pp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
# Define filebucket 'main':
2020
filebucket { 'main':
2121
#server should point to one master that will be the file bucket
22-
#$servername is the closest thing to the current behavior of PE
23-
#which hardcodes each master to point to itself for a file buckket
24-
server => $servername,
22+
server => "${settings::server}",
2523
path => false,
2624
}
2725

@@ -39,6 +37,14 @@
3937
# specified in the console for that node.
4038

4139
node default {
40+
#incude a role on any node that specifies it's role via a trusted fact at provision time
41+
#https://docs.puppetlabs.com/puppet/latest/reference/lang_facts_and_builtin_vars.html#trusted-facts
42+
#https://docs.puppetlabs.com/puppet/latest/reference/ssl_attributes_extensions.html#aws-attributes-and-extensions-population-example
43+
44+
if !empty( $trusted['extensions']['pp_role'] ) {
45+
include "role::${trusted['extensions']['pp_role']}"
46+
}
47+
4248
# This is where you can declare classes for all nodes.
4349
# Example:
4450
# class { 'my_class': }

scripts/config_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414

1515
#add something to find the remote url
1616

17-
puts head_sha
17+
puts head_sha

scripts/config_version.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ then
44
/opt/puppetlabs/puppet/bin/ruby $1/$2/scripts/config_version.rb $1 $2
55
else
66
/usr/bin/git --git-dir $1/$2/.git rev-parse HEAD
7-
fi
7+
fi

0 commit comments

Comments
 (0)