Execute command on another agent

16 views
Skip to first unread message

mathie

unread,
Nov 16, 2011, 11:44:07 AM11/16/11
to puppet...@googlegroups.com
Hello,

I have this setup but don't know how to implement it in puppet. There are 3 servers: puppetmaster, agent1, agent2

In order to setup agent1, I need to run a command on agent2 and return the data.

I know "file" can generate() function to run a command. However, it runs on the puppetmaster but I need it to run on agent2 instead. Is it possible with puppet? How? Thanks

file { "/tmp/setup_data":
            content => generate(
                "/bin/sh",
                "/tmp/script_on_puppetmaster.sh",
                $myvar,
            )
        }

Felix Frank

unread,
Dec 2, 2011, 4:03:30 AM12/2/11
to puppet...@googlegroups.com
Hi,

On 11/16/2011 05:44 PM, mathie wrote:
> Hello,
>
> I have this setup but don't know how to implement it in puppet. There
> are 3 servers: puppetmaster, agent1, agent2
>
> In order to setup agent1, I need to run a command on agent2 and return
> the data.
>
> I know "file" can generate() function to run a command. However, it runs
> on the puppetmaster but I need it to run on agent2 instead. Is it
> possible with puppet? How? Thanks

is this a lot of content or just a single line?
A generic approach would be to enable stored configs and have agent2
create the file resource by whatever means required (probably a custom
fact to get the data to the puppetmaster), export it and have agent1
import the file.

Pseudocode:

node 'agent2' {
$data = $::my_custom_fact
@@file { "/tmp/setup_data": content => $data }
}

node 'agent2' {
File<<| title == "/tmp/setup_data" "|>>
}

HTH,
Felix

Reply all
Reply to author
Forward
0 new messages