summaryrefslogtreecommitdiff
path: root/puppet
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-06-04 14:19:55 -0700
committerelijah <elijah@riseup.net>2014-06-04 14:19:55 -0700
commitf991e8a4c877cff1d274fd1cac26488f8c3fda84 (patch)
treea43a6f15bc9490fc40fb30e43b483d814770796e /puppet
parent79295764ebbefd346407b8042bc759552aa46234 (diff)
clean up how /etc/hosts is generated so it doesn't require custom behavior depending on the services.0.5.2
Diffstat (limited to 'puppet')
-rw-r--r--puppet/modules/site_config/manifests/default.pp3
-rw-r--r--puppet/modules/site_config/manifests/hosts.pp16
-rw-r--r--puppet/modules/site_config/manifests/setup.pp5
-rw-r--r--puppet/modules/site_config/templates/hosts3
4 files changed, 16 insertions, 11 deletions
diff --git a/puppet/modules/site_config/manifests/default.pp b/puppet/modules/site_config/manifests/default.pp
index dfdffe03..fc2179de 100644
--- a/puppet/modules/site_config/manifests/default.pp
+++ b/puppet/modules/site_config/manifests/default.pp
@@ -1,6 +1,7 @@
class site_config::default {
tag 'leap_base'
+ $services = hiera('services', [])
$domain_hash = hiera('domain')
include site_config::params
@@ -54,7 +55,7 @@ class site_config::default {
# set up core leap files and directories
include site_config::files
- if $::services !~ /\bmx\b/ {
+ if ! member($services, 'mx') {
include site_postfix::satellite
}
diff --git a/puppet/modules/site_config/manifests/hosts.pp b/puppet/modules/site_config/manifests/hosts.pp
index e5d4dd70..6982d37b 100644
--- a/puppet/modules/site_config/manifests/hosts.pp
+++ b/puppet/modules/site_config/manifests/hosts.pp
@@ -1,9 +1,19 @@
class site_config::hosts() {
$hosts = hiera('hosts', false)
+
+ # calculate all the hostname aliases that might be used
$hostname = hiera('name')
- $domain_hash = hiera('domain')
- $domain_public = $domain_hash['full_suffix']
- $api = hiera('api', '')
+ $domain_hash = hiera('domain', {})
+ $dns = hiera('dns', {})
+ if $dns['aliases'] == undef {
+ $dns_aliases = []
+ } else {
+ $dns_aliases = $dns['aliases']
+ }
+ $my_hostnames = unique(sort(concat(
+ [$hostname, $domain_hash['full'], $domain_hash['internal']],
+ $dns_aliases
+ )))
file { '/etc/hostname':
ensure => present,
diff --git a/puppet/modules/site_config/manifests/setup.pp b/puppet/modules/site_config/manifests/setup.pp
index 01dea723..b09d0413 100644
--- a/puppet/modules/site_config/manifests/setup.pp
+++ b/puppet/modules/site_config/manifests/setup.pp
@@ -4,7 +4,6 @@ class site_config::setup {
#
# this is applied before each run of site.pp
#
- #$services = ''
Exec { path => '/usr/bin:/usr/sbin/:/bin:/sbin:/usr/local/bin:/usr/local/sbin' }
@@ -13,10 +12,6 @@ class site_config::setup {
include concat::setup
include stdlib
-
- # parse services for host
- $services=join(hiera_array('services', ['']), ' ')
-
# configure /etc/hosts
class { 'site_config::hosts':
stage => setup,
diff --git a/puppet/modules/site_config/templates/hosts b/puppet/modules/site_config/templates/hosts
index bfcabaa5..d557f730 100644
--- a/puppet/modules/site_config/templates/hosts
+++ b/puppet/modules/site_config/templates/hosts
@@ -1,8 +1,7 @@
# This file is managed by puppet, any changes will be overwritten!
127.0.0.1 localhost
-127.0.1.1 <%= @hostname %>.<%= @domain_public %> <%= @hostname %> <% if (defined? @services) and (@services.include? 'webapp') -%><%= @domain_public %> <%= @api['domain'] %><% end -%>
-
+127.0.1.1 <%= @my_hostnames.join(' ') %>
<%- if @hosts then -%>
<% @hosts.keys.sort.each do |name| -%>