|
1 | 1 | Table of Contents |
2 | 2 | ================= |
3 | 3 |
|
4 | | - * [Overview](#overview) |
5 | | - * [How To Set It All Up](#how-to-set-it-all-up) |
6 | | - * [Enable Code Manager](#enable-code-manager) |
7 | | - * [Disable Webhook Auth If Using Gitlab](#disable-webhook-auth-if-using-gitlab) |
8 | | - * [Connecting Code Manager / r10k to Your Git Server](#connecting-code-manager--r10k-to-your-git-server) |
9 | | - * [Steps for Configuring SSH Access to your control\-repo via this module](#steps-for-configuring-ssh-access-to-your-control-repo-via-this-module) |
10 | | - * [Exact Timing and Order of Events](#exact-timing-and-order-of-events) |
11 | | - * [Relation to the puppetlabs/control\-repo](#relation-to-the-puppetlabscontrol-repo) |
12 | | - |
13 | | -Created by [gh-md-toc](https://github.com/ekalinin/github-markdown-toc.go) |
| 4 | +* [Overview](#overview) |
| 5 | +* [What Does This Module Provide You?](#what-does-this-module-provide-you) |
| 6 | +* [Easy Button Setup](#easy-button-setup) |
| 7 | +* [Other Notes:](#other-notes) |
| 8 | + * [Disable Webhook Auth If Using Gitlab Version < 8\.5](#disable-webhook-auth-if-using-gitlab-version--85) |
| 9 | + * [Relation to the puppetlabs\-rampupprogram/control\-repo](#relation-to-the-puppetlabs-rampupprogramcontrol-repo) |
| 10 | + * [The Zack/r10k functionality of the Module is Undocumented](#the-zackr10k-functionality-of-the-module-is-undocumented) |
14 | 11 |
|
15 | 12 | # Overview |
16 | 13 |
|
17 | | -This module allow for easy setup and configuration of PE code manager in PE2015.3 and above. If you are using PE 2015.2 then the module will default to installing the zack/r10k webhook. |
| 14 | +This module allows for easy setup and configuration of PE code manager in PE2015.3 and above. If you are using PE 2015.2 then the module will default to installing the zack/r10k webhook. |
18 | 15 |
|
19 | 16 | Upon upgrading to 2015.3 the module will uninstall zack/r10k and attempt to use code manager but this requires that you've set the correct parameters in the puppet_enterprise module for it to work. |
20 | 17 |
|
21 | | -This module was originally a very prescriptive profile in the puppetlabs/control-repo but is now here as its own module to make it more widely available. As a result, you may find that some items are not configurable but we're working on that. |
| 18 | +This module was originally a very prescriptive profile in the [puppetlabs-rampupprogram/control-repo](https://github.com/PuppetLabs-RampUpProgram/control-repo) but is now here as its own module to make it more widely available. |
22 | 19 |
|
23 | | -# How To Set It All Up |
| 20 | +# What Does This Module Provide You? |
24 | 21 |
|
25 | | -## Enable Code Manager |
| 22 | +1. A new RBAC role for deploying code ( Deploy Environments ) |
| 23 | +2. A new RBAC user for deploying code ( code_manager_service_user ) |
| 24 | +3. An infinite liftetime token from the RBAC user for use in a webhook |
| 25 | +4. A newly generated SSH key with the correct permissions to be used by code manager |
| 26 | + - And for you to setup in your Git server of choice as a deploy key |
| 27 | +5. Correctly chowns the $codedir so that code manager can deploy to it |
| 28 | +6. A file containing the webhook url to paste into your Git UI |
| 29 | + - Located at `/etc/puppetlabs/puppetserver/.puppetlabs/webhook_url.txt` by default |
26 | 30 |
|
27 | | -In order to use code manager ( and thus this module ) you must set the following parameter to true via hiera or the PE console UI. |
| 31 | +# Easy Button Setup |
28 | 32 |
|
29 | | -``` |
30 | | -puppet_enterprise::profile::master::code_manager_auto_configure: true |
31 | | -``` |
| 33 | +1. Enable code manager via the PE Console UI or hiera: |
32 | 34 |
|
33 | | -## Disable Webhook Auth If Using Gitlab |
| 35 | + ``` |
| 36 | + puppet_enterprise::profile::master::code_manager_auto_configure: true |
| 37 | + ``` |
34 | 38 |
|
35 | | -If you are using Gitlab as your git UI then you will also need to set the following hiera key to disable authentication to the code manager webhook. This is because gitlab currently does not allow for webhook urls that are longer than 255 characters while the RBAC token you need to place in the URL is, on its own, longer than 255 characters. |
| 39 | +2. Run `puppet agent -t` |
36 | 40 |
|
37 | | -If you are using an older version of gitlab ( before version 8 ) then you will not have the ability to disable ssl verification either and would need to disable the webhook authentication on code manager. |
38 | | -``` |
39 | | -puppet_enterprise::master::code_manager::authenticate_webhook: false |
40 | | -``` |
| 41 | +3. Install and run this module: |
41 | 42 |
|
42 | | -http://docs.puppetlabs.com/pe/2015.3/release_notes_known_issues_codemgmt.html#turn-off-webhook-authentication-for-gitlab |
| 43 | + ``` |
| 44 | + su - pe-puppet -c "puppet module install npwalker-pe_code_manager_webhook" |
| 45 | + chown -R pe-puppet:pe-puppet /etc/puppetlabs/code/environments/production/modules/ |
| 46 | + puppet apply -e "include pe_code_manager_webhook" |
| 47 | + ``` |
43 | 48 |
|
44 | | -# Connecting Code Manager / r10k to Your Git Server |
| 49 | +4. Configure a deploy key in your Git server using the SSH key created by the module |
| 50 | + - You'll paste `cat /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa.pub` |
| 51 | +5. Login to the PE console |
| 52 | +6. Navigate to the Classification page |
| 53 | + - Click on the PE Master group |
| 54 | + - Click the Classes tab |
| 55 | + - Find the `puppet_enterprise::profile::master` class |
| 56 | + - Set the `r10k_remote` to the SSH url of your git repo |
| 57 | + - Set the `r10k_private_key` parameter to `/etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa.key` |
| 58 | + - Commit your changes |
| 59 | +6. Run `puppet agent -t` |
| 60 | +7. Create a webhook on the control-repo repository in your Git server UI |
| 61 | + - The URL to connect to code manager is found at `/etc/puppetlabs/puppetserver/.puppetlabs/webhook_url.txt` |
| 62 | +8. Assuming this was a new install with no previous code in the code directory then everything worked. |
| 63 | +If not, try clearing all of the code and redeploying it with code manager |
| 64 | + - `echo 'code_manager_mv_old_code=true' > /opt/puppetlabs/facter/facts.d/code_manager_mv_old_code.txt; puppet agent -t` |
45 | 65 |
|
46 | | -Code Manager or r10k ( which Code Manager is based on ) require ssh authentication to your git repo. The basic steps are: |
47 | 66 |
|
48 | | -1. Create a ssh key |
49 | | -2. Make said ssh key a deploy key on your control-repo |
50 | | -3. Configure r10k / Code Manager to use this ssh key |
51 | 67 |
|
52 | | -## Steps for Configuring SSH Access to your control-repo via this module |
| 68 | +# Other Notes: |
53 | 69 |
|
54 | | -1. `/usr/bin/ssh-keygen -t rsa -b 2048 -C 'code_manager' -f /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa -q -N ''` |
55 | | - - http://doc.gitlab.com/ce/ssh/README.html |
56 | | - - https://help.github.com/articles/generating-ssh-keys/ |
57 | | -2. Create a deploy key on the control-repo project in your git server |
58 | | - - Paste in the public key from above |
59 | | - - `cat /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa.pub` |
60 | | -3. Login to the PE console |
61 | | -4. Navigate to the Classification page |
62 | | - - Click on the PE Master group |
63 | | - - Click the Classes tab |
64 | | - - Add the puppet_enterprise::profile::master |
65 | | - - Set the r10k_remote to the ssh url of your git repo |
66 | | - - Set the r10k_private_key parameter to /etc/puppetlabs/puppetserver/ssh/id-control_repo.rsa.key |
67 | | - - Commit your changes |
| 70 | +## Disable Webhook Auth If Using Gitlab Version < 8.5 |
68 | 71 |
|
69 | | -## Exact Timing and Order of Events |
| 72 | +If you are using [Gitlab < 8.5](https://gitlab.com/gitlab-org/gitlab-ce/commit/e80113593c120b71af428ea1b00f11fcdeae58b8) as your git UI then you will also need to set the following hiera key to disable authentication to the code manager webhook. This is because gitlab currently does not allow for webhook urls that are longer than 255 characters while the RBAC token you need to place in the URL is, on its own, longer than 255 characters. |
| 73 | + |
| 74 | +If you are using an older version of gitlab ( before version 8 ) then you will not have the ability to disable ssl verification either and would need to disable the webhook authentication on code manager. |
| 75 | +``` |
| 76 | +puppet_enterprise::master::code_manager::authenticate_webhook: false |
| 77 | +``` |
| 78 | + |
| 79 | +http://docs.puppetlabs.com/pe/2015.3/release_notes_known_issues_codemgmt.html#turn-off-webhook-authentication-for-gitlab |
70 | 80 |
|
71 | | -In order to enable code manager using this module you need to complete a very specific set of steps in the right order. |
| 81 | +## Relation to the puppetlabs-rampupprogram/control-repo |
72 | 82 |
|
73 | | -1. Make sure the code from this module is on your master |
74 | | - - You could either use a `puppet module install` or maybe an `r10k deploy environmnt -pv` |
75 | | -2. Enable code manager |
76 | | - - Set the parameter and run `puppet agent -t` |
77 | | -3. In order to allow file sync ( a companion to code manager) to deploy code it needs a clean $codedir ( meaning nothing in it ) |
78 | | - - This problem is solved in the puppet code via an exec statement that only runs if you set the following custom fact |
79 | | - - `echo 'code_manager_mv_old_code=true' > /opt/puppetlabs/facter/facts.d/code_manager_mv_old_code.txt` |
80 | | -4. Finally run `puppet agent -t` 2-3 times to make sure all of the configuration completes |
| 83 | +This module was created as a part of the [puppetlabs-rampupprogram/control-repo](https://github.com/PuppetLabs-RampUpProgram/control-repo) and for the time being the documentation in that control-repo may also serve as a useful supplement to this module. |
81 | 84 |
|
82 | | -# Relation to the puppetlabs/control-repo |
| 85 | +In fact if you are a new user of PE then you may consider using the puppetabs/control repo instead of trying to implement this module on its own. |
83 | 86 |
|
84 | | -This module was created as a part of the puppetlabs/control-repo and for the time being the documentation in that control-repo may also serve as a useful supplement to this module. |
| 87 | +## The Zack/r10k functionality of the Module is Undocumented |
85 | 88 |
|
86 | | -In fact if you are a new user of PE then you may consider using the puppetabs/control repo instead of trying to implement this module on its own. |
| 89 | +The purpose of this module is mostly for configuring code manager but the zack/r10k functionality is left in place undocumented. |
0 commit comments