Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configures Tails workstations via Ansible #1803

Merged
merged 10 commits into from
Jun 14, 2017
Merged

Conversation

conorsch
Copy link
Contributor

Status

Ready for review.

Description of Changes

Removes tails_files/install.sh bash script and ports all Tails configuration logic to Ansible. Updates the securedrop-admin tailsconfig command to trigger the dedicated Tails config playbook. Works for both Admin and Journalist Workstations. Does not require specification by Admin—if the app-ssh-aths and mon-ssh-aths files are present in the install_files/ansible-base directory, then the SSH access is configured. If the Journalist Interface ATHS info is missing, configuration halts with an informative error message.

Fixes #1793.

Testing

  1. Boot up Tails 3 with a fresh persistence volume.
  2. Run through an install on prod VMs (or hardware, as you will) via ./securedrop-admin install.
  3. After installation, run ./securedrop-admin tailsconfig to use the new Ansible-based Tails setup logic.

Note that 2) is optional, since you may already have -aths files locally. As long as those still refer to machines with active Tor interfaces (so you can test the interfaces), it's OK to reuse them, since the subject of this PR is the Tails config. Note that 1) is required!

After running 3), confirm the following:

  1. SecureDrop desktop icons exist for both Source and Journalist Interfaces.
  2. Double-clicking the desktop icons load the respective interfaces in Tor Browser.
  3. Running ansible all -m ping within the ansible-base directory returns a green OK message for each host.

Then reboot Tails, and confirm that 1-3 above are still true. Doing so will confirm that the persistence options were correctly configured.

Remember that use of prod VMs will cause failure due discrepancies in the AppArmor profile for Apache, caused by the Document -> Journalist Interface renaming (#1614). Edit the /etc/apparmor.d/usr.sbin.apache2 file on the Application Server and add an exemption for the journalist.conf file in sites-available, then bounce apparmor and apache.

Deployment

Makes first-time setup of a new instance substantially easier for Admins. Should greatly reduce the opportunity for user error during the configuration and install process. Not as relevant for existing Admins, although the new tailsconfig logic will run if/when new Journalists are onboarded to an existing instance.

Checklist

Relying on manual testing to validate Tails-based config.

If you made changes to documentation:

  • Doc linting passed locally

Conor Schaefer added 10 commits June 13, 2017 16:30
Reuses validation logic from the `validate` role, because why not. Added
some checks for the Persistence volume, since it's required, otherwise
the custom config options will be lost.

Includes dedicated playbook, intended for use after the
`securedrop-prod.yml` playbook finishes. Works against both Admin and
Journalist Workstations.

Sets the playbook to be executable as with the others.
Porting over changes from the install.sh script.
Hurray for templates! Lost the SSH username handling, however, since we
don't have a stable strategy for determining whether the YAML var
`ssh_users` is a list or a string. Settle that in a separate issue.
Similar to the exit message in the old `install.sh` script, we'll
provide informative output to state that the configuration run is
complete. It's probably not necessary to provide explicit URLs, since we
have desktop icons, but preserving the messages on the web interfaces
just in case it's useful. Omitted the Onion URLs for the SSH addresses,
since we have SSH alias configuration, as well as a dynamic inventory
script incoming.
The bash setup logic has been replaced entirely with Ansible playbooks,
which afford much better error handling, along with an idempotent setup.

Updates the securedrop-admin script's `tailsconfig` subcommand to target
the new playbook, rather than the old install.sh script. Activates the
virtualenv prior to running the playbook, same as in the `install`
subcommand, otherwise the ansible-playbook binary won't be found.
Should have been included in #1782, but was missed during QA (since
testing in Tails is still difficult, but getting simpler fast). We're
not using a straight tor-generated "hostname" file for reading; for
better or for worse, the SecureDrop playbook formats the hostname files
fetched back from the servers with the `HidServAuth` prefix, so we
actually need the second field in the file, not the first.

Exception handling is in place to catch any IndexErrors if for some
reason the file is not formatted as expected.

Also made a minor stylistic cleanup to move the return statement to the
end of the function, to aid in readability.
@conorsch
Copy link
Contributor Author

Had some problems connecting to SSH over Tor post-provisioning during local testing. Might have screwed up my network settings though, so will need to try again.

Also noticed that the desktop icons do not appear immediately—only after a reboot of Tails. That's different behavior than we saw in Tails 2, although I'm not sure what the root cause is yet.

Note that there's a minor regression presented in the Ansible logic, in that the Admin SSH username is omitted from the SSH aliases. Opened #1796 to discuss separately, so not handling in this PR.

@conorsch conorsch requested a review from msheiny June 14, 2017 00:31

tails_config_deprecated_config_files:
- 70-tor-reload.sh
- 99-tor-reload.sh
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic like these legacy cleanup tasks isn't strictly necessary, since we're requiring Admins to install Tails 3 on a fresh stick during upgrade to 0.4. Depending on how they copy the dotfiles over, though, it's conceivable something could be dangling, so I figured better safe than sorry. Also, we know have a dedicated task list for handling legacy cleanup tasks on Tails in the future.

subprocess.check_call(['sudo',
os.path.join(SD_DIR, 'tails_files/install.sh')])
activate_venv()
subprocess.check_call([os.path.join(ANSIBLE_PATH, 'securedrop-tails.yml'),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't there be an ['ansible'... before os.path.join ? Or is there some magic making the .yml executable ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually not much of a fan of the executable playbook pragma, simply because it's not common in the Ansible community. Added it here to be consistent with the tooling changes as of #1781.

@msheiny
Copy link
Contributor

msheiny commented Jun 14, 2017

Burning through a local install on tails now

@msheiny
Copy link
Contributor

msheiny commented Jun 14, 2017

Ohhh so I hit an interesting issue -- my securedrop is cloned to ~/securedrop instead of ~/Persistent/securedrop. Interesting I've been able to get this far in the process without something yelling at me (i blame my previous work on the installation script).

@msheiny
Copy link
Contributor

msheiny commented Jun 14, 2017

To clarify -- the issue is the script is breaking in certain areas at the tailsconfig where it is looking for the tor files to mix them in the system torrc.

@conorsch
Copy link
Contributor Author

@msheiny The new validation checks should fail out if ~/Persistent/securedrop does not exist: https://github.com/freedomofpress/securedrop/pull/1803/files#diff-dc14710315347f520dea7178bacdf5d6

@msheiny
Copy link
Contributor

msheiny commented Jun 14, 2017

😆 okay i see --- i had a left over securedrop folder in ~/Persistent from a previous run...

So I guess we need a ticket to cover the case when an FPF person has two copies of securedropin his home folder and he's rsyncing files through a virtualized instance ofTails and accidentally kicks off the install from wrong folder validation step?

@msheiny
Copy link
Contributor

msheiny commented Jun 14, 2017

SSH aliases are set up. You can use them with 'ssh app' and 'ssh mon'. "

This messaging is confusing because I forgot that we have to specify the username currently. Would recommend taking that from the config and dropping into the sshconfig file... yes i realize there is another ticket covering the user stuff ;)

@conorsch
Copy link
Contributor Author

Right, SSH aliases are punted to #1796.

Note that there's a minor regression presented in the Ansible logic, in that the Admin SSH username is omitted from the SSH aliases. Opened #1796 to discuss separately, so not handling in this PR.

path: "{{ item }}"
with_items:
- "{{ tails_config_amnesia_home }}/Desktop/document.desktop"
- "{{ tails_config_amnesia_home }}/.local/share/applications/document.desktop"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add that you should also remove Report_an_error.desktop and tails-documentation.desktop. These icons clutter the desktop and our users are likely hitting errors with SD --- if anything I would add a link to OUR website and OUR docs. That second part can be a new PR (up to you) but I think the removal of existing icons should go in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea. Will need to confirm that one-time removal sticks after rebooting. If that's the case, will push up changes.

- name: Configuration complete.
debug:
msg: >-
Successfully configured Tor and set up desktop bookmarks for SecureDrop!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so one issue i hit was that my desktop icons didnt show up right away -- i know thats not a new issue and cant find a specific fix online (gnome's refresh alt+f2 --> r) didnt resolve it for me. rebooting did tho. so i dunno if we want to say hey if your icons arent showing up on desktop, please reboot

@conorsch responded in chat: i noticed that too mike, you can quote my observation when you comment on github. my gut tells me there's some handler we can run to refresh the desktop, bu ti don't know what it is

Copy link
Contributor

@msheiny msheiny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really solid set of changes @conorsch !! I have nothing to add on the script changes 🎩 My only comment I would consider would be the modification of the desktop icons (remove standard tails icons and add ours). This is not critical for passage of this PR but if you decide to pass on those action items let me know and I'll make a new ticket to cover em.

@conorsch
Copy link
Contributor Author

Unfortunately the Tails desktop icons are baked in. Removing them from ~/Persistent/Desktop only works for the current session, since the icons are copied to that location from /etc/skel. Removing the icons in /etc/skel/Desktop doesn't work across reboots due to Tails not storing system state changes.

Technically we could shoehorn some customization logic into the securedrop_init.py script that's run via NetworkManager, but I don't want to overload that script more than absolutely necessary. If anyone feels strongly about removing the Tails-specific desktop icons, open a separate issue to discuss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants