Ask Your Question
0

How to copy and install 3 different files from puppet master to 3 different locations , plz help

asked 2017-04-20 15:29:50 -0500

Adam gravatar image

updated 2017-04-24 14:42:28 -0500

I created a module to copy one file from the master and install to agents and it works fine with code below: but now I am trying to copy 3 different files in different directory and install each one on different set of nodes ( it is like a range of ips or dns names called A systems ...) For example: file A need to be installed on all agents in A systems File B need to be installed on all agents in B systems File C need to be installed on all agents in C Systems

  1 class profile::ma {
  2
  3 file { '/tmp/filename.sh':
  4     ensure  => 'present',
  5     replace => 'no',

  6     source  => 'puppet:///module/files/filename.sh',
  7     mode   => '0755',
  8     notify  => Exec['install'],
  9
 10 }
 11
 12    exec { 'install':
 13      command     => '/tmp/filename.sh -i',
 14      onlyif      => '/usr/bin/test ! -e /etc/filetocheck',
  15 }
16}
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-04-21 05:22:49 -0500

bschonecker gravatar image

updated 2017-04-21 10:17:39 -0500

source => "puppet:///module/filename-${environment}.sh",

Should do the trick on line #6 where you have filename-a.sh, filename-b.sh, filename-c.sh in the module/files directory.

edit flag offensive delete link more

Comments

1

This is incorrect. You want source => "puppet:///module/filename-${environment}.sh", the files directory is overlooked by puppet even though your files are in the files directory. change module to your actual module name as well.

puser gravatar imagepuser ( 2017-04-21 06:26:18 -0500 )edit

Ah, yes. I didn't catch that. I was focused on using the ${environment} variable.

bschonecker gravatar imagebschonecker ( 2017-04-21 06:28:30 -0500 )edit

You can edit your answer, then if it works for the OP they can accept it

DarylW gravatar imageDarylW ( 2017-04-21 10:15:16 -0500 )edit

Thanks for your reply, but i should have said that I need to copy and install the file to 3 different set of agents not environment. I might nee to do lookup search or some sort like it.

Adam gravatar imageAdam ( 2017-04-24 14:40:32 -0500 )edit

So your concern is about managing different nodes/agents? Are you using the 'node' resource in site.pp? If so, you need to specifically pass the correct configuration to each node. This is usually done via the 'roles and profiles' pattern, https://docs.puppet.com/pe/2017.1/r_n_p_intro.html

DarylW gravatar imageDarylW ( 2017-04-24 15:57:07 -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: 2017-04-20 15:29:50 -0500

Seen: 51 times

Last updated: Apr 24