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

Add configure SS and pipeline #162

Merged
merged 4 commits into from
Aug 8, 2018
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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: "[email protected]" # 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: "[email protected]" # 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
78 changes: 78 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
# 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"
ignore_errors: "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

# Check whether pipeline is registered and dashboard user exists

- name: Check Dashboard SS url
become: "yes"
command: mysql {{ archivematica_src_am_db_name }} -Ns -e "select * from DashboardSettings where name='storage_service_url'"
register: dashboard_ss_url

- debug:
msg: "The pipeline is already configured: The dashboard superuser will not be created and the pipeline will not be registered."
when: dashboard_ss_url.stdout != "" and archivematica_src_configure_dashboard|bool

- name: Check Dashboard user
become: "yes"
command: mysql {{ archivematica_src_am_db_name }} -Ns -e "select * from auth_user where username='{{ archivematica_src_configure_am_user }}'"
register: dashboard_user

- debug:
msg: "The dashboard user {{ archivematica_src_configure_am_user }} is already configured: The dashboard superuser will not be created and the pipeline will not be registered."
when: dashboard_user.stdout != "" and archivematica_src_configure_dashboard|bool


# 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 }}"
environment: "{{ archivematica_src_am_dashboard_environment }}"
when: archivematica_src_configure_dashboard|bool and dashboard_user.stdout == "" and dashboard_user.stdout == ""
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"