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

added --preserve-tor-config flag to securedrop-admin restore #5115

Merged
merged 1 commit into from
Feb 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion admin/securedrop_admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -698,12 +698,25 @@ def restore_securedrop(args):
# Would like readable output if there's a problem
os.environ["ANSIBLE_STDOUT_CALLBACK"] = "debug"

ansible_cmd = [
ansible_cmd_full_restore = [
'ansible-playbook',
os.path.join(args.ansible_path, 'securedrop-restore.yml'),
'-e',
"restore_file='{}'".format(restore_file_basename),
]

ansible_cmd_skip_tor = [
'ansible-playbook',
os.path.join(args.ansible_path, 'securedrop-restore.yml'),
'-e',
"restore_file='{}' restore_skip_tor='True'".format(restore_file_basename),
]

if args.restore_skip_tor:
ansible_cmd = ansible_cmd_skip_tor
else:
ansible_cmd = ansible_cmd_full_restore

return subprocess.check_call(ansible_cmd, cwd=args.ansible_path)


Expand Down Expand Up @@ -935,6 +948,10 @@ class ArgParseFormatterCombo(argparse.ArgumentDefaultsHelpFormatter,
help=restore_securedrop.__doc__)
parse_restore.set_defaults(func=restore_securedrop)
parse_restore.add_argument("restore_file")
parse_restore.add_argument("--preserve-tor-config", default=False,
action='store_true',
dest='restore_skip_tor',
help="Preserve the server's current Tor config")

parse_update = subparsers.add_parser('update', help=update.__doc__)
parse_update.set_defaults(func=update)
Expand Down
3 changes: 3 additions & 0 deletions admin/tox.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[tox]
envlist = pylint,flake8,py3

[flake8]
max-line-length = 100

[testenv]
usedevelop = true
deps =
Expand Down
9 changes: 9 additions & 0 deletions install_files/ansible-base/roles/restore/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
dest: /
remote_src: yes
src: "/tmp/{{ restore_file}}"
when: restore_skip_tor is not defined

- name: Extract backup, skipping tor service configuration
unarchive:
dest: /
remote_src: yes
src: "/tmp/{{ restore_file}}"
exclude: "var/lib/tor,etc/tor/torrc"
when: restore_skip_tor is defined

- name: Reconfigure securedrop-app-code
command: dpkg-reconfigure securedrop-app-code
Expand Down