My env is facter 1.5.7, puppet 0.25.1.

  I am trying to (without resorting to exec) manage my hosts file so
that I remove the "loghost" alias which is associated with the system
hostname.

   For example on a stock Solaris install you'll see this line in the
hosts file

172.33.12.2      dev-sandbox     loghost

   Then when you decide to send log's off host you'd break out the
above line to be

172.33.12.2      dev-sandbox
172.33.12.19    loghost

   So based off some other posts on this topic and the handy docs I
thought I was clever with the following puppet bits.   While this does
what I want the first time.  Each following run it appears to remove
the invisible alias "" and modifies the hosts file each run.

node dev-sandbox {
        $my_syslog_server = "1.1.1.1"

host { "loghost_hosts_entry":
            ensure => "present",
            ip     => "$my_syslog_server",
            name   => "loghost",
        }

        # Remove the default loghost alias if we point loghost off
host
        host { "loghost_hosts_alias":
            alias  => "",
            name   => "$hostname",
            ip     => "$ipaddress",
            ensure => "present",
        }

}


  Here is the output from running the above script a few times.

grep loghost /etc/inet/hosts
172.33.12.2      dev-sandbox     loghost

puppet loghost.pp

info: Applying configuration version '1265821768'
debug: //Node[dev-sandbox]/Host[loghost_hosts_entry]: Changing ensure
debug: //Node[dev-sandbox]/Host[loghost_hosts_entry]: 1 change(s)
notice: //Node[dev-sandbox]/Host[loghost_hosts_entry]/ensure: created
debug: Flushing host provider target /etc/inet/hosts
debug: Finishing transaction 76312890 with 0 changes
info: Filebucket[/var/puppet/clientbucket]: Adding /etc/inet/
hosts(6b5a890ed909eb6ea5911e8975d3118b)
debug: //Node[dev-sandbox]/Host[loghost_hosts_alias]: Changing alias
debug: //Node[dev-sandbox]/Host[loghost_hosts_alias]: 1 change(s)
notice: //Node[dev-sandbox]/Host[loghost_hosts_alias]/alias: alias
changed 'loghost' to ''
debug: Flushing host provider target /etc/inet/hosts
debug: Finishing transaction 69468620 with 2 changes

the related lines in the hosts file now read

172.33.12.2     dev-sandbox
1.1.1.1 loghost

Running puppet again modifies the hosts file

puppet loghost.pp

info: Applying configuration version '1265821808'
debug: //Node[dev-sandbox]/Host[loghost_hosts_alias]: Changing alias
debug: //Node[dev-sandbox]/Host[loghost_hosts_alias]: 1 change(s)
notice: //Node[dev-sandbox]/Host[loghost_hosts_alias]/alias: alias
changed 'absent' to ''
debug: Flushing host provider target /etc/inet/hosts
debug: Finishing transaction 76308800 with 0 changes

   The only actual content that is getting changed in the hosts file
is the header line but I would prefer that not happen.  This was the
closest I could get to the desired functionality and I'm wondering if
someone could point out my failings?
   TIA.  Derek.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to