From cbb834da5de7e2abe7399e34766492bfab48fa9c Mon Sep 17 00:00:00 2001 From: Micah Anderson Date: Tue, 11 Dec 2012 15:37:15 -0500 Subject: test to see if the hosts value is empty before trying to reference it in a template also set the hostname to what the hiera 'name' is set to --- puppet/modules/site_config/manifests/hosts.pp | 10 ++++++++++ puppet/modules/site_config/templates/hosts | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'puppet/modules/site_config') diff --git a/puppet/modules/site_config/manifests/hosts.pp b/puppet/modules/site_config/manifests/hosts.pp index 08890a5d..5269bf35 100644 --- a/puppet/modules/site_config/manifests/hosts.pp +++ b/puppet/modules/site_config/manifests/hosts.pp @@ -1,5 +1,15 @@ class site_config::hosts { + $hosts = hiera('hosts','') + $hostname = hiera('name') + + exec { "/bin/hostname $hostname ": } + + file { "/etc/hostname": + ensure => present, + content => $hostname + } + file { '/etc/hosts': content => template('site_config/hosts'), mode => '0644', owner => root, group => root; diff --git a/puppet/modules/site_config/templates/hosts b/puppet/modules/site_config/templates/hosts index 1a12addc..c516eaf8 100644 --- a/puppet/modules/site_config/templates/hosts +++ b/puppet/modules/site_config/templates/hosts @@ -1,7 +1,9 @@ # This file is managed by puppet, any changes will be overwritten! -127.0.0.1 localhost -<%= scope.function_hiera('hosts') %> +127.0.0.1 localhost +<%- if hosts.to_s != '' then -%> +<%= hosts %> +<% end -%> # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback -- cgit v1.2.3