From 5f1da67103e5198e260cbb6be03c7ec64b8a5287 Mon Sep 17 00:00:00 2001 From: Miguel Angel Medinilla Luque Date: Wed, 17 Jan 2018 13:50:23 +0100 Subject: [PATCH] Add configure SS and pipeline This PR will use the features added by the following PRs: -https://github.com/artefactual/archivematica/pull/681 -https://github.com/artefactual/archivematica-storage-service/pull/213 Specifically, this PR allows to: a) Create a SS superuser b) Create a dashboard admin user and register the pipeline on the SS. To configure SS and pipeline on a deployment, the following boolean extra-vars have to be enabled: - archivematica_src_configure_dashboard: To create the dashboard admin user and to register pipeline on SS - archivematica_src_configure_ss: To create SS superuser They are disabled by default. --- README.md | 1 + defaults/main.yml | 17 ++++++++++++++ tasks/configure.yml | 54 +++++++++++++++++++++++++++++++++++++++++++++ tasks/main.yml | 9 ++++++++ 4 files changed, 81 insertions(+) create mode 100644 tasks/configure.yml diff --git a/README.md b/README.md index f75cc3b9..88b14a67 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ Note that if something is disabled with the [role variables](#role-variables), i - `amsrc-pipeline-websrv`: Configure webserver - `amsrc-devtools`: Archivematica devtools install - `amsrc-automationtools`: Automation tools install +- `amsrc-configure`: Create SS superuser & create dashboard admin & register pipeline on SS Dependencies diff --git a/defaults/main.yml b/defaults/main.yml index f4d16eef..ce19cb2d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -16,6 +16,10 @@ archivematica_src_install_acceptance_tests: "no" archivematica_src_install_fixity: "no" archivematica_src_search_enabled: "yes" +#Components to configure +archivematica_src_configure_dashboard: "no" +archivematica_src_configure_ss: "no" + # Define the type of environment: "production" or "development". The latter will deploy some extra stuff to make the development workflow easier. archivematica_src_environment_type: "production" @@ -126,3 +130,16 @@ archivematica_src_fixity_version: "master" archivematica_src_fixity_ss_url: "http://localhost:8000" archivematica_src_fixity_ss_user: "test" archivematica_src_fixity_ss_apikey: "XXXX" + +# Configure AM +# archivematica_src_configure_am_api_key & archivematica_src_configure_ss_api_key can be defined as vars. If not defined they will be autogenerated by the playbook +archivematica_src_configure_ss_user: "test" # SS superuser +archivematica_src_configure_ss_password: "PleaseChangeMe!" # SS superuser password +archivematica_src_configure_ss_email: "test@example.com" # SS superuser email address +archivematica_src_configure_ss_url: "http://localhost:8000" # SS url to register the pipeline +archivematica_src_configure_am_user: "test" # Dashboard admin +archivematica_src_configure_am_password: "PleaseChangeMe!" # Dashboard admin password +archivematica_src_configure_am_email: "test@example.com" # Dashboard admin password +archivematica_src_configure_am_org_name: "test org" # Dashboard admin Org name +archivematica_src_configure_am_org_id: "test id" # Dashboard admin Org id +archivematica_src_configure_am_whitelist: '""' # Dashboard API whitelist, IP address or hostnames separated by blank spaces and inside quotes diff --git a/tasks/configure.yml b/tasks/configure.yml new file mode 100644 index 00000000..1d7ac2a5 --- /dev/null +++ b/tasks/configure.yml @@ -0,0 +1,54 @@ +--- +# ss-configure + +# Create api-key if not defined +- set_fact: archivematica_src_configure_ss_api_key={{ 999999999999999999999 | random | to_uuid | hash('md5') }} + when: "archivematica_src_configure_ss_api_key is undefined and archivematica_src_configure_ss|bool" + +# Delete default SS superuser test +- name: "Delete default SS superuser" + become: "yes" + shell: echo "from django.contrib.auth.models import User;User.objects.get(username='test').delete()" | {{ archivematica_src_ss_virtualenv }}/bin/python manage.py shell + args: + chdir: "{{ archviematica_src_ss_app }}" + executable: /bin/bash + environment: "{{ archivematica_src_ss_environment }}" + when: "archivematica_src_configure_ss|bool" + +- name: "Create SS superuser" + django_manage: + command: > + create_user + --username="{{ archivematica_src_configure_ss_user }}" + --password="{{ archivematica_src_configure_ss_password }}" + --email="{{ archivematica_src_configure_ss_email }}" + --api-key="{{ archivematica_src_configure_ss_api_key }}" + --superuser + app_path: "{{ archviematica_src_ss_app }}" + virtualenv: "{{ archivematica_src_ss_virtualenv }}" + environment: "{{ archivematica_src_ss_environment }}" + when: "archivematica_src_configure_ss|bool" + +# dashboard-configure + +# Create api-key if not defined +- set_fact: archivematica_src_configure_am_api_key={{ 999999999999999999998 | random | to_uuid | hash('md5') }} + when: archivematica_src_configure_am_api_key is undefined + +- name: "Create Dashboard user and register pipeline on SS" + django_manage: + command: > + install --username="{{ archivematica_src_configure_am_user }}" + --password="{{ archivematica_src_configure_am_password }}" + --email="{{ archivematica_src_configure_am_email }}" + --org-name="{{ archivematica_src_configure_am_org_name }}" + --org-id="{{ archivematica_src_configure_am_org_id }}" + --api-key="{{ archivematica_src_configure_am_api_key }}" + --ss-url="{{ archivematica_src_configure_ss_url }}" + --ss-user="{{ archivematica_src_configure_ss_user }}" + --ss-api-key="{{ archivematica_src_configure_ss_api_key }}" + --whitelist="{{archivematica_src_configure_am_whitelist}}" + app_path: "{{ archivematica_src_am_dashboard_app }}" + pythonpath: "{{ archivematica_src_am_common_app }}" + virtualenv: "{{ archivematica_src_am_dashboard_virtualenv }}" + when: "archivematica_src_configure_dashboard|bool" diff --git a/tasks/main.yml b/tasks/main.yml index df23ed6b..701e91ec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -228,3 +228,12 @@ tags: - "amsrc-fixity" when: "archivematica_src_install_fixity|bool" + +# +# Configure pipeline and SS +# + +- include: "configure.yml" + tags: + - "amsrc-configure" + when: "archivematica_src_configure_ss|bool or archivematica_src_configure_dashboard|bool"