Browse Source

first development version

dev
parent
commit
ae08b0b91b
7 changed files with 64 additions and 0 deletions
  1. +1
    -0
      defaults/main.yaml
  2. +6
    -0
      handlers/main.yaml
  3. +16
    -0
      tasks/local_facts.yaml
  4. +20
    -0
      tasks/main.yaml
  5. +7
    -0
      tasks/setup_Debian.yaml
  6. +11
    -0
      templates/torrc.j2
  7. +3
    -0
      vars/main.yaml

+ 1
- 0
defaults/main.yaml View File

@@ -0,0 +1 @@
tor_hidden_services: []

+ 6
- 0
handlers/main.yaml View File

@@ -0,0 +1,6 @@
---

- name: restart tor
systemd:
name: tor@default.service
state: restarted

+ 16
- 0
tasks/local_facts.yaml View File

@@ -0,0 +1,16 @@
---

- name: ansible local facts directory
file:
path: /etc/ansible/facts.d
state: directory

- name: set ansible local fact
copy:
content: "{{_local_facts|to_json}}"
dest: /etc/ansible/facts.d/{{role_name}}.fact
register: _local_facts_set

- name: Gathering Facts
setup:
when: _local_facts_set.changed

+ 20
- 0
tasks/main.yaml View File

@@ -0,0 +1,20 @@
---

- import_tasks: setup_Debian.yaml

- name: torrc config file
template:
src: torrc.j2
dest: /etc/tor/torrc
notify: restart tor

- name: flush handlers
meta: flush_handlers

- name: get tor hidden service hostnames
command: cat /var/lib/tor/{{item}}/hostname
loop: "{{ tor_hidden_services | json_query('[*].name') }}"
register: tor_hidden_services_hostnames_cat
changed_when: false

- import_tasks: local_facts.yaml

+ 7
- 0
tasks/setup_Debian.yaml View File

@@ -0,0 +1,7 @@
---

- name: required debian packages
apt:
pkg:
- tor
- fish

+ 11
- 0
templates/torrc.j2 View File

@@ -0,0 +1,11 @@
{{ansible_managed|comment}}

## hidden services
{% for ths in tor_hidden_services %}
# hidden service "{{ths.name}}"
HiddenServiceDir /var/lib/tor/{{ths.name}}/
{% for sp in ths.service_ports %}
HiddenServicePort {{sp.virtport}} {{sp.target}}
{% endfor %}

{% endfor %}

+ 3
- 0
vars/main.yaml View File

@@ -0,0 +1,3 @@
---
_local_facts:
tor_hidden_services_hostnames: "{{ tor_hidden_services_hostnames_cat | json_query(\"results[*].{key: item, value: stdout}\") | items2dict }}"

Loading…
Cancel
Save