Skip to content
Open
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
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ archivematica_src_syslog_mcpserver_level: "DEBUG"
# - { location_purpose: "RP", location_path: "/replicator", location_description: "Replicator location", location_default: "false", location_replication_from: "AipStore" }
# - { location_purpose: "AS", location_path: "/aipstore", location_description: "AipStore", location_default: "true" }
# - { location_purpose: "TS", location_path: "/transfer-source/", location_description: "Transfer Source", location_default: "false" }
# - { location_purpose: "AS", location_description: "Store AIP in standard Archivematica Directory", location_enabled: "false" }
# - { location_purpose: "DS", location_description: "Store DIP in standard Archivematica Directory", location_enabled: "false" }
# - { location_purpose: "TS", location_description: "Default transfer source", location_enabled: "false" }
# - { location_purpose: "BL", location_description: "Default transfer backlog", location_enabled: "false" }



# Configure Remote pipeline
Expand Down
97 changes: 97 additions & 0 deletions tasks/configure-aipstores.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
## Configure default locations
# Get id of the associated pipeline
- name: "Configure SS: Get default pipeline UUID from SS database"
mysql_query:
login_db: "{{ archivematica_src_ss_db_name }}"
login_user: "{{ archivematica_src_ss_db_user }}"
login_password: "{{ archivematica_src_ss_db_password }}"
login_host: "{{ archivematica_src_ss_db_host }}"
query: >
SELECT uuid FROM locations_pipeline WHERE remote_name like %(pipeline)s;
named_args:
pipeline: "%{{ archivematica_src_remote_pipeline }}%"
register: __pipeline_uuid_query

- name: "Configure SS: Set pipeline_uuid"
set_fact:
__pipeline_uuid: "{{ (__pipeline_uuid_query.query_result |flatten | first).uuid }}"
when: __pipeline_uuid_query.rowcount[0] > 0

# If pipeline_uuid exists, configure the space and locations
- name: "Configure SS: Configure pipeline local filesystem space and locations"
block:
- name: "Configure SS default spaces: Check if the space already exist"
uri:
url: "{{ archivematica_src_configure_ss_url }}/api/v2/space/?access_protocol=FS"
headers:
Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}"
register: "__space_list"


- name: "Configure SS remote pipeline: Check uuid for local filesystem space"
uri:
url: "{{ archivematica_src_configure_ss_url }}/api/v2/space/?access_protocol=FS"
headers:
Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}"
register: "__local_space_list"

- name: "Configure SS remote pipeline: Set uuid for default filesystem space"
set_fact:
__local_space_uuid: "{{ __local_space_list.json.objects[0].uuid }}"
- name: "Configure AM: get all TS descriptions from SS database"
become: "yes"
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select description from locations_location;"
register: location_descriptions
tags: "configure-am"

- name: "Configure SS default locations: Add custom locations"
uri:
url: "{{ archivematica_src_configure_ss_url }}/api/v2/location/"
headers:
Content-Type: "application/json"
Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}"
body:
pipeline: ["/api/v2/pipeline/{{ __pipeline_uuid }}/"]
purpose: "{{ item.location_purpose }}"
relative_path: "{{ item.location_path | regex_replace('^\\/', '') }}"
description: "{{ item.location_description }}"
space: "/api/v2/space/{{ __local_space_uuid }}/"
default: "{{ item.location_default }}"
body_format: json
status_code: 201
method: POST
with_items: "{{ am_ss_default_locations }}"
when: not location_descriptions.stdout | join('') | regex_search( '(^|\n)'+item.location_description+'(\n|$)' )
tags: "configure-am"
- name: "Configure SS: configure replication locations "
mysql_query:
login_db: "{{ archivematica_src_ss_db_name }}"
login_user: "{{ archivematica_src_ss_db_user }}"
login_password: "{{ archivematica_src_ss_db_password }}"
login_host: "{{ archivematica_src_ss_db_host }}"
query:
- INSERT IGNORE INTO locations_location_replicators(from_location_id,to_location_id) VALUES ((SELECT id FROM locations_location where description = %(aipstore)s and purpose = "AS"),(SELECT id FROM locations_location where description = %(replica)s and purpose = "RP" ));
named_args:
aipstore: "{{ item.location_replication_from }}"
replica: "{{ item.location_description }}"
when:
- item.location_replication_from is defined
with_items:
- "{{ am_ss_default_locations }}"
- name: "Configure SS: disable unused locations "
mysql_query:
login_db: "{{ archivematica_src_ss_db_name }}"
login_user: "{{ archivematica_src_ss_db_user }}"
login_password: "{{ archivematica_src_ss_db_password }}"
login_host: "{{ archivematica_src_ss_db_host }}"
query:
- UPDATE locations_location SET enabled=0 WHERE description = %(aipstore)s ;
named_args:
aipstore: "{{ item.location_description }}"
when:
- item.location_enabled is defined
with_items:
- "{{ am_ss_default_locations }}"

when: __pipeline_uuid_query.rowcount[0] > 0
62 changes: 3 additions & 59 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@
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_ss_url.stdout == ""
when:
- archivematica_src_configure_dashboard|bool
- (dashboard_user.stdout == "" and dashboard_ss_url.stdout == "") or ( dashboard_ss_url.stdout != archivematica_src_configure_ss_url)


#
Expand Down Expand Up @@ -262,61 +264,3 @@
- archivematica_src_configure_dashboard|bool
- archivematica_src_configure_fprule is defined

- name: "Configure locations"
block:
# Get id of the first registered pipeline (id=1)
- name: "Configure AM: get default pipeline UUID from SS database"
become: "yes"
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select uuid from locations_pipeline where id='1';"
register: pipeline_uuid
tags: "configure-am"

# Gets the uuid of the first registered space (id=1)
- name: "Configure AM: get default Space UUID from SS database"
become: "yes"
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select uuid from locations_space where id='1';"
register: space_uuid
tags: "configure-am"

- name: "Configure AM: get all TS descriptions from SS database"
become: "yes"
command: mysql {{ archivematica_src_ss_db_name }} -Ns -e "select description from locations_location;"
register: location_descriptions
tags: "configure-am"

- name: "Configure SS: add custom locations"
uri:
url: "{{ archivematica_src_configure_ss_url }}/api/v2/location/"
headers:
Content-Type: "application/json"
Authorization: "ApiKey {{ archivematica_src_configure_ss_user }}:{{ archivematica_src_configure_ss_api_key }}"
body:
pipeline: ["/api/v2/pipeline/{{ pipeline_uuid.stdout }}/"]
purpose: "{{ item.location_purpose }}"
relative_path: "{{ item.location_path | regex_replace('^\\/', '') }}"
description: "{{ item.location_description }}"
space: "/api/v2/space/{{ space_uuid.stdout }}/"
default: "{{ item.location_default }}"
body_format: json
status_code: 201
method: POST
when: not location_descriptions.stdout | join('') | regex_search( '(^|\n)'+item.location_description+'(\n|$)' )
with_items: "{{ am_ss_default_locations }}"
tags: "configure-am"

- name: "Configure SS: configure replication locations "
mysql_query:
login_db: "{{ archivematica_src_ss_db_name }}"
login_user: "{{ archivematica_src_ss_db_user }}"
login_password: "{{ archivematica_src_ss_db_password }}"
login_host: "{{ archivematica_src_ss_db_host }}"
query:
- INSERT IGNORE INTO locations_location_replicators(from_location_id,to_location_id) VALUES ((SELECT id FROM locations_location where description = %(aipstore)s and purpose = "AS"),(SELECT id FROM locations_location where description = %(replica)s and purpose = "RP" ));
named_args:
aipstore: "{{ item.location_replication_from }}"
replica: "{{ item.location_description }}"
when:
- item.location_replication_from is defined
with_items:
- "{{ am_ss_default_locations }}"
when: am_ss_default_locations is defined
9 changes: 8 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
- name: "Include common-RHEL.yml for RHEL"
import_tasks: "common-RHEL.yml"
when:
- "ansible_distribution == 'RedHat'"
- "ansible_os_family in ['RedHat','Rocky']"

# Not using package in next task because it is slower than apt or yum modules.
# The package module is not installing the every list of packages at the same time
Expand Down Expand Up @@ -354,6 +354,13 @@
when: "archivematica_src_configure_ss|bool or archivematica_src_configure_dashboard|bool"


- import_tasks: "configure-aipstores.yml"
tags:
- "amsrc-configure"
when:
- archivematica_src_configure_ss|bool


# Configure remote pipeline spaces

- import_tasks: "configure-remote-pipeline.yml"
Expand Down