Arrange for a hostname to be written to a volume that is available the container.

This commit is contained in:
Brian Lee 2023-07-18 18:31:10 -07:00
parent 35083be06d
commit 2b9f99568e
6 changed files with 23 additions and 9 deletions

View File

@ -36,8 +36,9 @@ See the [defaults](defaults/main.yml) for the role.
```yaml ```yaml
samourai_dojo_version: "1.20.0" samourai_dojo_version: "1.20.0"
samourai_dojo_onion_address: "{{ lookup('ansible.builtin.env', 'SAMOURAI_DOJO_ONION') }}" samourai_dojo_onion_service: "{{ lookup('ansible.builtin.env', 'SAMOURAI_DOJO_ONION') }}"
samourai_dojo_onion_port: 80 samourai_dojo_onion_port: 80
#onion_services_path: /opt/dojo # a globally readable/writable path where the hsv3 hostname will be copied (optional)
``` ```
## Example Playbook ## Example Playbook

View File

@ -1,8 +1,8 @@
--- ---
samourai_dojo_version: "1.20.0" samourai_dojo_version: "1.20.0"
samourai_dojo_onion_address: "{{ lookup('ansible.builtin.env', 'SAMOURAI_DOJO_ONION') | default('_') }}" samourai_dojo_onion_service: "{{ lookup('ansible.builtin.env', 'SAMOURAI_DOJO_ONION') | default('_') }}"
samourai_dojo_onion_port: 80 samourai_dojo_onion_port: 80
onion_services_path: data-tor samourai_dojo_onion_path: data-tor
#samourai_dojo_https_port: 4480 #samourai_dojo_https_port: 4480
samourai_dojo_ws_http_port: 8080 samourai_dojo_ws_http_port: 8080
samourai_dojo_pushtx_http_port: 8081 samourai_dojo_pushtx_http_port: 8081

View File

@ -66,7 +66,7 @@
- name: Content-Type - name: Content-Type
value: application/json value: application/json
- core: - core:
server_name: "{{ samourai_dojo_onion_address|default('_') }}" server_name: "{{ samourai_dojo_onion_service|default('_') }}"
listen: listen:
- address: "127.0.0.1:{{ samourai_dojo_onion_port|default(80) }}" - address: "127.0.0.1:{{ samourai_dojo_onion_port|default(80) }}"
send_timeout: 600s send_timeout: 600s

View File

@ -14,7 +14,6 @@
quiet: true quiet: true
no_log: true no_log: true
loop: loop:
- "{{ samourai_dojo_onion_address }}"
- "{{ samourai_dojo_config.NODE_API_KEY }}" - "{{ samourai_dojo_config.NODE_API_KEY }}"
- "{{ samourai_dojo_config.NODE_ADMIN_KEY }}" - "{{ samourai_dojo_config.NODE_ADMIN_KEY }}"
- "{{ samourai_dojo_config.NODE_JWT_SECRET }}" - "{{ samourai_dojo_config.NODE_JWT_SECRET }}"

View File

@ -20,9 +20,9 @@
- name: Dojo | Create volumes - name: Dojo | Create volumes
containers.podman.podman_volume: containers.podman.podman_volume:
state: present state: present
name: data-tor name: "{{ samourai_dojo_onion_path }}"
recreate: no recreate: no
when: not onion_services_path.startswith('/') when: not samourai_dojo_onion_path.startswith('/')
- name: Dojo | Create container - name: Dojo | Create container
register: podman_container_output register: podman_container_output
@ -36,8 +36,7 @@
env: "{{ samourai_dojo_config }}" env: "{{ samourai_dojo_config }}"
ports: "{{ samourai_dojo_ports }}" ports: "{{ samourai_dojo_ports }}"
volume: volume:
- /var/lib/tor/hsv3dojo/hostname:/var/lib/tor/hsv3dojo/hostname - "{{ samourai_dojo_onion_path }}:/var/lib/tor/hsv3dojo"
# - "{{ onion_services_path }}:/var/lib/tor"
command: /home/node/app/restart.sh command: /home/node/app/restart.sh
# command: "/home/node/app/wait-for-it.sh host.containers.internal:3306 --timeout=720 --strict -- /home/node/app/restart.sh" # command: "/home/node/app/wait-for-it.sh host.containers.internal:3306 --timeout=720 --strict -- /home/node/app/restart.sh"

View File

@ -31,3 +31,18 @@
remote_src: yes remote_src: yes
src: "~/src/samourai-dojo/static/admin/conf/index-{{ samourai_dojo_config.COMMON_BTC_NETWORK }}.js" src: "~/src/samourai-dojo/static/admin/conf/index-{{ samourai_dojo_config.COMMON_BTC_NETWORK }}.js"
dest: ~/src/samourai-dojo/static/admin/conf/index.js dest: ~/src/samourai-dojo/static/admin/conf/index.js
- block:
- name: Dojo | Ensure onoion services directory exists
ansible.builtin.file:
path: "{{ samourai_dojo_onion_path }}"
state: directory
mode: '0755'
- name: Dojo | Write the hostname to a file in the samourai_dojo_onion_path
ansible.builtin.lineinfile:
path: "{{ samourai_dojo_onion_path }}/hostname"
line: "{{ samourai_dojo_onion_service }}"
create: yes
insertbefore: '^$' # avoid creating leading blank lines on multiple runs
when: samourai_dojo_onion_path.startswith('/')