Project

General

Profile

Upgrading from Puppet 3 to 4 » History » Version 8

Dominic Cleal, 05/26/2016 10:43 AM
formatting

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 2 Dominic Cleal
* Ensure you have enough RAM, Puppet Server defaults to requiring at _least_ 2GB
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
h2. Upgrading
31
32
h3. Install new PC1 packages
33
34
# Configure the new PC1 repositories with the "Using Puppet Collections":https://docs.puppet.com/guides/puppetlabs_package_repositories.html#using-puppet-collections instructions.
35
# On EL, run @yum remove puppet-server@ to prevent later conflicts.
36
# Install the @puppetserver@ package, which should replace @facter@, @puppet@ and @puppet-server@ with @puppetserver@ and @puppet-agent@
37
38
h3. Move configs and files to new structure
39
40
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.
41
42 8 Dominic Cleal
h4. Environments, SSL and Apache
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
# 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 1 Dominic Cleal
51 8 Dominic Cleal
h4. Config files
52 2 Dominic Cleal
53
# @mv /etc/puppet/autosign.conf /etc/puppetlabs/puppet/@
54
# @cp /etc/puppet/puppet.conf /etc/puppetlabs/puppet/puppet.conf@ and change:
55
#* in the 'main' section:
56
#*# @vardir = /opt/puppetlabs/puppet/cache@
57
#*# @logdir = /var/log/puppetlabs/puppet@
58
#*# @rundir = /var/run/puppetlabs@
59 1 Dominic Cleal
#*# @ssldir = /etc/puppetlabs/puppet/ssl@
60
#*# @environmentpath = /etc/puppetlabs/code@
61 2 Dominic Cleal
#*# @basemodulepath = /etc/puppetlabs/code/environments/common:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules@
62 3 Dominic Cleal
#* in the 'agent' section:
63
#*# remove @configtimeout@
64 2 Dominic Cleal
#* in the 'master' section:
65 1 Dominic Cleal
#*# @autosign = /etc/puppetlabs/puppet/autosign.conf { mode = 0644 }@
66
#*# @external_nodes = /etc/puppetlabs/puppet/node.rb@
67
#*# @ssldir = /etc/puppetlabs/puppet/ssl@
68 3 Dominic Cleal
# edit @/etc/puppetlabs/puppetserver/conf.d/puppetserver.conf@
69
## change @master-var-dir@ to @/opt/puppetlabs/puppet/cache@
70 5 Dominic Cleal
## uncomment/set @use-legacy-auth-conf: false@ 
71 3 Dominic Cleal
72 4 Dominic Cleal
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:
73
74
<pre>
75
        {
76
            match-request: {
77
                path: "/puppet/v3/resource_type"
78
                type: path
79
                method: [get, post]
80
            }
81
            allow: "*"
82
            sort-order: 500
83
            name: "puppetlabs resource type"
84
        },
85
</pre> 
86 6 Dominic Cleal
87
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.
88
89 1 Dominic Cleal
Start and enable the puppetserver service with: @/opt/puppetlabs/bin/puppet resource service puppetserver ensure=running enable=true@
90 6 Dominic Cleal
91 8 Dominic Cleal
h4. ENC files
92 3 Dominic Cleal
93
# @cp /etc/puppet/foreman.yaml /etc/puppetlabs/puppet/foreman.yaml@ and change:
94
## replace @/var/lib/puppet/ssl@ with @/etc/puppetlabs/puppet/ssl@
95 1 Dominic Cleal
## @:puppetdir: /opt/puppetlabs/puppet/cache@
96 3 Dominic Cleal
# @mv /etc/puppet/node.rb /etc/puppetlabs/puppet/@
97
98 8 Dominic Cleal
h4. Foreman settings
99 3 Dominic Cleal
100 4 Dominic Cleal
# edit @/etc/foreman/settings.yaml@ and change @:puppetssldir: /etc/puppetlabs/puppet/ssl@
101 1 Dominic Cleal
# change @websockets_*@ settings to use @/etc/puppetlabs/puppet/ssl@ and also @ssl_*@ if specified
102 3 Dominic Cleal
# restart Foreman by running @touch ~foreman/tmp/restart.txt@
103 4 Dominic Cleal
# 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
104 3 Dominic Cleal
105 8 Dominic Cleal
h4. Smart proxy settings
106 3 Dominic Cleal
107
# edit @/etc/foreman-proxy/settings.d/puppet.yml@ and set @:puppet_version@ to the version of Puppet currently installed, e.g. 4.5.0
108
#* 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
109
# edit @/etc/foreman-proxy/settings.d/puppet_proxy_puppet_api.yml@ and change @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
110 6 Dominic Cleal
# edit @/etc/foreman-proxy/settings.d/puppetca.yml@ and change:
111
## @:ssldir: /etc/puppetlabs/puppet/ssl@
112
## @:puppetdir: /etc/puppetlabs/puppet@
113 3 Dominic Cleal
# edit @/etc/foreman-proxy/settings.yml@ and change @/var/lib/puppet/ssl@ to @/etc/puppetlabs/puppet/ssl@
114
# restart foreman-proxy
115 6 Dominic Cleal
116
h2. Re-running foreman-installer
117
118
Foreman installer stores many paths in its answers file, so before it's safe to re-run it, these need to be changed.
119
120
_This section relies on #15071, currently unreleased._
121
122
You can either reset all of the affected parameters to their defaults and let them be recalculated using the AIO Puppet agent, or edit the answers file at @/etc/foreman-installer/scenarios.d/foreman-answers.yaml@. To reset them, run:
123
124
<pre>
125
foreman-installer --noop -v \
126
  --puppet-server-implementation=puppetserver \
127
  --reset-foreman-client-ssl-ca \
128
  --reset-foreman-client-ssl-cert \
129
  --reset-foreman-client-ssl-key \
130
  --reset-foreman-puppet-home \
131
  --reset-foreman-puppet-ssldir \
132
  --reset-foreman-server-ssl-ca \
133
  --reset-foreman-server-ssl-cert \
134
  --reset-foreman-server-ssl-chain \
135
  --reset-foreman-server-ssl-crl \
136
  --reset-foreman-server-ssl-key \
137
  --reset-foreman-websockets-ssl-cert \
138
  --reset-foreman-websockets-ssl-key \
139
  --reset-foreman-proxy-puppet-ssl-ca \
140
  --reset-foreman-proxy-puppet-ssl-cert \
141
  --reset-foreman-proxy-puppet-ssl-key \
142
  --reset-foreman-proxy-puppetdir \
143
  --reset-foreman-proxy-ssl-ca \
144
  --reset-foreman-proxy-ssl-cert \
145
  --reset-foreman-proxy-ssl-key \
146
  --reset-foreman-proxy-ssldir \
147
  --reset-puppet-autosign \
148
  --reset-puppet-codedir \
149
  --reset-puppet-configtimeout \
150
  --reset-puppet-dir \
151
  --reset-puppet-logdir \
152
  --reset-puppet-rundir \
153
  --reset-puppet-ssldir \
154
  --reset-puppet-vardir \
155
  --reset-puppet-server-common-modules-path \
156
  --reset-puppet-server-dir \
157
  --reset-puppet-server-envs-dir \
158
  --reset-puppet-server-external-nodes \
159
  --reset-puppet-server-jruby-gem-home \
160
  --reset-puppet-server-manifest-path \
161
  --reset-puppet-server-puppetserver-dir \
162
  --reset-puppet-server-ruby-load-paths \
163
  --reset-puppet-server-ssl-dir
164
</pre>
165
166
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. Note that there will be many more small changes to the contents of config files (particularly around Puppet Server) that the installer will change, but which shouldn't affect the operation.
167 3 Dominic Cleal
168
h2. Further reading
169
170
* "Puppet reference manual":https://docs.puppet.com/puppet/latest/reference/index.html
171
* "Puppet Server documentation":https://docs.puppet.com/puppetserver/latest/
172
* "Puppet Server vs Apache/Passenger Puppet master":https://docs.puppet.com/puppetserver/latest/puppetserver_vs_passenger.html
173
* "Where did everything go in Puppet 4.x?":https://docs.puppet.com/puppet/latest/reference/whered_it_go.html
174
* "puppet-agent: What is it, and what's in it?":https://docs.puppet.com/puppet/4.5/reference/about_agent.html