aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO.md2
-rw-r--r--manifests/bootstrap/configurator.pp99
-rw-r--r--templates/puppet/nodes.pp.erb20
3 files changed, 65 insertions, 56 deletions
diff --git a/TODO.md b/TODO.md
index 165eb3d..b61c86c 100644
--- a/TODO.md
+++ b/TODO.md
@@ -3,4 +3,4 @@ TODO
* Make `config` target:
* Check if already ran.
- * Refactor `configurator.pp`.
+ * Fail on empty variables.
diff --git a/manifests/bootstrap/configurator.pp b/manifests/bootstrap/configurator.pp
index ce60731..56f234f 100644
--- a/manifests/bootstrap/configurator.pp
+++ b/manifests/bootstrap/configurator.pp
@@ -12,7 +12,9 @@
# Basic variables
#
$templates = "$bootstrap_path/templates"
-$base_domain = hiera('bootstrap::base_domain', 'example.org')
+$base_domain = hiera('bootstrap::base_domain', "${::domain}")
+$first_hostname = hiera('bootstrap::first_hostname', "${::hostname}")
+$first_nodes = hiera('bootstrap::first_nodes', 'absent')
$db_password = hiera('nodo::role::master::db_password', 'changeme')
$mysql_rootpw = hiera('mysql::server::rootpw', '')
$root_password = hiera('bootstrap::root:password', 'rootpass')
@@ -133,51 +135,50 @@ file { "$bootstrap_path/modules/site_postfix/files/tls_policy":
#
# Basic nodes
#
-#file { "$bootstrap_path/manifests/nodes.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/nodes.pp.erb"),
-#}
-
-## First host
-#file { "$bootstrap_path/manifests/nodes/$hostname.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/server.pp.erb"),
-#}
-#
-## Master node
-#file { "$bootstrap_path/manifests/nodes/$hostname-master.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/master.pp.erb"),
-#}
-#
-## Proxy node
-#file { "$bootstrap_path/manifests/nodes/$hostname-proxy.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/proxy.pp.erb"),
-#}
-#
-## Web node
-#file { "$bootstrap_path/manifests/nodes/$hostname-web.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/web.pp.erb"),
-#}
-#
-## Storage node
-#file { "$bootstrap_path/manifests/nodes/$hostname-storage.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/storage.pp.erb"),
-#}
-#
-## Test node
-#file { "$bootstrap_path/manifests/nodes/$hostname-test.pp":
-# ensure => present,
-# mode => 0644,
-# content => template("$templates/puppet/test.pp.erb"),
-#}
-#
+file { "$bootstrap_path/manifests/nodes.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/nodes.pp.erb"),
+}
+
+# First host
+file { "$bootstrap_path/manifests/nodes/$first_hostname.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/server.pp.erb"),
+}
+
+# Master node
+file { "$bootstrap_path/manifests/nodes/$first_hostname-master.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/master.pp.erb"),
+}
+
+# Proxy node
+file { "$bootstrap_path/manifests/nodes/$first_hostname-proxy.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/proxy.pp.erb"),
+}
+
+# Web node
+file { "$bootstrap_path/manifests/nodes/$first_hostname-web.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/web.pp.erb"),
+}
+
+# Storage node
+file { "$bootstrap_path/manifests/nodes/$first_hostname-storage.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/storage.pp.erb"),
+}
+
+# Test node
+file { "$bootstrap_path/manifests/nodes/$first_hostname-test.pp":
+ ensure => $first_nodes,
+ mode => 0644,
+ content => template("$templates/puppet/test.pp.erb"),
+}
diff --git a/templates/puppet/nodes.pp.erb b/templates/puppet/nodes.pp.erb
index 15290d8..4acddc6 100644
--- a/templates/puppet/nodes.pp.erb
+++ b/templates/puppet/nodes.pp.erb
@@ -1,6 +1,14 @@
-import "nodes/<%= hostname %>.pp"
-import "nodes/<%= hostname %>-master.pp"
-import "nodes/<%= hostname %>-proxy.pp"
-import "nodes/<%= hostname %>-web.pp"
-import "nodes/<%= hostname %>-storage.pp"
-import "nodes/<%= hostname %>-test.pp"
+#
+# Node definitions.
+#
+
+<%- if first_nodes == 'present' then -%>
+import "nodes/<%= first_hostname %>.pp"
+import "nodes/<%= first_hostname %>-master.pp"
+import "nodes/<%= first_hostname %>-proxy.pp"
+import "nodes/<%= first_hostname %>-web.pp"
+import "nodes/<%= first_hostname %>-storage.pp"
+import "nodes/<%= first_hostname %>-test.pp"
+<%- else -%>
+#import "nodes/example.pp"
+<%- end -%>