Ask Your Question
0

installing forge module from inside manifest

asked 2015-11-20 18:32:33 -0500

johntest gravatar image

updated 2015-11-25 13:36:24 -0500

I have a masterless setup.

I am attempting to install a forge module from inside the manifest node definition as such

node 'server4.test.local' {

  include iptables::pre
  include iptables::customrules
  include iptables::post

  exec { 'install-firewall-module':
    command => "/usr/bin/puppet module install puppetlabs-firewall",
    creates => "/etc/puppet/modules/firewall",
  }->

  Class['iptables::pre'] -> Class['iptables::customrules'] -> Class['iptables::post']
}

However it keeps trying the firewall class before installing the module.

Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type firewall at /etc/puppet/modules/iptables/manifests/pre.pp:19 on node server4.test.local

What is the best way to go about this?

edit retag flag offensive close merge delete

Comments

Oh wait - I just noticed that you said you have a masterless setup. I need to revise my original answer. :)

GregLarkin gravatar imageGregLarkin ( 2015-11-20 20:03:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-11-20 20:03:19 -0500

GregLarkin gravatar image

updated 2015-11-24 18:48:53 -0500

You have a bootstrapping problem here, and you'll need to get all of your Puppet modules installed before you attempt to run puppet apply on the rest of your code.

I would create a bootstrap manifest that has your module install exec resources and apply that first, then apply the code that utilizes the classes and resources in the installed modules.

On the other hand, is there a reason for not moving to a master-agent configuration instead of masterless?

UPDATE

https://puppetlabs.com/presentations/designing-puppet-rolesprofiles-pattern

https://techpunch.co.uk/development/how-to-build-a-puppet-repo-using-r10k-with-roles-and-profiles

And one of our top PSEs, Gary Larizza, has exhaustively documented a proper workflow for setting up a master/agent configuration with git and r10k. Start at the bottom of the list and work your way up each article:

http://garylarizza.com/blog/categories/workflow/

edit flag offensive delete link more

Comments

Hi John, I was thinking of some kind of shell script that you would run on each node that would do a "puppet module install ..." of each module required by your Puppet code. Then the script would follow with the "puppet apply ...." command to apply all of your resources.

GregLarkin gravatar imageGregLarkin ( 2015-11-24 18:43:03 -0500 )edit

If you wanted to write the entire thing as a Puppet .pp file, then you could issue a bunch of exec resources to call "puppet module install", then make sure they are ordered to be done before the rest of your resources. The execs could be placed in their own bootstrap manifest or not.

GregLarkin gravatar imageGregLarkin ( 2015-11-24 18:44:14 -0500 )edit

If you want to move to a standard master/agent configuration, then you want to investigate the use of a control repository and a Puppetfile to manage all of your Puppet module dependencies, be they downloaded from the Forge or private git repositories. I will update the answer above with links.

GregLarkin gravatar imageGregLarkin ( 2015-11-24 18:45:58 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-20 18:32:33 -0500

Seen: 381 times

Last updated: Nov 25 '15