summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml60
-rw-r--r--provider_base/services/tor.json3
-rw-r--r--puppet/modules/site_static/manifests/hidden_service.pp27
-rw-r--r--puppet/modules/site_static/manifests/init.pp3
-rw-r--r--puppet/modules/site_tor/manifests/init.pp2
-rw-r--r--puppet/modules/site_webapp/manifests/hidden_service.pp25
-rw-r--r--puppet/modules/tor/.gitrepo6
-rw-r--r--puppet/modules/tor/README2
-rw-r--r--puppet/modules/tor/manifests/daemon/base.pp14
-rw-r--r--puppet/modules/tor/manifests/daemon/bridge.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/control.pp18
-rw-r--r--puppet/modules/tor/manifests/daemon/directory.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/dns.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/exit_policy.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/hidden_service.pp18
-rw-r--r--puppet/modules/tor/manifests/daemon/map_address.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/relay.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/snippet.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/socks.pp3
-rw-r--r--puppet/modules/tor/manifests/daemon/transparent.pp3
-rw-r--r--puppet/modules/tor/manifests/munin.pp2
-rw-r--r--puppet/modules/tor/manifests/repo.pp3
-rw-r--r--puppet/modules/tor/manifests/repo/debian.pp2
-rw-r--r--puppet/modules/tor/templates/torrc.directory.erb4
-rw-r--r--puppet/modules/tor/templates/torrc.global.erb4
-rw-r--r--puppet/modules/tor/templates/torrc.hidden_service.erb6
-rwxr-xr-xtests/platform-ci/ci-build.sh176
-rwxr-xr-xtests/platform-ci/setup.sh1
28 files changed, 256 insertions, 147 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ab2d5aa5..a1ad49a0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: leapcode/ruby
+image: 0xacab.org:4567/leap-docker/ruby:latest
# This is for caching the gems not only between the stages, but also persistent
# on the gitlab-runner so we don't need to install from scratch on every pipeline
@@ -14,7 +14,7 @@ before_script:
stages:
- setup
- syntax
- - build
+ - deploy
setup:
stage: setup
@@ -24,34 +24,74 @@ setup:
lint:
stage: syntax
script:
- - /usr/local/bin/bundle exec rake lint
+ - su -c '/usr/local/bin/bundle exec rake lint' cirunner
syntax:
stage: syntax
script:
- - /usr/local/bin/bundle exec rake syntax
+ - su -c '/usr/local/bin/bundle exec rake syntax' cirunner
validate:
stage: syntax
script:
- - /usr/local/bin/bundle exec rake validate
+ - su -c '/usr/local/bin/bundle exec rake validate' cirunner
templates:
stage: syntax
script:
- - /usr/local/bin/bundle exec rake templates
+ - su -c '/usr/local/bin/bundle exec rake templates' cirunner
catalog:
stage: syntax
script:
- - /usr/local/bin/bundle exec rake catalog
+ - su -c '/usr/local/bin/bundle exec rake catalog' cirunner
#rspec:
# stage: rspec
# script:
# - /usr/local/bin/bundle exec rake spec
-build:
- stage: build
+# The deploy_test job is run on any merge request. This is used to ensure that
+# the merge request will deploy and test properly. It is not run when the merge
+# request is accepted into master, instead the 'latest' job below is run
+# instead.
+deploy_test:
+ stage: deploy
+ except:
+ - master
script:
- - /usr/bin/unbuffer ./ci-build.sh | /usr/bin/ts -s
+ - su -c '/usr/bin/unbuffer bash -o pipefail ./ci-build.sh | /usr/bin/ts' cirunner
+
+# Latest job will only run on the master branch, which means all merge requests
+# that are created from branches don't get to deploy to the latest-ci server.
+# When a merge request is merged, then the latest job will deploy the code to
+# the latest provider, and the deployment will be recorded in an environment
+# named 'latest'
+ci.leap.se:
+ stage: deploy
+ environment:
+ name: staging
+ only:
+ - master
+ script:
+ - su -c '/usr/bin/unbuffer ./ci-build.sh' cirunner
+
+demo.bitmask.net:
+ stage: deploy
+ environment:
+ name: production/demo/vpn
+ only:
+ - master
+ when: manual
+ script:
+ - su -c '/usr/bin/unbuffer ./ci-build.sh' cirunner
+
+mail.bitmask.net:
+ stage: deploy
+ environment:
+ name: production/demo/mail
+ only:
+ - master
+ when: manual
+ script:
+ - su -c '/usr/bin/unbuffer ./ci-build.sh' cirunner
diff --git a/provider_base/services/tor.json b/provider_base/services/tor.json
index e80310fe..a0d44fef 100644
--- a/provider_base/services/tor.json
+++ b/provider_base/services/tor.json
@@ -9,7 +9,8 @@
"key_type": "RSA",
"public_key": "= tor_public_key_path(:node_tor_pub_key, tor.hidden_service.key_type) if tor.hidden_service.active",
"private_key": "= tor_private_key_path(:node_tor_priv_key, tor.hidden_service.key_type) if tor.hidden_service.active",
- "address": "=> tor.hidden_service.active && onion_address(:node_tor_pub_key)"
+ "address": "=> tor.hidden_service.active && onion_address(:node_tor_pub_key)",
+ "single_hop": false
}
}
}
diff --git a/puppet/modules/site_static/manifests/hidden_service.pp b/puppet/modules/site_static/manifests/hidden_service.pp
index f1f15f8e..b64a35bc 100644
--- a/puppet/modules/site_static/manifests/hidden_service.pp
+++ b/puppet/modules/site_static/manifests/hidden_service.pp
@@ -1,22 +1,25 @@
# create hidden service for static sites
-class site_static::hidden_service {
+class site_static::hidden_service ( $single_hop = false ) {
include tor::daemon
- tor::daemon::hidden_service { 'static': ports => [ '80 127.0.0.1:80'] }
+ tor::daemon::hidden_service { 'static':
+ ports => [ '80 127.0.0.1:80'],
+ single_hop => $single_hop
+ }
file {
'/var/lib/tor/webapp/':
- ensure => directory,
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '2700';
+ ensure => directory,
+ owner => 'debian-tor',
+ group => 'debian-tor',
+ mode => '2700';
'/var/lib/tor/static/private_key':
- ensure => present,
- source => "/srv/leap/files/nodes/${::hostname}/tor.key",
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0600',
- notify => Service['tor'];
+ ensure => present,
+ source => "/srv/leap/files/nodes/${::hostname}/tor.key",
+ owner => 'debian-tor',
+ group => 'debian-tor',
+ mode => '0600',
+ notify => Service['tor'];
'/var/lib/tor/static/hostname':
ensure => present,
diff --git a/puppet/modules/site_static/manifests/init.pp b/puppet/modules/site_static/manifests/init.pp
index dd3f912d..8be791e5 100644
--- a/puppet/modules/site_static/manifests/init.pp
+++ b/puppet/modules/site_static/manifests/init.pp
@@ -74,8 +74,7 @@ class site_static {
if $tor {
$hidden_service = $tor['hidden_service']
$tor_domain = "${hidden_service['address']}.onion"
- if $hidden_service['active'] {
- include site_static::hidden_service
+ class { 'site_static::hidden_service': single_hop => $hidden_service['single_hop']
}
# Currently, we only support a single hidden service address per server.
# So if there is more than one domain configured, then we need to make sure
diff --git a/puppet/modules/site_tor/manifests/init.pp b/puppet/modules/site_tor/manifests/init.pp
index 2207a5a9..8a92a944 100644
--- a/puppet/modules/site_tor/manifests/init.pp
+++ b/puppet/modules/site_tor/manifests/init.pp
@@ -20,7 +20,7 @@ class site_tor {
}
include site_config::default
- include tor::daemon
+ class { 'tor::daemon': ensure_version => latest }
tor::daemon::relay { $nickname:
port => 9001,
address => $address,
diff --git a/puppet/modules/site_webapp/manifests/hidden_service.pp b/puppet/modules/site_webapp/manifests/hidden_service.pp
index d2662b65..6651df86 100644
--- a/puppet/modules/site_webapp/manifests/hidden_service.pp
+++ b/puppet/modules/site_webapp/manifests/hidden_service.pp
@@ -11,22 +11,25 @@ class site_webapp::hidden_service {
include apache::module::removeip
include tor::daemon
- tor::daemon::hidden_service { 'webapp': ports => [ '80 127.0.0.1:80'] }
+ tor::daemon::hidden_service { 'webapp':
+ ports => [ '80 127.0.0.1:80'],
+ single_hop => $hidden_service['single_hop']
+ }
file {
'/var/lib/tor/webapp/':
- ensure => directory,
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '2700';
+ ensure => directory,
+ owner => 'debian-tor',
+ group => 'debian-tor',
+ mode => '2700';
'/var/lib/tor/webapp/private_key':
- ensure => present,
- source => "/srv/leap/files/nodes/${::hostname}/tor.key",
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0600',
- notify => Service['tor'];
+ ensure => present,
+ source => "/srv/leap/files/nodes/${::hostname}/tor.key",
+ owner => 'debian-tor',
+ group => 'debian-tor',
+ mode => '0600',
+ notify => Service['tor'];
'/var/lib/tor/webapp/hostname':
ensure => present,
diff --git a/puppet/modules/tor/.gitrepo b/puppet/modules/tor/.gitrepo
index dfc1b3d9..5e3e3c1f 100644
--- a/puppet/modules/tor/.gitrepo
+++ b/puppet/modules/tor/.gitrepo
@@ -6,6 +6,6 @@
[subrepo]
remote = https://leap.se/git/puppet_tor
branch = master
- commit = 9981a70f7ba1f9e4fe33e4eb46654295287c1fc1
- parent = 26aac7ccf240b06d65616bdd00ae472d980aaea9
- cmdver = 0.3.0
+ commit = 5ef29012dccc90e68afc215be9521629a0903bc6
+ parent = 747d3e9b55c8b7b7d98a63474b6de82d7114c389
+ cmdver = 0.4.0
diff --git a/puppet/modules/tor/README b/puppet/modules/tor/README
index 7777438a..188accac 100644
--- a/puppet/modules/tor/README
+++ b/puppet/modules/tor/README
@@ -113,7 +113,7 @@ Installing torsocks
To install torsocks, simply include the 'torsocks' class in your manifests:
- class { 'torsocks': }
+ class { 'tor::torsocks': }
You can specify the $ensure_version class parameter to get a specific
version installed.
diff --git a/puppet/modules/tor/manifests/daemon/base.pp b/puppet/modules/tor/manifests/daemon/base.pp
index 63d7bc4d..c0c82ac6 100644
--- a/puppet/modules/tor/manifests/daemon/base.pp
+++ b/puppet/modules/tor/manifests/daemon/base.pp
@@ -2,7 +2,7 @@
class tor::daemon::base inherits tor::base {
# packages, user, group
Service['tor'] {
- subscribe => File[$tor::daemon::config_file],
+ subscribe => Concat[$tor::daemon::config_file],
}
Package[ 'tor' ] {
@@ -49,18 +49,15 @@ class tor::daemon::base inherits tor::base {
# tor configuration file
concat { $tor::daemon::config_file:
- mode => '0600',
- owner => 'debian-tor',
- group => 'debian-tor',
+ mode => '0600',
+ owner => 'debian-tor',
+ group => 'debian-tor',
}
# config file headers
concat::fragment { '00.header':
ensure => present,
content => template('tor/torrc.header.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 00,
target => $tor::daemon::config_file,
}
@@ -68,9 +65,6 @@ class tor::daemon::base inherits tor::base {
# global configurations
concat::fragment { '01.global':
content => template('tor/torrc.global.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 01,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/bridge.pp b/puppet/modules/tor/manifests/daemon/bridge.pp
index 063f5656..83d74e07 100644
--- a/puppet/modules/tor/manifests/daemon/bridge.pp
+++ b/puppet/modules/tor/manifests/daemon/bridge.pp
@@ -8,9 +8,6 @@ define tor::daemon::bridge(
concat::fragment { "10.bridge.${name}":
ensure => $ensure,
content => template('tor/torrc.bridge.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 10,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/control.pp b/puppet/modules/tor/manifests/daemon/control.pp
index 01726562..ee425f33 100644
--- a/puppet/modules/tor/manifests/daemon/control.pp
+++ b/puppet/modules/tor/manifests/daemon/control.pp
@@ -7,20 +7,20 @@ define tor::daemon::control(
$cookie_auth_file_group_readable = '',
$ensure = present ) {
- if $cookie_authentication == '0' and $hashed_control_password == '' and $ensure != 'absent' {
- fail('You need to define the tor control password')
- }
+ if $cookie_authentication == '0'
+ and $hashed_control_password == ''
+ and $ensure != 'absent' {
+ fail('You need to define the tor control password')
+ }
- if $cookie_authentication == 0 and ($cookie_auth_file != '' or $cookie_auth_file_group_readable != '') {
- notice('You set a tor cookie authentication option, but do not have cookie_authentication on')
- }
+ if $cookie_authentication == 0
+ and ($cookie_auth_file != '' or $cookie_auth_file_group_readable != '') {
+ notice('You set a tor cookie authentication option, but do not have cookie_authentication on') # lint:ignore:80chars
+ }
concat::fragment { '04.control':
ensure => $ensure,
content => template('tor/torrc.control.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0600',
order => 04,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/directory.pp b/puppet/modules/tor/manifests/daemon/directory.pp
index d877a861..e2e405da 100644
--- a/puppet/modules/tor/manifests/daemon/directory.pp
+++ b/puppet/modules/tor/manifests/daemon/directory.pp
@@ -8,9 +8,6 @@ define tor::daemon::directory (
concat::fragment { '06.directory':
ensure => $ensure,
content => template('tor/torrc.directory.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 06,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/dns.pp b/puppet/modules/tor/manifests/daemon/dns.pp
index 4677f24d..e8d4fc88 100644
--- a/puppet/modules/tor/manifests/daemon/dns.pp
+++ b/puppet/modules/tor/manifests/daemon/dns.pp
@@ -7,9 +7,6 @@ define tor::daemon::dns(
concat::fragment { "08.dns.${name}":
ensure => $ensure,
content => template('tor/torrc.dns.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => '08',
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/exit_policy.pp b/puppet/modules/tor/manifests/daemon/exit_policy.pp
index f459ece7..df0fb999 100644
--- a/puppet/modules/tor/manifests/daemon/exit_policy.pp
+++ b/puppet/modules/tor/manifests/daemon/exit_policy.pp
@@ -8,9 +8,6 @@ define tor::daemon::exit_policy(
concat::fragment { "07.exit_policy.${name}":
ensure => $ensure,
content => template('tor/torrc.exit_policy.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 07,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/hidden_service.pp b/puppet/modules/tor/manifests/daemon/hidden_service.pp
index c8272116..07121bd6 100644
--- a/puppet/modules/tor/manifests/daemon/hidden_service.pp
+++ b/puppet/modules/tor/manifests/daemon/hidden_service.pp
@@ -1,17 +1,21 @@
# hidden services definition
define tor::daemon::hidden_service(
- $ports = [],
- $data_dir = $tor::daemon::data_dir,
- $ensure = present ) {
+ $ports = [],
+ $single_hop = false,
+ $data_dir = $tor::daemon::data_dir,
+ $ensure = present ) {
+
+
+ if $single_hop {
+ file { "${$data_dir}/${$name}/onion_service_non_anonymous":
+ ensure => 'present',
+ }
+ }
concat::fragment { "05.hidden_service.${name}":
ensure => $ensure,
content => template('tor/torrc.hidden_service.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 05,
target => $tor::daemon::config_file,
}
}
-
diff --git a/puppet/modules/tor/manifests/daemon/map_address.pp b/puppet/modules/tor/manifests/daemon/map_address.pp
index 270eac21..ac624a0a 100644
--- a/puppet/modules/tor/manifests/daemon/map_address.pp
+++ b/puppet/modules/tor/manifests/daemon/map_address.pp
@@ -7,9 +7,6 @@ define tor::daemon::map_address(
concat::fragment { "08.map_address.${name}":
ensure => $ensure,
content => template('tor/torrc.map_address.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => '08',
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/relay.pp b/puppet/modules/tor/manifests/daemon/relay.pp
index ff528937..555587cd 100644
--- a/puppet/modules/tor/manifests/daemon/relay.pp
+++ b/puppet/modules/tor/manifests/daemon/relay.pp
@@ -33,9 +33,6 @@ define tor::daemon::relay(
concat::fragment { '03.relay':
ensure => $ensure,
content => template('tor/torrc.relay.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 03,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/snippet.pp b/puppet/modules/tor/manifests/daemon/snippet.pp
index b9089b40..7e1494c5 100644
--- a/puppet/modules/tor/manifests/daemon/snippet.pp
+++ b/puppet/modules/tor/manifests/daemon/snippet.pp
@@ -6,9 +6,6 @@ define tor::daemon::snippet(
concat::fragment { "99.snippet.${name}":
ensure => $ensure,
content => $content,
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 99,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/socks.pp b/puppet/modules/tor/manifests/daemon/socks.pp
index 910461c9..54c8b6a2 100644
--- a/puppet/modules/tor/manifests/daemon/socks.pp
+++ b/puppet/modules/tor/manifests/daemon/socks.pp
@@ -6,9 +6,6 @@ define tor::daemon::socks(
concat::fragment { '02.socks':
content => template('tor/torrc.socks.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => 02,
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/daemon/transparent.pp b/puppet/modules/tor/manifests/daemon/transparent.pp
index 65d744f4..6ac7b44c 100644
--- a/puppet/modules/tor/manifests/daemon/transparent.pp
+++ b/puppet/modules/tor/manifests/daemon/transparent.pp
@@ -7,9 +7,6 @@ define tor::daemon::transparent(
concat::fragment { "09.transparent.${name}":
ensure => $ensure,
content => template('tor/torrc.transparent.erb'),
- owner => 'debian-tor',
- group => 'debian-tor',
- mode => '0644',
order => '09',
target => $tor::daemon::config_file,
}
diff --git a/puppet/modules/tor/manifests/munin.pp b/puppet/modules/tor/manifests/munin.pp
index 4412337a..2a01175c 100644
--- a/puppet/modules/tor/manifests/munin.pp
+++ b/puppet/modules/tor/manifests/munin.pp
@@ -8,7 +8,7 @@ class tor::munin {
}
Munin::Plugin::Deploy {
- config => "user debian-tor\n env.cookiefile /var/run/tor/control.authcookie\n env.port 19051"
+ config => "user debian-tor\n env.cookiefile /var/run/tor/control.authcookie\n env.port 19051" # lint:ignore:80chars
}
munin::plugin::deploy {
'tor_connections':
diff --git a/puppet/modules/tor/manifests/repo.pp b/puppet/modules/tor/manifests/repo.pp
index f6255995..95492191 100644
--- a/puppet/modules/tor/manifests/repo.pp
+++ b/puppet/modules/tor/manifests/repo.pp
@@ -1,3 +1,4 @@
+# setup repository for tor
class tor::repo (
$ensure = present,
$source_name = 'torproject.org',
@@ -10,7 +11,7 @@ class tor::repo (
class { 'tor::repo::debian': }
}
default: {
- fail("Unsupported managed repository for osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports managing repos for osfamily Debian and Ubuntu")
+ fail("Unsupported managed repository for osfamily: ${::osfamily}, operatingsystem: ${::operatingsystem}, module ${module_name} currently only supports managing repos for osfamily Debian and Ubuntu") # lint:ignore:80chars
}
}
}
diff --git a/puppet/modules/tor/manifests/repo/debian.pp b/puppet/modules/tor/manifests/repo/debian.pp
index 174c3310..81976a2e 100644
--- a/puppet/modules/tor/manifests/repo/debian.pp
+++ b/puppet/modules/tor/manifests/repo/debian.pp
@@ -1,6 +1,6 @@
# PRIVATE CLASS: do not use directly
class tor::repo::debian inherits tor::repo {
- apt::source { $source_name:
+ apt::source { $tor::repo::source_name:
ensure => $::tor::repo::ensure,
location => $::tor::repo::location,
key => $::tor::repo::key,
diff --git a/puppet/modules/tor/templates/torrc.directory.erb b/puppet/modules/tor/templates/torrc.directory.erb
index 1af9f40f..c7dc4ab5 100644
--- a/puppet/modules/tor/templates/torrc.directory.erb
+++ b/puppet/modules/tor/templates/torrc.directory.erb
@@ -1,11 +1,11 @@
# directory listing
-<% if port != '0' -%>
+<% if @port != '0' -%>
DirPort <%= @port %>
<% end -%>
<% listen_addresses.each do |listen_address| -%>
DirListenAddress <%= listen_address %>
<% end -%>
<% if @port_front_page != '' -%>
-DirPortFrontPage <%= port_front_page %>
+DirPortFrontPage <%= @port_front_page %>
<%- end -%>
diff --git a/puppet/modules/tor/templates/torrc.global.erb b/puppet/modules/tor/templates/torrc.global.erb
index f577673d..a02afc8e 100644
--- a/puppet/modules/tor/templates/torrc.global.erb
+++ b/puppet/modules/tor/templates/torrc.global.erb
@@ -12,8 +12,8 @@ Log notice syslog
Log <%= log_rule %>
<% end -%>
<% end -%>
-<%- if @safe_logging != 1 then -%>
-SafeLogging <%= @safe_logging %>
+<%- if (v=scope.lookupvar('tor::daemon::safe_logging')) != '1' then -%>
+SafeLogging <%= v %>
<%- end -%>
<% if (v=scope.lookupvar('tor::daemon::automap_hosts_on_resolve')) != '0' -%>
diff --git a/puppet/modules/tor/templates/torrc.hidden_service.erb b/puppet/modules/tor/templates/torrc.hidden_service.erb
index 4dec0b25..5b6afe1c 100644
--- a/puppet/modules/tor/templates/torrc.hidden_service.erb
+++ b/puppet/modules/tor/templates/torrc.hidden_service.erb
@@ -1,3 +1,9 @@
+<% if @single_hop != false %>
+HiddenServiceSingleHopMode 1
+HiddenServiceNonAnonymousMode 1
+SOCKSPort 0
+<% end %>
+
# hidden service <%= @name %>
HiddenServiceDir <%= @data_dir %>/<%= @name %>
<% @ports.each do |port| -%>
diff --git a/tests/platform-ci/ci-build.sh b/tests/platform-ci/ci-build.sh
index 0dfbb5c3..34876a73 100755
--- a/tests/platform-ci/ci-build.sh
+++ b/tests/platform-ci/ci-build.sh
@@ -15,75 +15,159 @@
# * ssh private key used to login to remove vm
# * `SSH_PRIVATE_KEY`
#
-# Todo:
-# - Running locally works fine, now use it in gitlab CI ( which ssh-key ? create cloud.json from env vars )
-# - Speed up vm boot if possible ( right now 3-4mins )
# exit if any commands returns non-zero status
set -e
+# because the ci-build is running in a pipe we need to also set the following
+# so exit codes will be caught correctly.
+set -o pipefail
+
+# Check if scipt is run in debug mode so we can hide secrets
+if [[ "$-" =~ 'x' ]]
+then
+ echo 'Running with xtrace enabled!'
+ xtrace=true
+else
+ echo 'Running with xtrace disabled!'
+ xtrace=false
+fi
# leap_platform/tests/platform-ci
# shellcheck disable=SC2086
ROOTDIR=$(readlink -f "$(dirname $0)")
-# leap_platform/tests/platform-ci/provider
-PROVIDERDIR="${ROOTDIR}/provider"
-
# leap_platform
PLATFORMDIR=$(readlink -f "${ROOTDIR}/../..")
-LEAP_CMD="/usr/local/bin/bundle exec leap -v2 --yes"
-
-# create node(s) with unique id so we can run tests in parallel
-NAME="citest${CI_BUILD_ID}"
-# when using gitlab-runner locally, CI_BUILD_ID is always 1 which
-# will conflict with running/terminating AWS instances in subsequent runs
-# therefore we pick a random number in this case
-[ "$CI_BUILD_ID" -eq "1" ] && NAME+="000${RANDOM}"
-
-TAG='single'
-SERVICES='couchdb,soledad,mx,webapp,tor,monitor'
-SEEDS=''
+# In the gitlab CI pipeline leap is installed in a different
+# stage by bundle. To debug you can run a single CI job locally
+# so we install leap_cli as gem here.
+if /usr/local/bin/bundle exec leap >/dev/null 2>&1
+then
+ LEAP_CMD() {
+ /usr/local/bin/bundle exec leap -v2 --yes "$@"
+ }
+else
+ sudo gem install leap_cli
+ LEAP_CMD() {
+ leap -v2 --yes "$@"
+ }
+fi
+
+deploy() {
+ LEAP_CMD deploy "$TAG"
+}
+
+test() {
+ LEAP_CMD test "$TAG"
+}
+
+build_from_scratch() {
+ # leap_platform/tests/platform-ci/provider
+ PROVIDERDIR="${ROOTDIR}/provider"
+ /bin/echo "Provider directory: ${PROVIDERDIR}"
+ cd "$PROVIDERDIR"
+
+ # Create cloud.json needed for `leap vm` commands using AWS credentials
+ which jq || ( apt-get update -y && apt-get install jq -y )
+
+ # Dsiable xtrace
+ set +x
+ /usr/bin/jq ".platform_ci.auth |= .+ {\"aws_access_key_id\":\"$AWS_ACCESS_KEY\", \"aws_secret_access_key\":\"$AWS_SECRET_KEY\"}" < cloud.json.template > cloud.json
+ # Enable xtrace again only if it was set at beginning of script
+ [[ $xtrace == true ]] && set -x
+
+ [ -d "./tags" ] || mkdir "./tags"
+ /bin/echo "{\"environment\": \"$TAG\"}" | /usr/bin/json_pp > "${PROVIDERDIR}/tags/${TAG}.json"
+
+ pwd
+
+# remove old cached nodes
+ echo "Removing old cached nodes..."
+ find nodes -name 'citest*' -exec rm {} \;
+
+ echo "Listing current VM status..."
+ LEAP_CMD vm status "$TAG"
+ # shellcheck disable=SC2086
+ echo "Adding VM $NAME with the services: $SERVICES and the tags: $TAG"
+ LEAP_CMD vm add "$NAME" services:"$SERVICES" tags:"$TAG"
+ echo "Compiling $TAG..."
+ LEAP_CMD compile "$TAG"
+ echo "Listing current VM status for TAG: $TAG..."
+ LEAP_CMD vm status "$TAG"
+
+ echo "Running leap list..."
+ LEAP_CMD list
+
+ echo "Running leap node init on TAG: $TAG"
+ LEAP_CMD node init "$TAG"
+ echo "Running leap info on $TAG"
+ LEAP_CMD info "${TAG}"
+}
+
+run() {
+ echo "Cloning $1 repo: $2"
+ git clone -q --depth 1 "$2"
+ cd "$1"
+ git rev-parse HEAD
+ echo -n "Operating in the $1 directory: "
+ pwd
+ echo "Listing current node information..."
+ LEAP_CMD list
+ echo "Attempting a deploy..."
+ deploy
+ echo "Attempting to run tests..."
+ test
+}
#
# Main
#
-
/bin/echo "CI directory: ${ROOTDIR}"
-/bin/echo "Provider directory: ${PROVIDERDIR}"
/bin/echo "Platform directory: ${PLATFORMDIR}"
-cd "$PROVIDERDIR"
# Ensure we don't output secret stuff to console even when running in verbose mode with -x
set +x
-# Create cloud.json needed for `leap vm` commands using AWS credentials
-which jq || ( apt-get update -y && apt-get install jq -y )
-/usr/bin/jq ".platform_ci.auth |= .+ {\"aws_access_key_id\":\"$AWS_ACCESS_KEY\", \"aws_secret_access_key\":\"$AWS_SECRET_KEY\"}" < cloud.json.template > cloud.json
-
# Configure ssh keypair
[ -d ~/.ssh ] || /bin/mkdir ~/.ssh
/bin/echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
/bin/chmod 600 ~/.ssh/id_rsa
-/bin/cp users/gitlab-runner/gitlab-runner_ssh.pub ~/.ssh/id_rsa.pub
-
-[ -d "./tags" ] || mkdir "./tags"
-/bin/echo "{\"environment\": \"$TAG\"}" | /usr/bin/json_pp > "${PROVIDERDIR}/tags/${TAG}.json"
-
-$LEAP_CMD vm status "$TAG"
-# shellcheck disable=SC2086
-$LEAP_CMD vm add "$NAME" services:"$SERVICES" tags:"$TAG" $SEEDS
-$LEAP_CMD compile "$TAG"
-$LEAP_CMD vm status "$TAG"
-
-$LEAP_CMD node init "$TAG"
-$LEAP_CMD info "${TAG}"
-
-# Deploy and test
-$LEAP_CMD deploy "$TAG"
-$LEAP_CMD test "$TAG"
-
-# if everything succeeds, destroy the vm
-$LEAP_CMD vm rm "${TAG}"
-[ -f "nodes/${NAME}.json" ] && /bin/rm "nodes/${NAME}.json"
+/bin/cp "${ROOTDIR}/provider/users/gitlab-runner/gitlab-runner_ssh.pub" ~/.ssh/id_rsa.pub
+
+# Enable xtrace again only if it was set at beginning of script
+[[ $xtrace == true ]] && set -x
+
+case "$CI_ENVIRONMENT_NAME" in
+ staging)
+ TAG='latest'
+ run ibex ssh://gitolite@leap.se/ibex
+ ;;
+ production/demo/mail)
+ TAG='demomail'
+ run bitmask ssh://gitolite@leap.se/bitmask
+ ;;
+ production/demo/vpn)
+ TAG='demovpn'
+ run bitmask ssh://gitolite@leap.se/bitmask
+ ;;
+ *)
+ # create node(s) with unique id so we can run tests in parallel
+ NAME="citest${CI_BUILD_ID:-0}"
+ # when using gitlab-runner locally, CI_BUILD_ID is always 1 which
+ # will conflict with running/terminating AWS instances in subsequent runs
+ # therefore we pick a random number in this case
+ [ "${CI_BUILD_ID:-0}" -eq "1" ] && NAME+="000${RANDOM}"
+
+ TAG='single'
+ SERVICES='couchdb,soledad,mx,webapp,tor,monitor'
+ build_from_scratch
+ # Deploy and test
+ deploy
+ test
+ # if everything succeeds, destroy the vm
+ LEAP_CMD vm rm "${TAG}"
+ [ -f "nodes/${NAME}.json" ] && /bin/rm "nodes/${NAME}.json"
+ ;;
+esac
diff --git a/tests/platform-ci/setup.sh b/tests/platform-ci/setup.sh
index 99f735b7..e92dddc7 100755
--- a/tests/platform-ci/setup.sh
+++ b/tests/platform-ci/setup.sh
@@ -2,3 +2,4 @@
which bundle || /usr/bin/apt install bundle
/usr/local/bin/bundle install --binstubs --path=vendor --with=test --jobs "$(nproc)"
+/usr/local/bin/bundle exec leap -v2 --yes help