Hi,
I have 4 hosts as part of a hostgroup.
I was wondering if there is way to use foreman and puppet to write
/etc/hosts entries on all four hosts i.e. so each host would contain a file
with the following
/etc/hosts:
1.2.3.4 host1
1.2.3.5 host2
1.2.3.6 host3
1.2.3.7 host4
I can create a puppet manifest to write the file, but I'm not sure how I
could make the IPs available as global facts to all hosts in the hostgroup.
Why create one, there are a couple of them allready on puppetforge ->
https://forge.puppetlabs.com/modules?utf-8=✓&sort=downloads&os=redhat&q=hosts
For example:
https://forge.puppetlabs.com/treydock/dynamic_hosts
Met vriendelijke groet, With kind regards,
Jorick Astrego
Netbulae Virtualization Experts
···
On 01/26/2015 11:03 PM, Dave Johnston wrote:
> Hi,
>
> I have 4 hosts as part of a hostgroup.
> I was wondering if there is way to use foreman and puppet to write
> /etc/hosts entries on all four hosts i.e. so each host would contain a
> file with the following
>
> /etc/hosts:
> 1.2.3.4 host1
> 1.2.3.5 host2
> 1.2.3.6 host3
> 1.2.3.7 host4
>
> I can create a puppet manifest to write the file, but I'm not sure how
> I could make the IPs available as global facts to all hosts in the
> hostgroup.
> --
Tel: 053 20 30 270 info@netbulae.eu Staalsteden 4-3A KvK 08198180
Fax: 053 20 30 271 www.netbulae.eu 7547 TA Enschede BTW NL821234584B01
> Hi,
>
> I have 4 hosts as part of a hostgroup.
> I was wondering if there is way to use foreman and puppet to write
> /etc/hosts entries on all four hosts i.e. so each host would contain a file
> with the following
>
> /etc/hosts:
> 1.2.3.4 host1
> 1.2.3.5 host2
> 1.2.3.6 host3
> 1.2.3.7 host4
>
> I can create a puppet manifest to write the file, but I'm not sure how I
> could make the IPs available as global facts to all hosts in the hostgroup.
>
using the API you can easily query for all hosts in a given condition (such
as a hostgroup = '…').
there is already a puppet function that does exactly that at [1] and a very
old blog i wrote about it at [2]
Ohad
[1]
https://github.com/theforeman/puppet-foreman/blob/master/lib/puppet/parser/functions/foreman.rb
[2]
···
On Tue, Jan 27, 2015 at 12:03 AM, Dave Johnston wrote:
–
You received this message because you are subscribed to the Google Groups
“Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.
Thanks, but I think you have mis-understood the question.
Using puppet to write the hosts is not the problem. My problem is how can
I use puppet to obtain the information from foreman in the first place.
i.e. get fetch a list of hosts that belong to a speciifed group, and obtain
there IPs.
···
On Tuesday, 27 January 2015 13:17:51 UTC, Jorick Astrego wrote:
>
>
> On 01/26/2015 11:03 PM, Dave Johnston wrote:
> > Hi,
> >
> > I have 4 hosts as part of a hostgroup.
> > I was wondering if there is way to use foreman and puppet to write
> > /etc/hosts entries on all four hosts i.e. so each host would contain a
> > file with the following
> >
> > /etc/hosts:
> > 1.2.3.4 host1
> > 1.2.3.5 host2
> > 1.2.3.6 host3
> > 1.2.3.7 host4
> >
> > I can create a puppet manifest to write the file, but I'm not sure how
> > I could make the IPs available as global facts to all hosts in the
> > hostgroup.
> > --
>
> Why create one, there are a couple of them allready on puppetforge ->
>
> https://forge.puppetlabs.com/modules?utf-8=%E2%9C%93&sort=downloads&os=redhat&q=hosts
>
>
> For example:
>
> https://forge.puppetlabs.com/treydock/dynamic_hosts
>
>
>
>
>
> Met vriendelijke groet, With kind regards,
>
> Jorick Astrego
>
> *Netbulae Virtualization Experts *
> ------------------------------
> Tel: 053 20 30 270 in...@netbulae.eu Staalsteden 4-3A KvK
> 08198180 Fax: 053 20 30 271 www.netbulae.eu 7547 TA Enschede BTW
> NL821234584B01
> ------------------------------
>
>
Hi Ohad,
Thanks I came across your post - it got me started in the right direction.
It seems the foreman.rb has changed a little since them, as now you have to
pass in a hash object directly.
Anyway it got me a little closer. I was able to get all hosts for my
hostgroup, unfortunately I wasn't able to get the hosts back with IP, I
guess I need to iterate over the hash and make a subsequent requests for
facts.
···
On Tuesday, 27 January 2015 14:53:03 UTC, ohad wrote:
>
>
>
> On Tue, Jan 27, 2015 at 12:03 AM, Dave Johnston > wrote:
>
>> Hi,
>>
>> I have 4 hosts as part of a hostgroup.
>> I was wondering if there is way to use foreman and puppet to write
>> /etc/hosts entries on all four hosts i.e. so each host would contain a file
>> with the following
>>
>> /etc/hosts:
>> 1.2.3.4 host1
>> 1.2.3.5 host2
>> 1.2.3.6 host3
>> 1.2.3.7 host4
>>
>> I can create a puppet manifest to write the file, but I'm not sure how I
>> could make the IPs available as global facts to all hosts in the hostgroup.
>>
>
> using the API you can easily query for all hosts in a given condition
> (such as a hostgroup = '..').
> there is already a puppet function that does exactly that at [1] and a
> very old blog i wrote about it at [2]
>
> Ohad
>
> [1]
> https://github.com/theforeman/puppet-foreman/blob/master/lib/puppet/parser/functions/foreman.rb
> [2]
> http://blog.theforeman.org/2012/01/getting-foreman-search-results-into.html
>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Foreman users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to foreman-user...@googlegroups.com .
>> To post to this group, send email to forema...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/foreman-users.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> Hi Ohad,
>
> Thanks I came across your post - it got me started in the right direction.
>
> It seems the foreman.rb has changed a little since them, as now you have
> to pass in a hash object directly.
> Anyway it got me a little closer. I was able to get all hosts for my
> hostgroup, unfortunately I wasn't able to get the hosts back with IP, I
> guess I need to iterate over the hash and make a subsequent requests for
> facts.
>
> both should normally not be required… the default query for a list of
hosts returns the hosts primary ip. what exactly are you doing?
Ohad
···
On Tue, Jan 27, 2015 at 6:45 PM, Dave Johnston wrote:
On Tuesday, 27 January 2015 14:53:03 UTC, ohad wrote:
On Tue, Jan 27, 2015 at 12:03 AM, Dave Johnston dave.j...@me.com wrote:
Hi,
I have 4 hosts as part of a hostgroup.
I was wondering if there is way to use foreman and puppet to write
/etc/hosts entries on all four hosts i.e. so each host would contain a file
with the following
/etc/hosts:
1.2.3.4 host1
1.2.3.5 host2
1.2.3.6 host3
1.2.3.7 host4
I can create a puppet manifest to write the file, but I’m not sure how I
could make the IPs available as global facts to all hosts in the hostgroup.
using the API you can easily query for all hosts in a given condition
(such as a hostgroup = ‘…’).
there is already a puppet function that does exactly that at [1] and a
very old blog i wrote about it at [2]
Ohad
[1] https://github.com/theforeman/puppet-foreman/
blob/master/lib/puppet/parser/functions/foreman.rb
[2] http://blog.theforeman.org/2012/01/getting-foreman-
search-results-into.html
–
You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-user...@googlegroups.com.
To post to this group, send email to forema...@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.
–
You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.