We are migrating to later versions of puppet.
New Version:
# puppet --version
4.5.2
Existing Version:
#puppet-3.8.7
Our existing site.pp is as follows:
#A default site.pp to do a quick test run
import "../classes/*"
import "../nodes/*"
file { 'testfile':
path => '/home/test/testfile',
ensure => present,
mode => 0755,
content => "A test file to check a different manifestdir" ,
}
Exec { path => ["/bin" , "/sbini/", "/usr/bin" , "/usr/sbin/"] }
Now since we are migrating to Puppet 4
, i think below import function to include multiple pp files will not work here in Puppet 4
import "../classes/*"
import "../nodes/*"
If I am not wrong then I can copy all manifests under classes and nodes directory to the below manifest directory
/apps/puppetlabs/code/environments/production/manifests/site.pp
Please suggest how to update the manifests to the later versions of Puppet or there is no compatibility issues ?
Yes, the manifest directory will be imported recursively, so this is the best thing to do.
There are many subtle changes, so test your manifests on Puppet 3 with the future parser (
--parser future
) to see how well they work.Start with Puppet 3.x to 4.x: Get upgrade-ready, release notes and Puppet 3.8 deprecations.
Following are the changes I had to perform to migrate code from Puppet to Puppet 4.
Puppet 3 Code:
My site.pp was using import function to call other manifests as shown below
Puppet 4 Code:
Copied nodes and classes directory to manifests directory as specified by `puppet config print manifest'
No requirement for
site.pp
in my case as we are having manifests for multiple nodes. Putting classes and nodes to manifests directory will lead puppet to read each of the node manifests node recursivelySyntax change in writing Puppet templates
Puppet 3 Code :
<%= ipaddress %> dev.example.com
Was seeing the following error when applying on Puppet 4
Call, Failed to parse template /etc/puppet/templates/Node-002/hosts.erb: Filepath: /etc/puppet/templates/Node-002/hosts.erb: Line: 1 Detail: undefined local variable or method 'ipaddress' for #<Puppet::Parser::TemplateWrapper:0x007ffa98fb55c8>
Puppet 4 Code:
Updated the code as follows and after that the manifests was getting applied fine
<%= @ipaddress %> node-002.example.com
- Representation of numeric attribute value
Puppet 3 Code:
This was failing with the below error
Puppet 4 Code: Fix was to put mode value within quotes
These are the major issues I faced while migrating to Puppet 4 . After that the migration was smooth.