How do I run a shell script from puppet?

1,910 views
Skip to first unread message

Tibor Malomsoki

unread,
Jun 1, 2014, 6:09:46 PM6/1/14
to puppet...@googlegroups.com
apt-get update is work->
exec { "apt-update":
    command => "/usr/bin/apt-get update"
}

Exec["apt-update"] -> Package <| |>

But now I want to run a complicated script (/etc/puppet/script/works.sh)

what do I write the site.pp that I run the script in the client

David Schmitt

unread,
Jun 2, 2014, 2:18:19 AM6/2/14
to puppet...@googlegroups.com
First, put the script into a module's "files" subdirectory, so it is
accessible via the puppet file server. Alternatively create a custom
mount point in fileserver.conf (see
http://docs.puppetlabs.com/guides/file_serving.html for details).

Then use this:

> file { "/var/lib/puppet/script.sh":
> source => "puppet:///modules/test/script.sh", # assuming you put it in the 'test' module
> mode => 0755,
> } ->
> exec { "/var/lib/puppet/script.sh": }


Have fun, David

Tibor Malomsoki

unread,
Jun 2, 2014, 3:38:22 AM6/2/14
to puppet...@googlegroups.com
I creat the subdirectory etc.
But I get this massage -> client:

can't open /proc/interrupts at /usr/bin/lsdev line 15.
info: Caching catalog for server.domain.com
info: Applying configuration version '1401794715'
err: /Stage[main]//File[/var/lib/puppet/script.sh]: Could not evaluate: Could not retrieve information from environment production source(s) puppet:///modules/test/script.sh at /etc/puppet/manifests/site.pp:4
notice: /Stage[main]//Exec[/var/lib/puppet/script.sh]: Dependency File[/var/lib/puppet/script.sh] has failures: true
warning: /Stage[main]//Exec[/var/lib/puppet/script.sh]: Skipping because of failed dependencies
notice: Finished catalog run in 0.08 seconds

David Schmitt

unread,
Jun 2, 2014, 3:46:52 AM6/2/14
to puppet...@googlegroups.com
On 2014-06-02 09:38, Tibor Malomsoki wrote:
> err: /Stage[main]//File[/var/lib/puppet/script.sh]: Could not evaluate:
> Could not retrieve information from environment production source(s)
> puppet:///modules/test/script.sh at /etc/puppet/manifests/site.pp:4

This says that the script.sh could not be found or accessed on the server.


Regards, David

Tibor Malomsoki

unread,
Jun 2, 2014, 4:14:51 AM6/2/14
to puppet...@googlegroups.com
OS Ubuntu

The (test) script itself run.
The script content:
#!/bin/sh
mkdir /home/works01

I found this site.pp conf->
It is work the puppet agent ---test but the get-data.sh will not run.

 define get-data() {
 
        file { "/usr/bin/data":
           owner => "root",
           group => "wheel",
           mode => "755",
           purge   => true,
           recurse => true,
           source => "puppet://puppet/data/bin/";
    }
 
    file { "/usr/bin/data/get-data.sh":
           owner => "root",
           group => "wheel",
           mode => "755",
           source => "puppet://puppet/data/bin/get-data.sh";
    }
 
        exec { "/usr/bin/data/get-data.sh restart":
                   subscribe => File["/usr/bin/data/get-data.sh"],
                   refreshonly => true;
        }
}



David Schmitt

unread,
Jun 2, 2014, 4:34:06 AM6/2/14
to puppet...@googlegroups.com
Hi Tibor,

working through the learning VM from puppetlabs at

> https://puppetlabs.com/download-learning-vm

will provide you with working knowledge how to debug this and other
issues in your puppet deployment.


Regards, David
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/b3dad75b-e8f9-469f-b3c1-84a619994a89%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/b3dad75b-e8f9-469f-b3c1-84a619994a89%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages