Reputation: 31
I am new to Puppet..I am trying to install a shell script and exceute it using Puppet. The shell script after running creates another conf file and places in a specific location /usr/local/conf/app.conf. How can I write a puppet code to execute this script and then take the output file and scp it to another server (in my case its the webserver). Can someone please help.
Upvotes: 1
Views: 12111
Reputation: 141
Let's assume you have developed a module named webconfig and your puppet config dir is /etc/puppet.
You would need to store your shell script as /etc/puppet/modules/webconfig/files/script.sh
Your puppet code would partially look like this:
file { '/path/to/script.sh':
ensure => present,
source => 'puppet:///modules/webconfig/script.sh',
mode => '0644',
owner => 'root',
group => 'root',
}
->
exec { 'Generate the config':
command => '/path/to/script.sh',
cwd => '/path/to',
user => 'root',
}
->
exec { 'SCP the config':
command => 'scp /usr/local/conf/app.conf user@remote-server:',
cwd => '/path/to',
user => 'root',
}
Upvotes: 1