Project

General

Profile

Upgrading from Puppet 3 to 4 » History » Version 10

Dominic Cleal, 06/21/2016 04:31 AM
recommend using foreman-installer

1 1 Dominic Cleal
h1. Upgrading from Puppet 3 to 4
2
3 7 Dominic Cleal
_This wiki page is a work in progress for the release of Foreman 1.12 and should be used +at your own risk+._
4 1 Dominic Cleal
5 8 Dominic Cleal
{{toc}}
6
7 1 Dominic Cleal
This wiki page is a rough guide on how to upgrade from Puppet 3 to Puppet 4 when using Foreman. It doesn't replace Puppet's own documentation - you need to take both into account, and it's not for the faint-hearted.
8
9
Remember, Puppet is a separate piece of software to Foreman. Foreman integrates with Puppet in only a few places (e.g. reports, ENC and smart proxy class imports) but the Foreman installer may have set it up for you initially. Most of the work is changing the Puppet installation and then updating paths and configs in Foreman to suit.
10
11
If you're unfamiliar with how Puppet works, then you should consider setting up a new installation and migrating hosts instead.
12
13
h2. Planning
14
15
Ensure you are running Foreman 1.12 or higher, previous versions are not compatible with Puppet 4, while 1.12 is compatible with both 3 and 4, so carry out that upgrade first. See "Upgrading to Foreman 1.12":http://theforeman.org/manuals/1.12/index.html#3.6Upgrade for more information.
16
17
*Start with "Puppet 3.x to 4.x: Get upgrade-ready":https://docs.puppet.com/puppet/latest/reference/upgrade_major_pre.html* - it has many excellent points, including:
18
19
* As with any upgrade, the smaller the step, the easier it will be. Ensure you've already upgraded to the latest 3.x release and fixed any deprecations from the release notes before moving to 4. This will save time later.
20
* Ensure your Puppet modules are going to be compatible with Puppet 4's new ("future") parser
21
* Plan to upgrade your masters before your agents, because the master can serve older agents, but not the other way around.
22
* Back up everything, especially SSL keys and certificates.
23 10 Dominic Cleal
* Ensure you have enough RAM, Puppet Server defaults to requiring at _least_ 2GB (or set @--puppet-server-jvm-min-heap-size=1G --puppet-server-jvm-max-heap-size=1G@ to reduce it)
24 1 Dominic Cleal
25
The guide will assume you're using regular 'puppet' packages either from your OS (or EPEL) or from Puppet Labs repositories. Puppet 4 packages are All-In-One (AIO) packages and work quite differently, introducing lots of new paths for config files and binaries. More information on these at:
26
27
* "Welcome to Puppet Collections":https://puppet.com/blog/welcome-to-puppet-collections
28
* "About Puppet collections and packages":https://docs.puppet.com/puppet/latest/reference/puppet_collections.html
29 2 Dominic Cleal
30 10 Dominic Cleal
h2. 1. Beginning the upgrade
31 1 Dominic Cleal
32 10 Dominic Cleal
These steps should be carried out whether using the installer or updating by hand.
33 2 Dominic Cleal
34 10 Dominic Cleal
h3. 1a. Install new PC1 packages
35
36 1 Dominic Cleal
# Configure the new PC1 repositories with the "Using Puppet Collections":https://docs.puppet.com/guides/puppetlabs_package_repositories.html#using-puppet-collections instructions.
37 2 Dominic Cleal
# On EL, run @yum remove puppet-server@ to prevent later conflicts.
38
# Install the @puppetserver@ package, which should replace @facter@, @puppet@ and @puppet-server@ with @puppetserver@ and @puppet-agent@
39
40 10 Dominic Cleal
h3. 1b. Environments, SSL and Apache
41 2 Dominic Cleal
42 8 Dominic Cleal
This section is based on "Puppet 3.x to 4.x: Upgrade Puppet Server":https://docs.puppet.com/puppet/latest/reference/upgrade_major_server.html which goes into far more detail.
43
44 2 Dominic Cleal
# Move or copy any environments from @/etc/puppet/environments@ to @/etc/puppetlabs/code/environments@
45
# Move or copy all SSL keys and certificates from @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
46 1 Dominic Cleal
# Remove the Puppet master VirtualHost from Apache at @/etc/httpd/conf.d/25-puppet.conf@ (EL) or @a2dissite 25-puppet@ (Debian/Ubuntu)
47
# Remove 8140 from the Apache ports in @/etc/httpd/conf/ports.conf@ or @/etc/apache2/ports.conf@
48
# Update SSL paths in @/etc/httpd/conf.d/05-foreman-ssl.conf@ or @/etc/apache2/sites-available/05-foreman-ssl.conf@, changing @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
49
# Restart httpd/apache2 to free up the port
50
51 10 Dominic Cleal
h3. 1c. Choose foreman-installer or by hand
52 1 Dominic Cleal
53 10 Dominic Cleal
Choose _one_ of the two following sections - either update all configuration files using foreman-installer or by hand.
54
55
h2. 2. Upgrading with foreman-installer
56
57
If your installation is fairly standard, re-running the Foreman installer is the most reliable way to install and configure Puppet Server correctly. All parameters containing paths that change based on an AIO/non-AIO layout will be reset back to their defaults, which will match the paths files were moved to in the previous section.
58
59
<pre>
60
foreman-installer --noop -v \
61
  --puppet-server-implementation=puppetserver \
62
  --reset-foreman-client-ssl-ca \
63
  --reset-foreman-client-ssl-cert \
64
  --reset-foreman-client-ssl-key \
65
  --reset-foreman-puppet-home \
66
  --reset-foreman-puppet-ssldir \
67
  --reset-foreman-server-ssl-ca \
68
  --reset-foreman-server-ssl-cert \
69
  --reset-foreman-server-ssl-chain \
70
  --reset-foreman-server-ssl-crl \
71
  --reset-foreman-server-ssl-key \
72
  --reset-foreman-websockets-ssl-cert \
73
  --reset-foreman-websockets-ssl-key \
74
  --reset-foreman-proxy-puppet-ssl-ca \
75
  --reset-foreman-proxy-puppet-ssl-cert \
76
  --reset-foreman-proxy-puppet-ssl-key \
77
  --reset-foreman-proxy-puppetdir \
78
  --reset-foreman-proxy-ssl-ca \
79
  --reset-foreman-proxy-ssl-cert \
80
  --reset-foreman-proxy-ssl-key \
81
  --reset-foreman-proxy-ssldir \
82
  --reset-foreman-puppet-home \
83
  --reset-puppet-autosign \
84
  --reset-puppet-codedir \
85
  --reset-puppet-configtimeout \
86
  --reset-puppet-dir \
87
  --reset-puppet-logdir \
88
  --reset-puppet-rundir \
89
  --reset-puppet-ssldir \
90
  --reset-puppet-vardir \
91
  --reset-puppet-server-common-modules-path \
92
  --reset-puppet-server-dir \
93
  --reset-puppet-server-envs-dir \
94
  --reset-puppet-server-external-nodes \
95
  --reset-puppet-server-jruby-gem-home \
96
  --reset-puppet-server-manifest-path \
97
  --reset-puppet-server-puppetserver-dir \
98
  --reset-puppet-server-ruby-load-paths \
99
  --reset-puppet-server-ssl-dir
100
</pre>
101
102
* Note: in noop mode, you can expect an error of @Could not find a suitable provider for foreman_smartproxy@ to be logged, but this should be fixed on the live run, or install the @puppet-agent-oauth@ package manually.
103
104
Keep the @--noop -v@ flags on the first run to check if there are any unexpected changes, then remove it to perform the actual changes.
105
106
h2. 3. Upgrading by hand
107
108
If you have many manual customisations to your Foreman or Puppet installations that you wish to preserve, then you may wish to update config files by hand for new paths.
109
110
h3. 3a. Puppet Config files
111
112 3 Dominic Cleal
# @mv /etc/puppet/autosign.conf /etc/puppetlabs/puppet/@
113
# @cp /etc/puppet/puppet.conf /etc/puppetlabs/puppet/puppet.conf@ and change:
114
#* in the 'main' section:
115 6 Dominic Cleal
#*# @vardir = /opt/puppetlabs/puppet/cache@
116 1 Dominic Cleal
#*# @logdir = /var/log/puppetlabs/puppet@
117 6 Dominic Cleal
#*# @rundir = /var/run/puppetlabs@
118
#*# @ssldir = /etc/puppetlabs/puppet/ssl@
119 3 Dominic Cleal
#*# @environmentpath = /etc/puppetlabs/code@
120
#*# @basemodulepath = /etc/puppetlabs/code/environments/common:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules@
121 6 Dominic Cleal
#* in the 'agent' section:
122
#*# remove @configtimeout@
123
#* in the 'master' section:
124
#*# @autosign = /etc/puppetlabs/puppet/autosign.conf { mode = 0644 }@
125
#*# @external_nodes = /etc/puppetlabs/puppet/node.rb@
126
#*# @ssldir = /etc/puppetlabs/puppet/ssl@
127
# edit @/etc/puppetlabs/puppetserver/conf.d/puppetserver.conf@
128
## change @master-var-dir@ to @/opt/puppetlabs/puppet/cache@
129
## uncomment/set @use-legacy-auth-conf: false@ 
130
131
If using a smart proxy to import classes, edit @/etc/puppetlabs/puppetserver/conf.d/auth.conf@, search for @/puppet/v3/environments@ and add a new section below it:
132
133
<pre>
134
        {
135
            match-request: {
136
                path: "/puppet/v3/resource_type"
137
                type: path
138
                method: [get, post]
139
            }
140
            allow: "*"
141
            sort-order: 500
142 1 Dominic Cleal
            name: "puppetlabs resource type"
143 6 Dominic Cleal
        },
144
</pre> 
145
146
If you will still support Puppet 3 clients against the server running Puppet 4, see "auth.conf rules for Puppet 3 and 4 agents":https://docs.puppet.com/puppet/latest/reference/upgrade_major_server.html#example-authconf-rules-for-puppet-3-and-4-agents for additional rules. Using foreman-installer (below) will also configure these by default.
147
148 1 Dominic Cleal
Start and enable the puppetserver service with: @/opt/puppetlabs/bin/puppet resource service puppetserver ensure=running enable=true@
149 6 Dominic Cleal
150 10 Dominic Cleal
h3. 3b. ENC files
151 6 Dominic Cleal
152
# @cp /etc/puppet/foreman.yaml /etc/puppetlabs/puppet/foreman.yaml@ and change:
153
## replace @/var/lib/puppet/ssl@ with @/etc/puppetlabs/puppet/ssl@
154 1 Dominic Cleal
## @:puppetdir: /opt/puppetlabs/puppet/cache@
155 6 Dominic Cleal
# @mv /etc/puppet/node.rb /etc/puppetlabs/puppet/@
156 9 Dominic Cleal
157 10 Dominic Cleal
h3. 3c. Foreman settings
158 6 Dominic Cleal
159
# edit @/etc/foreman/settings.yaml@ and change @:puppetssldir: /etc/puppetlabs/puppet/ssl@
160
# change @websockets_*@ settings to use @/etc/puppetlabs/puppet/ssl@ and also @ssl_*@ if specified
161
# restart Foreman by running @touch ~foreman/tmp/restart.txt@
162
# check in _Administer > Settings > Auth_ in the Foreman UI that SSL certificate, private key and CA file all use @/etc/puppetlabs/puppet/ssl@, else change them
163
164 10 Dominic Cleal
h3. 3d. Smart proxy settings
165 6 Dominic Cleal
166
# edit @/etc/foreman-proxy/settings.d/puppet.yml@ and set @:puppet_version@ to the version of Puppet currently installed, e.g. 4.5.0
167
#* look up the version of puppet-agent (@rpm -q puppet-agent@ or @dpkg -l puppet-agent@) and check "Release contents":https://docs.puppet.com/puppet/4.5/reference/about_agent.html
168
# edit @/etc/foreman-proxy/settings.d/puppet_proxy_puppet_api.yml@ and change @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
169
# edit @/etc/foreman-proxy/settings.d/puppetca.yml@ and change:
170
## @:ssldir: /etc/puppetlabs/puppet/ssl@
171
## @:puppetdir: /etc/puppetlabs/puppet@
172
# edit @/etc/foreman-proxy/settings.yml@ and change @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
173
# restart foreman-proxy
174
175 10 Dominic Cleal
h3. 3e. Foreman installer
176 6 Dominic Cleal
177 10 Dominic Cleal
Foreman installer stores many paths in its answers file, so if you plan to run it again in future, these need to be changed. See the earlier section on upgrading with Foreman installer to update them.
178 3 Dominic Cleal
179
h2. Further reading
180
181
* "Puppet reference manual":https://docs.puppet.com/puppet/latest/reference/index.html
182
* "Puppet Server documentation":https://docs.puppet.com/puppetserver/latest/
183
* "Puppet Server vs Apache/Passenger Puppet master":https://docs.puppet.com/puppetserver/latest/puppetserver_vs_passenger.html
184
* "Where did everything go in Puppet 4.x?":https://docs.puppet.com/puppet/latest/reference/whered_it_go.html
185
* "puppet-agent: What is it, and what's in it?":https://docs.puppet.com/puppet/4.5/reference/about_agent.html