1
votes

I have a basic puppet install using this tutorial https://www.digitalocean.com/community/tutorials/how-to-install-puppet-4-on-ubuntu-16-04

When I run /opt/puppetlabs/bin/puppet agent --test on my node I get

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Error while evaluating a Resource Statement. Could not find declared class firewall at /etc/puppetlabs/code/environments/production/manifests/site.pp:7:1 on node mark-inspiron.

On my node:

/opt/puppetlabs/bin/puppet module list

returns

/etc/puppetlabs/code/environment/production/modules

----- puppetlabs-firewall (v1.9.0)

On my puppet master at /etc/puppetlabs/code/environments/production/manifests/site.pp:

file {'/tmp/it_works.txt':                        # resource type file and filename
  ensure  => present,                             # make sure it exists
  mode    => '0644',                              # file permissions
  content => "It works on ${ipaddress_eth0}!\n",  # Print the eth0 IP fact
}

class { 'firewall': }

resources { 'firewall':
    purge => true,
}

firewall { "051 asterisk-set-rate-limit-register":
    string      => "REGISTER sip:",
    string_algo => "bm",
    dport       => '5060',
    proto       => 'udp',
    recent      => 'set',
    rname       => 'VOIPREGISTER',
    rsource     => 'true';
}
firewall { "052 asterisk-drop-rate-limit-register":
    string      => "REGISTER sip:",
    string_algo => "bm",
    dport       => '5060',
    proto       => 'udp',
    action      => 'drop',
    recent      => 'update',
    rseconds    => '600',
    rhitcount   => '5',
    rname       => 'VOIPREGISTER',
    rsource     => true,
    rttl        => true;
}

The file part works but not firewall.

1

1 Answers

2
votes

You need to install the modules on your master in a master setup with Puppet. They need to be somewhere in your modulepath. You can either place it in the modules directory within your $codedir (normally /etc/puppetlabs/code/modules) or in your directory environment modules directory (likely /etc/puppetlabs/code/environments/production/modules in your case since your cited site.pp is there). If you defined additional module paths in your environment.conf, then you can also place the modules there.

You can install/deploy them with a variety of methods, such as librarian-puppet, r10k, or code-manager (in Enterprise). However, the easiest method for you would be puppet module install puppetlabs-firewall on the master. Your Puppet catalog will then find the firewall class during compilation.

On a side note, that:

resources { 'firewall':
  purge => true,
}

will remove any changes to associated firewall configurations (as defined by Puppet's knowledge of the system firewall configuration according to the module's definition of what the resource manages) that are not managed by Puppet. This is nice for eliminating local changes that people make, but it can also have interesting side effects, so be careful.