Skip to content

Commit

Permalink
Uses the correct v2 or v3 URLS
Browse files Browse the repository at this point in the history
Ansible overrides facts if they are reused even with when statements.
We are creating two varaiables from either v2 or from v3 addresses
based on what is available and then using those.
  • Loading branch information
kushaldas authored and zenmonkeykstop committed Aug 22, 2019
1 parent 473b7cd commit 7b302c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@
command: grep -Po '.{16}\.onion' app-source-ths
changed_when: false
register: source_interface_lookup_result
when: v3_source_file.stat.exists == False
when: v3_source_file.stat.exists == false

- name: Look up v3 Source Interface URL.
command: grep -Po '.{56}\.onion' app-sourcev3-ths
changed_when: false
register: source_interface_lookup_result
when: v3_source_file.stat.exists == True
register: sourcev3_interface_lookup_result
when: v3_source_file.stat.exists == true

- name: Look up v2 Journalist Interface URL.
command: grep -Po '.{16}\.onion' app-journalist-aths
changed_when: false
register: journalist_interface_lookup_result
when: v3_source_file.stat.exists == False
when: v3_source_file.stat.exists == false

- name: Look up v3 Journalist Interface URL.
command: awk -F ':' '{print $1 ".onion"}' app-journalist.auth_private
changed_when: false
register: journalist_interface_lookup_result
when: v3_source_file.stat.exists == True
register: journalistv3_interface_lookup_result
when: v3_source_file.stat.exists == true

- name: Create desktop shortcut parent directories.
file:
Expand All @@ -58,16 +58,27 @@
when: item.startswith(tails_config_amnesia_home)
with_items: "{{ tails_config_desktop_icon_directories }}"

- name: Set the right variable for source
set_fact:
source_iface: "{{ sourcev3_interface_lookup_result if (v3_source_file.stat.exists == true) else source_interface_lookup_result }}"

- name: Set the right variable for journalist
set_fact:
journalist_iface: "{{ journalistv3_interface_lookup_result if (v3_source_file.stat.exists == true) else journalist_interface_lookup_result }}"

- debug:
var: source_iface

# Storing as host fact so we can loop over the data in one task.
- name: Assemble desktop icon info.
set_fact:
_securedrop_desktop_icon_info:
- src: desktop-source-icon.j2
filename: source.desktop
onion_url: "{{ source_interface_lookup_result.stdout }}"
onion_url: "{{ source_iface.stdout }}"
- src: desktop-journalist-icon.j2
filename: journalist.desktop
onion_url: "{{ journalist_interface_lookup_result.stdout }}"
onion_url: "{{ journalist_iface.stdout }}"

- name: Create SecureDrop interface desktop icons.
become: yes
Expand Down
4 changes: 2 additions & 2 deletions install_files/ansible-base/securedrop-tails.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
Successfully configured Tor and set up desktop bookmarks for SecureDrop!
You will see a notification appear on your screen when Tor is ready.
The Journalist Interface's Tor onion URL is: http://{{ journalist_interface_lookup_result.stdout }}
The Source Interfaces's Tor onion URL is: http://{{ source_interface_lookup_result.stdout }}
The Journalist Interface's Tor onion URL is: http://{{ journalist_iface.stdout }}
The Source Interfaces's Tor onion URL is: http://{{ source_iface.stdout }}
{% if find_aths_info_result.matched > 1 %}
SSH aliases are set up. You can use them with 'ssh app' and 'ssh mon'.
{% endif %}

0 comments on commit 7b302c0

Please sign in to comment.