Creating a list of hosts

59 views
Skip to first unread message

Peter Berghold

unread,
Mar 26, 2015, 12:29:48 PM3/26/15
to puppet-users
I need a push in the right direction.  I have a need to have a subset of hosts in my environment "register" themselves to receive rsync updates from a central host.  I realize that the right approach is exported resources but I'm getting stuck on the actual implementation. 

Here is what I tried:

in one module

define registerhost() {
         include parms
         concat::fragment("$fqdn fragment":
               content => "${fqdn}",
               target=>"${parms::filenmae}"
          }
}

and elsewhere 

@@registerhost {"${fqdn}": }

and then to marshal the resources

concat { "${parms::filename}":
      ensure => present,
       backup=> true,
       owner => root, group=> root, mode => 0644
  }

  Registerhost <<||>>

What I'm seeing is 
/usr/local/etc/remote-masters.txt]/returns: The fragments directory is empty, cowardly refusing to make empty config files


I watched the puppetdb log and it would seem something is being written to puppetdb and puppetdb is the backend for storeconfigs. 

so... suggestions?

Felix Frank

unread,
Mar 26, 2015, 1:46:03 PM3/26/15
to puppet...@googlegroups.com
On 03/26/2015 05:29 PM, Peter Berghold wrote:
>
> I watched the puppetdb log and it would seem something is being written
> to puppetdb and puppetdb is the backend for storeconfigs.

Have you tried actually querying the PuppetDB contents?

https://docs.puppetlabs.com/puppetdb/latest/api/query/v2/resources.html

Peter Berghold

unread,
Mar 26, 2015, 2:39:50 PM3/26/15
to puppet...@googlegroups.com
Actually I made a typo and the segment of code that should have exported a resource was never invoked.  When I fixed the typo I know get:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error ArgumentError: Invalid resource type remotemaster at /etc/puppet/environments/POC/modules/puppet/manifests/master.pp:106 on node mtinjacn02.nvp.cip.att.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

"remotemaster" is the define I put together using the pattern
define registerhost() {
         include parms
         concat::fragment("$fqdn fragment":
               content => "${fqdn}",
               target=>"${parms::filenmae}"
          }
}


I guess you can't export such a thing?


--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/551445C5.7060102%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/d/optout.

Jeffrey Watts

unread,
Mar 26, 2015, 2:59:56 PM3/26/15
to puppet...@googlegroups.com
On Thu, Mar 26, 2015 at 11:29 AM, Peter Berghold <salty....@gmail.com> wrote:
I need a push in the right direction.  I have a need to have a subset of hosts in my environment "register" themselves to receive rsync updates from a central host.  I realize that the right approach is exported resources but I'm getting stuck on the actual implementation. 

Hi!  I'd recommend you look at the wonderful puppetdb-query:

I use it to extract hostnames from PuppetDB to populate various things.  It's been a long time since I set this up but it should be as simple as installing the module and doing something like this:

manifests/init.pp:

   $all_hosts = query_nodes('kernel="Linux"')

    file { 'fqdns.txt':
      content   => template('test/fqdns.erb'),
      ensure    => file,
      path       => '/foo/bar/fqdns',
    }

templates/fqdns.erb:

    <%- all_hosts.each do |fqdn| -%>
    <%= fqdn %>
    <%- end -%>

Hope this helps!
Jeffrey.

Felix Frank

unread,
Mar 26, 2015, 4:07:30 PM3/26/15
to puppet...@googlegroups.com
On 03/26/2015 07:39 PM, Peter Berghold wrote:
>
> I guess you can't export such a thing?

You can. But your define is not called 'remotemaster'. Perhaps that is
the cause of the error.

Cheers,
Felix

Peter Berghold

unread,
Mar 26, 2015, 4:47:37 PM3/26/15
to puppet...@googlegroups.com
puppetdbquery looks worth looking into... 

--
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+unsubscribe@googlegroups.com.

Peter Berghold

unread,
Mar 26, 2015, 4:58:28 PM3/26/15
to puppet...@googlegroups.com
OK... excuse me for being a bit dense... but how do you install this thing?  i've unzipped it and it isn't very obvious to me...

Jeffrey Watts

unread,
Mar 26, 2015, 6:18:52 PM3/26/15
to puppet...@googlegroups.com
Put the puppetdb directory in /etc/puppet/modules.

Good luck.
Jeffrey.

Peter Berghold

unread,
Mar 26, 2015, 6:36:15 PM3/26/15
to puppet...@googlegroups.com

Ok... I thought so... thanks


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAMvPdm0pmOYTcVZqjJUxXAN553e%3DiRoXCfrxL-8kU9zeCx6DYQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages