Skip to content

Commit afc9a35

Browse files
committed
Merge branch 'production' of https://github.com/npwalker/control-repo into merge_npwalker_control_repo
2 parents 869a5c3 + 7e40513 commit afc9a35

File tree

20 files changed

+469
-20
lines changed

20 files changed

+469
-20
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: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,179 @@
11
# control-repo
22
A control repository template
3+
=======
4+
# Before Starting:
5+
6+
This control repo and the steps below are intended to be used during a new installation of PE.
7+
8+
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.
9+
10+
## Setup a Trusted Fact On Your PE Master
11+
12+
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`
13+
14+
```
15+
---
16+
extension_requests:
17+
#pp_role
18+
1.3.6.1.4.1.34380.1.1.13: 'all_in_one_pe'
19+
```
20+
21+
### If You Have Not Installed PE
22+
23+
Good then you can proceed forward and the trusted fact will be used when you get to the install step.
24+
25+
### If You Have Already Installed PE
26+
27+
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.
28+
29+
Follow this document to regenerate the certificate on your master.
30+
31+
http://docs.puppetlabs.com/pe/latest/regenerate_certs_master.html
32+
33+
##Copy This Repo Into Your Own Git Server
34+
35+
###Gitlab
36+
37+
1. Install Gitlab
38+
- https://about.gitlab.com/downloads/
39+
40+
2. After Gitlab is installed you may sign if with the `root` user and password `5iveL!fe`
41+
42+
3. Make an user for yourself
43+
44+
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 )
45+
- http://doc.gitlab.com/ce/ssh/README.html
46+
- https://help.github.com/articles/generating-ssh-keys/
47+
48+
5. Create a group called `puppet` ( this is case sensitive )
49+
- http://doc.gitlab.com/ce/workflow/groups.html
50+
51+
6. Create a user called `r10k_api_user` and add them to the `puppet` group
52+
- From the landing page, select groups
53+
- Choose the puppet group
54+
- In the left hand pane, select memembers
55+
- Add the `r10k_api_user` with `master` permissions
56+
57+
7. Add your user to the `puppet` group as well
58+
59+
8. Create a project called `control-repo` and set the Namespace to be the `puppet` group
60+
61+
9. Logout of root and login as the `r10k_api_user`
62+
- Go to profile settings -> account ( https://<your_gitlab_server>/profile/account )
63+
- Copy the api token
64+
65+
10. Clone this control repository to your laptop/workstation
66+
- `git clone https://github.com/npwalker/control-repo.git`
67+
- `cd control-repo`
68+
69+
11. `git mv hieradata/nodes/example-puppet-master.yaml hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
70+
- Open `hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
71+
- edit `gms_api_token` to be your api token
72+
- edit `git_management_system` to be 'gitlab'
73+
- edit the `gms_server_url`
74+
75+
12. `git add hieradata/nodes/<fqdn_of_your_puppet_master>.yaml`
76+
77+
13. `git commit -m "renaming example-puppet-master.yaml"`
78+
79+
14. Rename my repository as the upstream remote
80+
- `git remote rename origin upstream`
81+
82+
15. Add your internal repository as the origin remote
83+
- `git remote add origin <url of your gitlab repository>`
84+
85+
16. Push the production branch of the repository from your machine up to your git server
86+
- `git push origin production`
87+
88+
17. `git branch --set-upstream-to origin/production`
89+
90+
###Stash
91+
92+
Coming soon!
93+
94+
###Github
95+
96+
Coming soon!
97+
98+
##Configure PE to Use the Control-Repo
99+
100+
###Install PE
101+
102+
1. Download the latest version of the PE installer for your platform and copy it to your master
103+
- https://puppetlabs.com/download-puppet-enterprise
104+
2. Expand the tarball and `cd` into the directory
105+
3. Run `puppet-enterprise-installer` to install
106+
107+
If you run into any issues or have more questions about the installer you can see our docs here:
108+
109+
http://docs.puppetlabs.com/pe/latest/install_basic.html
110+
111+
###Get the Control-Repo Deployed On Your Master
112+
113+
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.
114+
115+
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.
116+
117+
1. On your puppet master, make an ssh key for r10k to connect to gitlab
118+
- `/usr/bin/ssh-keygen -t rsa -b 2048 -C 'r10k' -f /root/.ssh/r10k_rsa -q -N ''`
119+
- http://doc.gitlab.com/ce/ssh/README.html
120+
- https://help.github.com/articles/generating-ssh-keys/
121+
2. Create a deploy key on the `control-repo` project in Gitlab
122+
- Paste in the public key from above
123+
- `cat /root/.ssh/r10k_rsa.pub`
124+
3. Follow https://docs.puppetlabs.com/pe/latest/r10k_config_console.html
125+
- The remote is on the front page of the project in the gitlab UI
126+
- git_settings should be:
127+
- `{"provider": "rugged",
128+
"private_key": "/root/.ssh/r10k_rsa"}`
129+
3. Run `puppet agent -t`
130+
- Expect to see changes to `r10k.yaml`
131+
3. Run `r10k deploy environment -pv`
132+
4. Run `puppet agent -t`
133+
- Now you should see many more changes
134+
135+
136+
## Test The Zack/r10k Webhook
137+
138+
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`.
139+
140+
1. Edit README.md
141+
- Just add something to it
142+
2. `git add README.md`
143+
3. `git commit -m "edit README"`
144+
4. `git push origin production`
145+
5. Allow the push to complete and then give it few seconds to complete
146+
- Open `/etc/puppetlabs/code/environments/production/README.md` and confirm your change is present
147+
148+
149+
150+
----
151+
#Miscellaneous
152+
153+
## If You Want to Install Pointing To This Repo on Github
154+
155+
### Setting Up Gitlab
156+
157+
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).
158+
159+
```
160+
---
161+
extension_requests:
162+
#pp_role
163+
1.3.6.1.4.1.34380.1.1.13: 'gitlab'
164+
```
165+
166+
### Setting up Github
167+
168+
Not yet completed.
169+
170+
### Setting up Stash
171+
172+
Not yet completed.
173+
174+
175+
#TODO
176+
Flush out generating an answer file and then appending extra answers onto the end of it.
177+
178+
179+

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)