Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: modules/base/manifests/init.pp

Issue 4810150141493248: Issue 122 - Puppet ENC via Hiera (Closed)
Patch Set: 112 - Puppet ENC via Hiera Created Oct. 8, 2014, 3:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: modules/base/manifests/init.pp
===================================================================
--- a/modules/base/manifests/init.pp
+++ b/modules/base/manifests/init.pp
@@ -1,4 +1,4 @@
-class base {
+class base ($authority='adblockplus.org') {
stage {'pre': before => Stage['main']}
stage {'post': require => Stage['main']}
@@ -39,4 +39,45 @@
class {'logrotate':
stage => 'post'
}
+
+ $servers = hiera("servers")
+ create_resources(base::explicit_host_record, $servers)
+
+ define explicit_host_record($ip, $ssh_public_key=undef, $role=undef, $dns=undef) {
+
+ if is_array($ip) {
+ $internal_ip = $ip[0]
+ } else {
+ $internal_ip = $ip
+ }
+
+ $fqdn_name = join([$name, $authority], ".")
+
+ host{"$name,$internal_ip":
Wladimir Palant 2014/11/17 16:43:36 Given that each name is resolved to a single IP ad
mathias 2014/11/27 00:30:18 Done.
+ ensure => present,
+ ip => $internal_ip,
+ name => $fqdn_name,
+ host_aliases => $dns ? {
+ undef => [],
+ default => $dns,
+ }
+ }
+
+ if $ssh_public_key != undef {
+
+ $name_key = $dns ? {
+ undef => $fqdn_name,
+ default => $dns,
+ }
+
+ @sshkey {$name:
+ name => $name_key,
+ key => $ssh_public_key,
+ type => ssh-rsa,
+ host_aliases => $ip,
+ }
+ }
+
+ }
}
+

Powered by Google App Engine
This is Rietveld