From 720c1670750345e8c361219a58c2722a603e26bb Mon Sep 17 00:00:00 2001 From: mh Date: Tue, 1 Nov 2016 20:26:20 +0100 Subject: add support for onionbalance --- manifests/onionbalance.pp | 81 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 manifests/onionbalance.pp (limited to 'manifests/onionbalance.pp') diff --git a/manifests/onionbalance.pp b/manifests/onionbalance.pp new file mode 100644 index 0000000..34831d3 --- /dev/null +++ b/manifests/onionbalance.pp @@ -0,0 +1,81 @@ +# manages an onionbalance installation +# +# Parameters: +# +# services: a hash of onionbalance service instances +# services => { +# keyname_of_service1 => { +# name1 => onionservice_addr_3, +# name2 => onionservice_addr_2, +# _key_content => content_of_key_of_onionbalanced_service1, +# }, +# } +# +class tor::onionbalance( + $services, +) { + + include ::tor + + case $osfamily { + 'Debian': { + $pkg_name = 'onionbalance' + $instance_file = '/etc/tor/instances/onionbalance/torrc' + $instance_user = '_tor-onionbalance' + exec{'/usr/sbin/tor-instance-create onionbalance': + creates => '/etc/tor/instances/onionbalance', + require => Package['tor'], + before => File[$instance_file], + } -> augeas{"manage_onionbalance_in_group_${instance_user}": + context => '/files/etc/group', + changes => [ "set ${instance_user}/user[last()+1] onionbalance" ], + onlyif => "match ${instance_user}/*[../user='onionbalance'] size == 0", + require => Package['onionbalance'], + } + } + 'RedHat': { + $instance_file = '/etc/tor/onionbalance.torrc' + $instance_user = 'toranon' + $pkg_name = 'python2-onionbalance' + } + default: { + fail("OSFamily ${osfamily} not (yet) supported for onionbalance") + } + } + + package{$pkg_name: + ensure => 'installed', + tag => 'onionbalance', + } -> file{ + '/etc/onionbalance/config.yaml': + content => template('tor/onionbalance/config.yaml.erb'), + owner => root, + group => $instance_user, + mode => '0640', + notify => Service['onionbalance']; + $instance_file: + content => template("tor/onionbalance/${osfamily}.torrc.erb"), + owner => root, + group => 0, + mode => '0644', + require => Package['tor'], + notify => Service['tor@onionbalance'], + } + + tor::onionbalance::keys{ + keys($services): + values => $services, + group => $instance_user, + } + + service{ + 'tor@onionbalance': + ensure => running, + enable => true; + 'onionbalance': + ensure => running, + enable => true, + subscribe => Service['tor@onionbalance']; + } + +} -- cgit v1.2.3 From b80f81eb4594ddd4a2a62f21b0c5802e762f8fcc Mon Sep 17 00:00:00 2001 From: mh Date: Thu, 10 Nov 2016 02:13:04 +0100 Subject: make it work with the old parser --- manifests/onionbalance.pp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'manifests/onionbalance.pp') diff --git a/manifests/onionbalance.pp b/manifests/onionbalance.pp index 34831d3..6a6b476 100644 --- a/manifests/onionbalance.pp +++ b/manifests/onionbalance.pp @@ -62,8 +62,9 @@ class tor::onionbalance( notify => Service['tor@onionbalance'], } + $keys = keys($services) tor::onionbalance::keys{ - keys($services): + $keys: values => $services, group => $instance_user, } -- cgit v1.2.3