On Tuesday, August 14, 2012 6:27:36 AM UTC-5, Marc Haber wrote:
>
> Hi, 
>
> I am trying to build (on node A) an authorized_keys file that contains 
> all host keys from all nodes that have class C imported. Here is my 
> code: 
>
> class C { 
>         @@file { "/var/lib/foo/authorized_keys/$fqdn": 
>                 ensure => present, 
>                 content => "from=\"$ipaddress_eth0\" ssh-rsa 
> $sshrsakey\n", 
>                 tag => "foo", 
>         } 
> } 
>
> node A { 
>         class { 'bar': } 
> } 
>
> class bar { 
>         File <<| tag == 'foo' |>> { 
>                 notify => Exec["/home/bar/.ssh/authorized_keys"], 
>         } 
>          
>         exec { "/home/bar/.ssh/authorized_keys": 
>                         command => "cat /var/lib/foo/authorized_keys/* > 
> /home/bar/.ssh/authorized_keys" 
>                         path => "/bin:/usr/bin", 
>                         provider => shell, 
>         } 
> } 
>
> This works. 
>
> I would, however, prefer to have the exec subscribed to the File 
> instead of notifying the exec from the File.



Why?

 

> I would like to write 
>
> class bar { 
>         File <<| tag == 'foo' |>> 
>          
>         exec { "/home/bar/.ssh/authorized_keys": 
>                         command => "cat /var/lib/foo/authorized_keys/* > 
> /home/bar/.ssh/authorized_keys" 
>                         path => "/bin:/usr/bin", 
>                         provider => shell, 
>                         subscribe => File <<| tag == 'foo' |>>, 
>         } 
> } 
>
> which doesn't compile. 
>
> How can I refer to the File in my exec? 
>
>
What you are looking for may work in Puppet 3; see 
http://projects.puppetlabs.com/issues/3178, which is targeted there.

With that said, Stephen is right that you are reinventing the wheel (though 
he didn't put it in those terms).  The Concat module is all about 
constructing files from pieces, and those pieces can easily be imported 
resources declared by other nodes.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/o0fj-2x2S3sJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to