From 98ebe81784b038c379c67274ee5a77d47c5f8dd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Fri, 22 Nov 2024 18:31:05 +0100 Subject: [PATCH 1/4] Rerun dashboard configuration if ss changes --- tasks/configure.yml | 62 +++------------------------------------------ 1 file changed, 3 insertions(+), 59 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 798e727..959a828 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -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) # @@ -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 From 34912f2f6a2233169f936c71aa2741be31f00eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Fri, 22 Nov 2024 18:36:40 +0100 Subject: [PATCH 2/4] Refactor default locations configuration Use same methods than for remote locations --- tasks/configure-aipstores.yml | 82 +++++++++++++++++++++++++++++++++++ tasks/main.yml | 7 +++ 2 files changed, 89 insertions(+) create mode 100644 tasks/configure-aipstores.yml diff --git a/tasks/configure-aipstores.yml b/tasks/configure-aipstores.yml new file mode 100644 index 0000000..2c00055 --- /dev/null +++ b/tasks/configure-aipstores.yml @@ -0,0 +1,82 @@ +--- +## 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 }}" + when: __pipeline_uuid_query.rowcount[0] > 0 diff --git a/tasks/main.yml b/tasks/main.yml index 3887993..4b6b4e3 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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" From aa14e719062de740cc84bf40b07c07a284c6ef50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Wed, 27 Nov 2024 11:56:33 +0100 Subject: [PATCH 3/4] Allow for disabled locations configuration --- defaults/main.yml | 5 +++++ tasks/configure-aipstores.yml | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index b089059..33d8876 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/tasks/configure-aipstores.yml b/tasks/configure-aipstores.yml index 2c00055..fc41b20 100644 --- a/tasks/configure-aipstores.yml +++ b/tasks/configure-aipstores.yml @@ -79,4 +79,19 @@ - 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 From ed44e3e8b4b2ac6b6e6835b34e43cdf4cb836a22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Santiago=20Rodr=C3=ADguez?= Date: Thu, 28 Nov 2024 10:05:25 +0100 Subject: [PATCH 4/4] Configure RHEL repositories on RockyLinux --- tasks/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 4b6b4e3..d2faa17 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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