Project

General

Profile

Upgrading from Puppet 3 to 4 » History » Version 22

Anonymous, 06/25/2017 05:09 PM

1 1 Dominic Cleal
h1. Upgrading from Puppet 3 to 4
2
3 22 Anonymous
_This wiki page was written at 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 15 Anonymous
* Ensure you have enough RAM, Puppet Server defaults to requiring at _least_ 2GB (or set @--puppet-server-max-active-instances=1 --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 11 Dominic Cleal
38
On EL:
39
40
# run @yum remove puppet-server@ to prevent later conflicts
41
# run @yum install puppetserver@ which should replace @facter@, @puppet@ and @puppet-server@ with @puppetserver@ and @puppet-agent@
42
43
On Debian/Ubuntu:
44
45
# run @apt-get install puppetserver puppet-agent@ which should  @facter@, @puppet@ and @puppetmaster@ with @puppetserver@ and @puppet-agent@
46 2 Dominic Cleal
47 10 Dominic Cleal
h3. 1b. Environments, SSL and Apache
48 2 Dominic Cleal
49 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.
50
51 2 Dominic Cleal
# Move or copy any environments from @/etc/puppet/environments@ to @/etc/puppetlabs/code/environments@
52 1 Dominic Cleal
# Move or copy all SSL keys and certificates from @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
53 22 Anonymous
# Move or copy cached data (if there's any) from @/var/lib/puppet/foreman_cache_data@ to @/opt/puppetlabs/puppet/cache/foreman_cache_data@
54 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)
55
# Remove 8140 from the Apache ports in @/etc/httpd/conf/ports.conf@ or @/etc/apache2/ports.conf@
56
# 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@
57
# Restart httpd/apache2 to free up the port
58
59 10 Dominic Cleal
h3. 1c. Choose foreman-installer or by hand
60 1 Dominic Cleal
61 10 Dominic Cleal
Choose _one_ of the two following sections - either update all configuration files using foreman-installer or by hand.
62
63
h2. 2. Upgrading with foreman-installer
64
65
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.
66
67 12 Dominic Cleal
First install the @puppet-agent-oauth@ package to prevent warnings running in no-op mode.
68
69 10 Dominic Cleal
<pre>
70
foreman-installer --noop -v \
71
  --puppet-server-implementation=puppetserver \
72
  --reset-foreman-client-ssl-ca \
73
  --reset-foreman-client-ssl-cert \
74
  --reset-foreman-client-ssl-key \
75
  --reset-foreman-puppet-home \
76
  --reset-foreman-puppet-ssldir \
77
  --reset-foreman-server-ssl-ca \
78
  --reset-foreman-server-ssl-cert \
79
  --reset-foreman-server-ssl-chain \
80
  --reset-foreman-server-ssl-crl \
81
  --reset-foreman-server-ssl-key \
82
  --reset-foreman-websockets-ssl-cert \
83
  --reset-foreman-websockets-ssl-key \
84
  --reset-foreman-proxy-puppet-ssl-ca \
85
  --reset-foreman-proxy-puppet-ssl-cert \
86
  --reset-foreman-proxy-puppet-ssl-key \
87 16 Dominic Cleal
  --reset-foreman-proxy-puppetca-cmd \
88 10 Dominic Cleal
  --reset-foreman-proxy-puppetdir \
89
  --reset-foreman-proxy-ssl-ca \
90
  --reset-foreman-proxy-ssl-cert \
91
  --reset-foreman-proxy-ssl-key \
92
  --reset-foreman-proxy-ssldir \
93
  --reset-foreman-puppet-home \
94
  --reset-puppet-autosign \
95 13 Dominic Cleal
  --reset-puppet-client-package \
96 10 Dominic Cleal
  --reset-puppet-codedir \
97
  --reset-puppet-configtimeout \
98
  --reset-puppet-dir \
99
  --reset-puppet-logdir \
100
  --reset-puppet-rundir \
101
  --reset-puppet-ssldir \
102
  --reset-puppet-vardir \
103
  --reset-puppet-server-common-modules-path \
104 12 Dominic Cleal
  --reset-puppet-server-default-manifest-path \
105 10 Dominic Cleal
  --reset-puppet-server-dir \
106
  --reset-puppet-server-envs-dir \
107
  --reset-puppet-server-external-nodes \
108
  --reset-puppet-server-jruby-gem-home \
109 14 Dominic Cleal
  --reset-puppet-server-package \
110 10 Dominic Cleal
  --reset-puppet-server-puppetserver-dir \
111 18 Martin Schurz
  --reset-puppet-server-puppetserver-vardir \
112 21 Dominic Cleal
  --reset-puppet-server-puppetserver-version \
113 10 Dominic Cleal
  --reset-puppet-server-ruby-load-paths \
114
  --reset-puppet-server-ssl-dir
115
</pre>
116
117 20 Daniel Helgenberger
* 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.
118
119 10 Dominic Cleal
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.
120
121
h2. 3. Upgrading by hand
122
123
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.
124
125
h3. 3a. Puppet Config files
126
127 3 Dominic Cleal
# @mv /etc/puppet/autosign.conf /etc/puppetlabs/puppet/@
128
# @cp /etc/puppet/puppet.conf /etc/puppetlabs/puppet/puppet.conf@ and change:
129
#* in the 'main' section:
130 6 Dominic Cleal
#*# @vardir = /opt/puppetlabs/puppet/cache@
131 1 Dominic Cleal
#*# @logdir = /var/log/puppetlabs/puppet@
132 6 Dominic Cleal
#*# @rundir = /var/run/puppetlabs@
133
#*# @ssldir = /etc/puppetlabs/puppet/ssl@
134 3 Dominic Cleal
#*# @environmentpath = /etc/puppetlabs/code@
135
#*# @basemodulepath = /etc/puppetlabs/code/environments/common:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules@
136 6 Dominic Cleal
#* in the 'agent' section:
137
#*# remove @configtimeout@
138
#* in the 'master' section:
139
#*# @autosign = /etc/puppetlabs/puppet/autosign.conf { mode = 0644 }@
140
#*# @external_nodes = /etc/puppetlabs/puppet/node.rb@
141
#*# @ssldir = /etc/puppetlabs/puppet/ssl@
142
# edit @/etc/puppetlabs/puppetserver/conf.d/puppetserver.conf@
143
## change @master-var-dir@ to @/opt/puppetlabs/puppet/cache@
144
## uncomment/set @use-legacy-auth-conf: false@ 
145
146
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:
147
148
<pre>
149
        {
150
            match-request: {
151
                path: "/puppet/v3/resource_type"
152
                type: path
153
                method: [get, post]
154
            }
155
            allow: "*"
156
            sort-order: 500
157 1 Dominic Cleal
            name: "puppetlabs resource type"
158 6 Dominic Cleal
        },
159
</pre> 
160
161 19 Daniel Lobato Garcia
And if your Puppet server version is 4.4+, and you're using the proxy to import classes, add this section too:
162
163
<pre>
164
        {
165
            match-request: {
166
                path: "/puppet/v3/environment_classes"
167
                type: path
168
                method: get
169
            }
170
            allow: "*"
171
            sort-order: 500
172
            name: "puppetlabs environment classes"
173
        },
174
</pre>
175
176 6 Dominic Cleal
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.
177
178 1 Dominic Cleal
Start and enable the puppetserver service with: @/opt/puppetlabs/bin/puppet resource service puppetserver ensure=running enable=true@
179 6 Dominic Cleal
180 10 Dominic Cleal
h3. 3b. ENC files
181 6 Dominic Cleal
182
# @cp /etc/puppet/foreman.yaml /etc/puppetlabs/puppet/foreman.yaml@ and change:
183
## replace @/var/lib/puppet/ssl@ with @/etc/puppetlabs/puppet/ssl@
184 1 Dominic Cleal
## @:puppetdir: /opt/puppetlabs/puppet/cache@
185 6 Dominic Cleal
# @mv /etc/puppet/node.rb /etc/puppetlabs/puppet/@
186 9 Dominic Cleal
187 10 Dominic Cleal
h3. 3c. Foreman settings
188 6 Dominic Cleal
189
# edit @/etc/foreman/settings.yaml@ and change @:puppetssldir: /etc/puppetlabs/puppet/ssl@
190
# change @websockets_*@ settings to use @/etc/puppetlabs/puppet/ssl@ and also @ssl_*@ if specified
191
# restart Foreman by running @touch ~foreman/tmp/restart.txt@
192
# 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
193
194 10 Dominic Cleal
h3. 3d. Smart proxy settings
195 6 Dominic Cleal
196
# edit @/etc/foreman-proxy/settings.d/puppet.yml@ and set @:puppet_version@ to the version of Puppet currently installed, e.g. 4.5.0
197
#* 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
198
# edit @/etc/foreman-proxy/settings.d/puppet_proxy_puppet_api.yml@ and change @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
199
# edit @/etc/foreman-proxy/settings.d/puppetca.yml@ and change:
200
## @:ssldir: /etc/puppetlabs/puppet/ssl@
201
## @:puppetdir: /etc/puppetlabs/puppet@
202
# edit @/etc/foreman-proxy/settings.yml@ and change @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
203 17 Dominic Cleal
# @service foreman-proxy restart@
204 6 Dominic Cleal
205 10 Dominic Cleal
h3. 3e. Foreman installer
206 6 Dominic Cleal
207 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.
208 3 Dominic Cleal
209
h2. Further reading
210
211
* "Puppet reference manual":https://docs.puppet.com/puppet/latest/reference/index.html
212
* "Puppet Server documentation":https://docs.puppet.com/puppetserver/latest/
213
* "Puppet Server vs Apache/Passenger Puppet master":https://docs.puppet.com/puppetserver/latest/puppetserver_vs_passenger.html
214
* "Where did everything go in Puppet 4.x?":https://docs.puppet.com/puppet/latest/reference/whered_it_go.html
215
* "puppet-agent: What is it, and what's in it?":https://docs.puppet.com/puppet/4.5/reference/about_agent.html