help with ghoneycutt hosts on PE

328 views
Skip to first unread message

Aaron Lager

unread,
Jun 26, 2015, 8:26:49 PM6/26/15
to puppet...@googlegroups.com
I'm evaluating PE and after the super simple success of the ntp example, I thought I'd try out the /etc/hosts modules.
I'm trying to add additional host entries, but all that happens is my existing additional entries (including one for puppet) get removed from the nodes host file.

Here is my value for host_entries:
{"10.150.28.8":"puppet.mybluebolt.com"}

There are no errors reported, that I'm aware of.  The documentation simply says it's a Hash of host entries.
I don't understand what I am doing wrong.

Thanks for any help you can give.

Aaron

Johan De Wit

unread,
Jun 27, 2015, 7:32:54 AM6/27/15
to puppet...@googlegroups.com

purge_hosts

Boolean to optionally purge unmanaged entries from hosts

  • Default: false

Check this parameter.  When set to true, yuo will have the behaviour you describe.

--
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/9dc28aec-ed57-4929-825d-5342ab3239c1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-- 
Johan De Wit

Open Source Consultant

Red Hat Certified Engineer              (805008667232363)
Puppet Certified Professional 2013/2014/2015 (PCP0000006)
Puppet Certified Instructor
blog : http://johan.koewacht.net/
_________________________________________________________
  

Upcoming Trainings:

Bacula Administrator I | http://www.open-future.be/bacula-administrator-i-training-23rd-till-25th-june

Zabbix Certified Specialist | http://www.open-future.be/zabbix-certified-specialist-training-7th-till-9thth-september

Zabbix Certified Professional | http://www.open-future.be/zabbix-certified-professional-training-10th-till-11th-september

Puppet Fundamentals | http://www.open-future.be/puppet-fundamentals-training-14th-till-16th-september

Puppet Architect | http://www.open-future.be/puppet-architect-training-17th-till-18th-september

Bacula Administrator I | http://www.open-future.be/bacula-administrator-i-training-22nd-till-24th-september

Linux Training | http://www.open-future.be/linux-training-28th-till-2nd-october

Subscribe to our newsletter: http://eepurl.com/BUG8H


jcbollinger

unread,
Jun 29, 2015, 9:46:57 AM6/29/15
to puppet...@googlegroups.com
I cannot say exactly what you're doing wrong, as I am uncertain what "the" /etc/hosts modules are, or why anyone would need more than one such module.  You clearly are not talking about the standard Host resource type, as it has no parameter named "host_entries".

Inasmuch as the Host resource uses the hostname as its identifier, I suspect the wanted hash will have hostnames as keys.  I would not be surprised to hear that the expected form of the hash was something like this (YAML):

'hosts::hostentries':
 
'puppet.mybluebolt.com':
   
'ip': '10.150.28.8'
   
'host_aliases': 'puppet'  # optional; may also be an array

That matches up with the underlying Host resource type, and it is the form that would be used with the standard create_resources() function.  This is all an educated guess, however, inasmuch as I don't know what module you are in fact using.  Any way around, I'm sure PL would appreciate feedback about the shortcomings of its documentation on this point.  They might pick it up from your post here, as several employees do participate, but you cannot rely on that.


Regards,

John

Aaron Lager

unread,
Jun 29, 2015, 12:59:11 PM6/29/15
to puppet...@googlegroups.com
The purge_hosts parameter was not set, so should be default to false.  I now have it explicitly set to false, and I get the same behavior.
How can I figure out where the files are stored, so I can inspect the puppet file to see if there is something else that is set that PE isn't showing on via the dash board?

Thanks,
Aaron

Aaron Lager

unread,
Jun 29, 2015, 1:06:20 PM6/29/15
to puppet...@googlegroups.com
@John, the host modules are for maintaining the /etc/hosts files.  On windows it's located in %systemroot%\system32\drivers\etc\hosts
ghoneycutt-hosts is the module I'm trying to use.

I've tried with the hash both ways:
{"10.150.28.8":"puppet.mybluebolt.com"}
or
{"puppet.mybluebolt.com":"10.150.28.8"}

The result is the same, the file is reverted back to :
#
# THIS FILE IS MANAGED BY PUPPET
# /etc/puppetlabs/puppet/environments/production/modules/hosts/templates/trusty/etc/hosts.erb
#

127.0.0.1       localhost
10.150.28.4     AVC2-WUS1-APP01.AVC2-WUS1-CS1.d6.internal.cloudapp.net  AVC2-WUS1-APP01

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters


Is there a log file somewhere that might hint at what is going on?

Thanks,
Aaron

Aaron Lager

unread,
Jun 29, 2015, 1:11:05 PM6/29/15
to puppet...@googlegroups.com
Okay, I have my first clue:
# THIS FILE IS MANAGED BY PUPPET
# /etc/puppetlabs/puppet/environments/production/modules/hosts/templates/trusty/etc/hosts.erb

This file does not exist....nice!

Aaron Lager

unread,
Jun 29, 2015, 5:01:36 PM6/29/15
to puppet...@googlegroups.com
So I started over from scratch, and now I get the following error on the agent:
 sudo puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert Array into Hash at /etc/puppetlabs/puppet/environments/production/modules/hosts/manifests/init.pp:149 on node

line 149 is
146   if $host_entries != undef {
147     $host_entries_real = delete($host_entries,$::fqdn)
148     validate_hash($host_entries_real)
149     create_resources(host,$host_entries_real)
150   }


What is wrong with my syntax?

Aaron

jcbollinger

unread,
Jun 30, 2015, 12:04:51 PM6/30/15
to puppet...@googlegroups.com


On Monday, June 29, 2015 at 4:01:36 PM UTC-5, Aaron Lager wrote:
So I started over from scratch, and now I get the following error on the agent:
 sudo puppet agent --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: can't convert Array into Hash at /etc/puppetlabs/puppet/environments/production/modules/hosts/manifests/init.pp:149 on node

line 149 is
146   if $host_entries != undef {
147     $host_entries_real = delete($host_entries,$::fqdn)
148     validate_hash($host_entries_real)
149     create_resources(host,$host_entries_real)
150   }


What is wrong with my syntax?



The module is using the create_resources() function, so the expected form for your data is exactly the one I guessed in my previous message: a hash in which the keys are host names (corresponding to Host resource names / titles), and the values are themselves hashes associating Host resource parameter names with values.  In addition to the example data, I provided links to the docs for the create_resources() function and the Host resource.  The error message seems to indicate that the data the module receives are formed differently than it expects, which would be true of both the forms you described using.


John

Aaron Lager

unread,
Jun 30, 2015, 12:45:03 PM6/30/15
to puppet...@googlegroups.com
@John, thanks for your patients with me.  I'm a total noob at this stuff.  Following the links you gave me, I came up with this: {name  => 'foo', ip => '192.168.168.1'}
But the agent says:
 Error 400 on SERVER: "{name  => 'foo', ip => '192.168.168.1'}" is not a Hash. 

The image below from the PE dashboard is why I was trying JSON format previously.



When I use JSON format, it says it can't convert it into a Hash.

Using your provided sample snippet:
Error 400 on SERVER: "'hosts::hostentries':   'puppet.mybluebolt.com':     'ip': '10.150.28.8'     'host_aliases': 'puppet'" is not a Hash.

I fee like I'm a fish flopping around on the ground...

Aaron Lager

unread,
Jun 30, 2015, 1:02:31 PM6/30/15
to puppet...@googlegroups.com
Using a JSON validation tool, I massaged your sample into:
{     "hosts: : hostentries": "puppet.mybluebolt.com",     "ip": "10.150.28.8",     "host_aliases": "puppet" }

But the agent still doesn't like it:
Error 400 on SERVER: can't convert String into Hash 

argh!


On Tuesday, June 30, 2015 at 9:04:51 AM UTC-7, jcbollinger wrote:

Aaron Lager

unread,
Jun 30, 2015, 6:49:25 PM6/30/15
to puppet...@googlegroups.com
Answer from puppetlabs that works:
{"hostname.example.com":{"ip":"1.2.3.4","host_aliases":"an_alias"}}

yay!

Aaron Lager

unread,
Jun 30, 2015, 7:13:13 PM6/30/15
to puppet...@googlegroups.com
And final post, an example of two hosts:
{"hostname.example.com":{"ip":"1.2.3.4","host_aliases":"an_alias"}, "hostname2.example.com":{"ip":"1.2.3.5","host_aliases":"an_alias2"}}
Reply all
Reply to author
Forward
0 new messages