Commit e188dd8f authored by Silvio Rhatto's avatar Silvio Rhatto

Trying a different approach to realize exported resources

parent b17704f7
define backupninja_server_realize($host) {
User <<| tag == "backupninja-$host" |>>
File <<| tag == "backupninja-$host" |>>
Ssh_authorized_key <<| tag == "backupninja-$host" |>>
}
class backupninja::server {
$real_backupdir = $backupdir ? {
......@@ -46,9 +52,8 @@ class backupninja::server {
}
}
User <<| tag == "backupninja-$real_backupserver_tag" |>>
File <<| tag == "backupninja-$real_backupserver_tag" |>>
Ssh_authorized_key <<| tag == "backupninja-$real_backupserver_tag" |>>
# collect all resources from hosted backups
Backupninja_server_realize <| tag == "$real_backupserver_tag" |>
if !defined(Package["rsync"]) {
if $rsync_ensure_version == '' { $rsync_ensure_version = 'installed' }
......@@ -91,7 +96,7 @@ class backupninja::server {
default => $authorized_keys_file,
}
$real_backuptag = $backuptag ? {
false => "backupninja-$real_host",
false => "backupninja-$fqdn",
default => $backuptag,
}
......@@ -105,6 +110,11 @@ class backupninja::server {
nagios2::passive_service { "backups-${name}": nagios2_host_name => $real_host, nagios2_description => $real_nagios2_description, servicegroups => "backups" }
}
@@backupninja_server_realize { "${fqdn}-${real_host}":
host => $fqdn,
tag => $real_host,
}
if !defined(File["$real_dir"]) {
@@file { "$real_dir":
ensure => directory,
......@@ -112,11 +122,6 @@ class backupninja::server {
tag => "$real_backuptag",
}
}
else {
File["$real_dir"] {
tag +> "$real_backuptag",
}
}
case $installuser {
true: {
case $manage_ssh_dir {
......@@ -129,11 +134,6 @@ class backupninja::server {
tag => "$real_backuptag",
}
}
else {
File["$real_ssh_dir"] {
tag +> "$real_backuptag",
}
}
}
}
case $key {
......@@ -147,11 +147,6 @@ class backupninja::server {
tag => "$real_backuptag",
}
}
else {
File["${real_ssh_dir}/${real_authorized_keys_file}"] {
tag +> "$real_backuptag",
}
}
}
default: {
if !defined(Ssh_autorized_key["$real_user"]) {
......@@ -164,11 +159,6 @@ class backupninja::server {
require => User[$real_user],
}
}
else {
Ssh_authorized_key["$real_user"] {
tag +> "$real_backuptag",
}
}
}
}
case $uid {
......@@ -186,11 +176,6 @@ class backupninja::server {
tag => "$real_backuptag"
}
}
else {
User["$real_user"] {
tag +> "$real_backuptag",
}
}
}
default: {
if !defined(User["$real_user"]) {
......@@ -207,11 +192,6 @@ class backupninja::server {
tag => "$real_backuptag"
}
}
else {
User["$real_user"] {
tag +> "$real_backuptag",
}
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment