Merge remote-tracking branch 'stapelberg/dyn'
[mirror/dsa-puppet.git] / modules / onion / manifests / service.pp
index deaefa1..80d6922 100644 (file)
@@ -26,26 +26,27 @@ define onion::service (
                $onion_hn = onion_tor_service_hostname($name)
                if $onion_hn {
                        $hostname_without_onion = regsubst($onion_hn, '\.onion$', '')
-                       @@concat::fragment { "onion::balance::instance::$name::$fqdn":
-                               target  => "/etc/onionbalance/config.yaml",
-                               content => "      - address: ${hostname_without_onion}\n        name: ${hostname}-${name}\n",
-                               order   => "50-${name}-20",
-                               tag     => "onion::balance::$name",
-                       }
 
                        if ($direct) {
                                @@concat::fragment { "onion::balance::onionbalance-services.yaml::${name}":
-                                       target  => "/srv/puppet.torproject.org/puppet-facts/onionbalance-services.yaml",
+                                       target  => "/srv/puppet.debian.org/puppet-facts/onionbalance-services.yaml",
                                        content => "{\"${name}\": \"${onion_hn}\"}\n",
                                        tag     => "onionbalance-services.yaml",
                                }
                        } else {
                                @@concat::fragment { "onion::balance::instance::dsa-snippet::$name::$fqdn":
                                        target  => "/etc/onionbalance/config-dsa-snippet.yaml",
-                                       content => "- service: ${name}\n  address: ${hostname_without_onion}\n  host: ${hostname}-${name}\n",
+                                       content => "- service: ${name}\n  address: ${hostname_without_onion}\n  name: ${hostname}-${name}\n",
                                        tag     => "onion::balance::dsa-snippet",
                                }
                        }
                }
+       } elsif ($my_ensure == "absent") {
+               file { "/var/lib/tor/onion/${name}":
+                       ensure => absent,
+                       force  => true,
+               }
+       } else {
+               fail("Invalid ensure value ${my_ensure}")
        }
 }