1
1
---
2
2
- name : Ensure gpg is present
3
- apt :
3
+ ansible.builtin. apt :
4
4
pkg : gnupg
5
5
update_cache : True
6
6
7
7
- name : Ensure tor is installed
8
- apt :
8
+ ansible.builtin. apt :
9
9
pkg : tor
10
10
state : " {{ onion_tor_apt_state }}"
11
11
12
12
- name : Install extra tor packages
13
- apt :
13
+ ansible.builtin. apt :
14
14
pkg : " {{ onion_apt_packages }}"
15
15
state : present
16
16
17
17
- name : Ensure onion directory is present
18
- file :
18
+ ansible.builtin. file :
19
19
path : " /var/lib/tor/{{ item.key }}/"
20
20
owner : debian-tor
21
21
group : debian-tor
22
- mode : 0700
22
+ mode : " 0700"
23
23
state : directory
24
24
with_dict : " {{ onion_services }}"
25
25
when : item.value.onion_state|default('present') == 'present'
26
26
notify : Restart tor
27
27
28
28
- name : Ensure onion configuration is latest
29
- template :
29
+ ansible.builtin. template :
30
30
src : torrc.j2
31
31
dest : /etc/tor/torrc
32
32
owner : root
35
35
notify : Restart tor
36
36
37
37
- name : Ensure hostname file are present
38
- template :
38
+ ansible.builtin. template :
39
39
src : hostname.j2
40
40
dest : " /var/lib/tor/{{ item.key }}/hostname"
41
41
owner : debian-tor
42
42
group : debian-tor
43
- mode : 0600
43
+ mode : " 0600"
44
44
backup : yes
45
45
with_dict : " {{ onion_services }}"
46
46
when :
50
50
notify : Restart tor
51
51
52
52
- name : Copy encoded public_key (only for onion v3)
53
- shell :
53
+ ansible.builtin. shell :
54
54
cmd : " set -o pipefail &&\
55
- echo \" {{ item.value.onion_public_key_b64encoded }}\" | base64 -d >/var/lib/tor/{{ item.key }}/hs_ed25519_public_key"
55
+ echo \" {{ item.value.onion_public_key_b64encoded }}\" | base64 -d >/var/lib/tor/{{ item.key }}/hs_ed25519_public_key"
56
56
executable : /bin/bash
57
57
creates : " /var/lib/tor/{{ item.key }}/hs_ed25519_public_key"
58
58
with_dict : " {{ onion_services }}"
@@ -63,7 +63,7 @@ echo \"{{ item.value.onion_public_key_b64encoded }}\" | base64 -d >/var/lib/tor/
63
63
notify : Restart tor
64
64
65
65
- name : Ensure file permissions are correct
66
- file :
66
+ ansible.builtin. file :
67
67
path : " /var/lib/tor/{{ item.key }}/hs_ed25519_public_key"
68
68
owner : debian-tor
69
69
group : debian-tor
@@ -75,9 +75,9 @@ echo \"{{ item.value.onion_public_key_b64encoded }}\" | base64 -d >/var/lib/tor/
75
75
- item.value.onion_state|default('present') == 'present'
76
76
77
77
- name : Copy encoded secret_key (only for onion v3)
78
- shell :
78
+ ansible.builtin. shell :
79
79
cmd : " set -o pipefail &&\
80
- echo \" {{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/{{ item.key }}/hs_ed25519_secret_key"
80
+ echo \" {{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/{{ item.key }}/hs_ed25519_secret_key"
81
81
executable : /bin/bash
82
82
creates : " /var/lib/tor/{{ item.key }}/hs_ed25519_secret_key"
83
83
with_dict : " {{ onion_services }}"
@@ -88,38 +88,38 @@ echo \"{{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/
88
88
notify : Restart tor
89
89
90
90
- name : Ensure file permissions are correct
91
- file :
91
+ ansible.builtin. file :
92
92
path : " /var/lib/tor/{{ item.key }}/hs_ed25519_secret_key"
93
93
owner : debian-tor
94
94
group : debian-tor
95
- mode : 0600
95
+ mode : " 0600"
96
96
with_dict : " {{ onion_services }}"
97
97
when :
98
98
- item.value.onion_secret_key_b64encoded is defined
99
99
- item.value.onion_secret_key_b64encoded
100
100
- item.value.onion_state|default('present') == 'present'
101
101
102
102
- name : Ensure onion directory is absent
103
- file :
103
+ ansible.builtin. file :
104
104
path : " /var/lib/tor/{{ item.key }}/"
105
- mode : 0700
105
+ mode : " 0700"
106
106
state : absent
107
107
with_dict : " {{ onion_services }}"
108
108
when : item.value.onion_state|default('present') == "absent"
109
109
110
110
# The hostname file won't be created until the tor service
111
111
# is restarted, so bounce it before the `wait_for` task.
112
112
- name : Flush handlers
113
- meta : flush_handlers
113
+ ansible.builtin. meta : flush_handlers
114
114
115
115
- name : Wait for onion
116
- wait_for :
116
+ ansible.builtin. wait_for :
117
117
path : " /var/lib/tor/{{ item.key }}/hostname"
118
118
with_dict : " {{ onion_services }}"
119
119
when : item.value.onion_state|default('present') != "absent"
120
120
121
121
- name : Read onion url
122
- command : cat "/var/lib/tor/{{ item.key }}/hostname"
122
+ ansible.builtin. command : cat "/var/lib/tor/{{ item.key }}/hostname"
123
123
register : onion_hostname_results
124
124
changed_when : false
125
125
with_dict : " {{ onion_services }}"
@@ -128,7 +128,7 @@ echo \"{{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/
128
128
- item.value.onion_state|default('present') != "absent"
129
129
130
130
- name : Read onion v3 secret key
131
- command : base64 "/var/lib/tor/{{ item.key }}/hs_ed25519_secret_key"
131
+ ansible.builtin. command : base64 "/var/lib/tor/{{ item.key }}/hs_ed25519_secret_key"
132
132
register : onion_v3_secret_key_results
133
133
changed_when : false
134
134
with_dict : " {{ onion_services }}"
@@ -137,7 +137,7 @@ echo \"{{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/
137
137
- item.value.onion_state|default('present') != "absent"
138
138
139
139
- name : Read onion v3 public key
140
- command : base64 "/var/lib/tor/{{ item.key }}/hs_ed25519_public_key"
140
+ ansible.builtin. command : base64 "/var/lib/tor/{{ item.key }}/hs_ed25519_public_key"
141
141
register : onion_v3_public_key_results
142
142
changed_when : false
143
143
with_dict : " {{ onion_services }}"
@@ -146,17 +146,17 @@ echo \"{{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/
146
146
- item.value.onion_state|default('present') != "absent"
147
147
148
148
- name : Display onion url
149
- debug :
149
+ ansible.builtin. debug :
150
150
msg : >-
151
151
{{ lookup('template', role_path + '/templates/display_hostnames.j2') }}
152
152
153
153
- name : Display public key for v3 host
154
- debug :
154
+ ansible.builtin. debug :
155
155
msg : >-
156
156
{{ lookup('template', role_path + '/templates/display_v3_public_keys.j2') }}
157
157
158
158
- name : Display secret key for v3 host
159
- debug :
159
+ ansible.builtin. debug :
160
160
msg : >-
161
161
{{ lookup('template', role_path + '/templates/display_v3_secret_keys.j2') }}
162
162
@@ -172,10 +172,10 @@ echo \"{{ item.value.onion_secret_key_b64encoded }}\" | base64 -d >/var/lib/tor/
172
172
when : not onion_active
173
173
174
174
- name : Import monit tasks
175
- import_tasks : monit.yml
175
+ ansible.builtin. import_tasks : monit.yml
176
176
when : onion_monit_enabled
177
177
178
178
- name : Import goss tasks
179
- import_tasks : goss.yml
179
+ ansible.builtin. import_tasks : goss.yml
180
180
tags :
181
181
- goss
0 commit comments