Score:1

Puppet manifest configuration for docker image verification

cn flag

I’m quite new to devops/ci/cd, so bear with me.

Currently, I’m getting a puppet manifest configuration set up for docker image verification. Let me try to layout it out:

I have a puppet master server with the following configuration:

  • Puppetmaster version: 5.5.10-4ubuntu3
  • Both of the servers are linux 20.04
  • All hosted on AWS

/etc/puppet/code/environments/production/manifests/site.pp

node default {
    include 'docker'
    docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }
}

Every time I try a new verification command in the .pp, I restart the puppet master server with the following command: sudo systemctl restart puppet-master

I’ve installed a module called garethr-docker on both of my servers – the agent and the master.

On the slave / agent server, I have this image docker image present and running: jorgemauriciodev/ubuntu-dockerfile-dev-v1 For the first step, I just want to check if the image exists in my slave server. Later on, I’ll figure out to make sure it’s running or built with the Dockerfile.

On the slave / agent server, I run: sudo puppet agent –test

And I receive the following error message:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::docker for ip-123-123-123-123.us-east-2.compute.internal (file: /etc/puppet/code/environments/production/manifests/site.pp, line: 2, column: 5) on node ip-123-123-123-123.us-east-2.compute.internal Warning: Not using cache on failed catalog Error: Could not retrieve catalog; skipping run

Anyone has any idea on what I’m getting wrong with the puppet manifest file?

Edit 1:

I did some changes that were suggested. Now, my file has a diferent name and changed the content: /etc/puppet/code/environments/production/manifests/init.pp

include 'docker'
class { 'docker':
  version => 'latest',
}
docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }

Still returns me that same error message.

Here´s the full message:

/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Retrieving plugin
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Info: Retrieving locales
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/indirector/request.rb:272: warning: URI.unescape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::docker for ip-172-31-21-116.us-east-2.compute.internal (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 1, column: 1) on node ip-172-31-21-116.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
/usr/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0
/usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete
/usr/lib/ruby/vendor_ruby/puppet/file_system/uniquefile.rb:126: warning: $SAFE will become a normal global variable in Ruby 3.0

Edit 2:

I installed further modules on master server and slave/agent server with this command:

sudo puppet module install puppetlabs-docker --version 4.1.2

And it´s still returning me an error message, but now seems that it´s a different one. So, probably a syntax issue now.

Here´s the important part of the message.

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: Class[Docker] is already declared; cannot redeclare (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 3) (file: /etc/puppet/code/environments/production/manifests/init.pp, line: 3, column: 1) on node ip-123-123-123-123.us-east-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Besides this message, it´s still returning me those warnings, but the list is much bigger. However, I don´t think it´s a concern at this time.

Score:0
ng flag

Error 500 in puppet means bad written code, can you pls share the whole config(init.pp) and I can tell you from there.

class { 'docker':
  version => 'latest',
}

docker::image { 'jorgemauriciodev/ubuntu-dockerfile-dev-v1': }

More information is available here: https://forge.puppet.com/modules/puppetlabs/docker

Jorge Mauricio avatar
cn flag
Ok. That´s the full file. Alright, then. I´ll change the name of the file and check it that´s it. should it be in the path that I put?
Zhivko Zhelev avatar
ng flag
usually is this ```/etc/puppetlabs/code/environments/production/manifests/init.pp```
Zhivko Zhelev avatar
ng flag
Please look at the answer. This is how it should be written, try copy/paste it and file is not needed to be exactly ```init.pp``` in your case, sorry my bad.
Jorge Mauricio avatar
cn flag
thanks for the help. I did exactly as you posted, restarted puppet master server, ran sudo puppet agent --test and still getting the same error. I´m not sure if I installed the module garethr-docker right. I used this CMD: sudo puppet module install garethr-docker. I should install it on the master o slave? And is there a way for me to check if I installed it right? Or is there anything else missing?
Zhivko Zhelev avatar
ng flag
It should use ```r10k``` this is built-in package managing tool in puppet, also try ```sudo puppetrun --noop``` on client and plese give the output. I have no idea how you setup puppet environment and is not easy to give straight answer.
Jorge Mauricio avatar
cn flag
I understand. Well, I know that I´m almost there, because I tested the manifest .pp with other commands that worked. For example: ``` file {'/tmp/it_works.txt': ensure => present, mode => '0644', content => "It works on ${ipaddress_eth0}!\n", }``` - worked and also ```service { 'docker': ensure => running, }``` - worked. When I ran the command you just sent me now (sudo puppet run --noop), it outputs this message: /usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete Error: Unknown Puppet subcommand 'run' See 'puppet help' for help on available puppet
Jorge Mauricio avatar
cn flag
Think I was suppose to run this, right: sudo puppet agent --noop. If that was the cases, this is what appeared for me: /usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete /usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete /usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete /usr/lib/ruby/vendor_ruby/puppet/util.rb:461: warning: URI.escape is obsolete /usr/lib/ruby/vendor_ruby/puppet/util.rb:315: warning: deprecated Object#=~ is called on Puppet::Transaction::Report; it always returns nil (goes on for 3 lines)
Zhivko Zhelev avatar
ng flag
ok pls run this on the server and agent ```puppet module install puppetlabs-docker --version 4.1.2``` and try again with ```puppet agent --test```
Jorge Mauricio avatar
cn flag
Ok. I think we´re evolving. Thanks for the help. I installed the extra modules on both master and agent. Restarted the puppet master service and ran ```sudo puppet agent --test``` again. Gave me a bigger warning message and a different error message. Seems like it may be a syntax issue now. I´ve edited the question an put the new error warning.
Zhivko Zhelev avatar
ng flag
remove ```include 'docker'``` and you should be good to go :) this line is the same as ```class { 'docker':``` both will include it, just with the first you are not doing anything
Jorge Mauricio avatar
cn flag
Worked! Thanks a million!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.