Browse Source

initial commit

master
Bastiaan Stroosnijder 5 months ago
parent
commit
a65d29d668
  1. 4
      defaults/main.yml
  2. 11
      meta/main.yml
  3. 19
      tasks/main.yml
  4. 16
      templates/pilab-tor.dockerfile.j2
  5. 8
      templates/torrc.j2

4
defaults/main.yml

@ -0,0 +1,4 @@
---
pilab_tor_path: "{{ pilab_path_services }}/tor"
pilab_tor_suffix_config: config

11
meta/main.yml

@ -0,0 +1,11 @@
---
galaxy_info:
readme: README.md
license: GPL-3.0-only
authors:
- Bastiaan Stroosnijder <bas@strootje.com> (https://strootje.com)
repository: https://git.strooweb.nl/pilab/pilab-role-service-tor
dependencies:
- src: git+https://git.strooweb.nl/pilab/pilab-role-common.git

19
tasks/main.yml

@ -0,0 +1,19 @@
---
- vars:
_service_name: "{{ pilab_tor_service_name | mandatory }}"
pilab_tor_path_config: "{{ [pilab_tor_path, _service_name, pilab_tor_suffix_config] | join('/') }}"
block:
- loop:
- image: pilab/tor
image_template: "{{ role_path }}/templates/pilab-tor.dockerfile"
volumes:
- tmpl: "{{ role_path }}/templates/torrc"
src: "{{ pilab_tor_path_config }}/torrc"
dest: /etc/tor/torrc
options:
redirect_to: "{{ pilab_tor_redirect_to | default('127.0.0.1:8080') }}"
listen_on: "{{ pilab_tor_listen_on | default(80) }}"
ansible.builtin.include_role:
name: pilab-role-common
tasks_from: add-service

16
templates/pilab-tor.dockerfile.j2

@ -0,0 +1,16 @@
FROM alpine:latest
LABEL maintainer "bas@strootje.com"
ARG UID=101
ARG GID=101
RUN mkdir /web \
&& chmod go-rwx /web \
&& addgroup -Sg $GID tor \
&& adduser -SDHu $UID -G tor tor \
&& apk add --no-cache tor \
&& chown -R tor /etc/tor /web
USER tor
VOLUME /web
ENTRYPOINT /usr/bin/tor

8
templates/torrc.j2

@ -0,0 +1,8 @@
#jinja2: lstrip_blocks: "True"
{% set _options = pilab_services_volumes_options[_volume_name] %}
Log notice stdout
DataDirectory /tmp/tor
HiddenServiceDir /web/
HiddenServicePort {{ _options.listen_on }} {{ _options.redirect_to }}
Loading…
Cancel
Save