How Do You Troubleshoot the Puppet Error “file mode specification must be a string, not ‘Integer'”?

Problem scenario
You are running a manifest and you get this error:

Error: Failed to apply catalog: Parameter mode failed on File[/opt/hadoop/hadoop-2.2.0.tar.gz]: The file mode specification must be a string, not 'Integer' at /etc/puppetlabs/code/environments/production/modules/hadoop/manifests/init.pp:55

What is wrong?

Solution
Go to the Puppet Master server and open the file in the error. (The error provides the full directory path.) Go to the line number that the error message specifies. Find a file {} block section that looks something like this:

file { "${hadoop::params::hadoop_base}/hadoop-${hadoop::params::version}.tar.gz":
         mode => 0664,
         ensure => present,
         owner => "${hadoop::params::hadoop_path_owner}",
         group => "${hadoop::params::hadoop_group}",
         alias => "hadoop-source-tgz",
         before => Exec["untar-hadoop"],
         require => [File["hadoop-base"], Exec["download-hadoop"]],
     }

Translate the mode from octal notation to symbolic notation. If you do not know how, go to this website.

Enter the number in the website form and click "Submit." Change the Puppet manifest accordingly. In this example, the 'mode => 0664' line will need to be changed to 'mode => "u=rw,g=rw,o=r"'.

The website will show columns for user, group and other. These correspond to u, g, and o. The equals sign "=" assigns different permissions such as read, write or execute. Those permissions are symbolized with "r", "w", and "x" respectively.

Leave a comment

Your email address will not be published. Required fields are marked *