1

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 ?

Zama Ques
  • 523
  • 1
  • 9
  • 24

2 Answers2

3

If I am not wrong then I can copy all manifests under classes and nodes directory to the below manifest directory

Yes, the manifest directory will be imported recursively, so this is the best thing to do.

Please suggest how to update the manifests to the later versions of Puppet or there is no compatibility issues ?

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.

Dominic Cleal
  • 3,160
  • 19
  • 16
0

Following are the changes I had to perform to migrate code from Puppet to Puppet 4.

  • Use of import function is deprecated .

Puppet 3 Code:

My site.pp was using import function to call other manifests as shown below

 import "../classes/*"
 import "../nodes/*"

Puppet 4 Code:

Copied nodes and classes directory to manifests directory as specified by `puppet config print manifest'

  # puppet config print manifest
   /etc/puppetlabs/code/environments/production/manifests

  # ls /etc/puppetlabs/code/environments/production/manifests
    classes nodes 

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 recursively

  • Syntax 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:

 ` file { "/etc/sudoers":
     path => "/etc/sudoers",
     ...
     mode => 440,
    }    `

This was failing with the below error

     `Error: Failed to apply catalog: Parameter mode failed on File[/etc/sudoers]: The file mode specification must be a string, not 'Fixnum' at /etc/puppetlabs/code/environments/production/manifests/classes/user_default.pp:7`

Puppet 4 Code: Fix was to put mode value within quotes

   `file { "/etc/sudoers":
     path => "/etc/sudoers",
     ...
     mode => "440",
    }      ` 

These are the major issues I faced while migrating to Puppet 4 . After that the migration was smooth.

Zama Ques
  • 523
  • 1
  • 9
  • 24