Skip to content
Snippets Groups Projects
install_test_scripts.yml 2.97 KiB
---
### INSTALL TEST SCRIPTS ###

- name: install prerequisites
  apt:
    update_cache: true
    name: [
      'libdata-printer-perl',
      'libdatetime-format-http-perl',
      'libio-pty-perl',
    ]
    state: latest
- name: install prerequisites for deep_fixity
  apt:
    update_cache: true
    name: [
      'libcryptx-perl',
      'libdigest-crc-perl',
    ]
    state: latest
# This plugin is part of the community.general collection (version 4.0.2), which might not be installed on your computer.
# https://docs.ansible.com/ansible/latest/collections/community/general/cpanm_module.html
- name:
  community.general.cpanm:
    name: "Getopt::Long::Complete"

- name: deploy wrapper script for exit strategy
  template:
    src: "{{ item }}.j2"
    dest: "/usr/local/bin/{{ item }}"
    owner: "root"
    group: "lza"
    mode: "0755"
  loop:
    - "test_exit_strategy.sh"

- name: deploy test scripts from Git
  ansible.builtin.git:
    dest: "/usr/local/bin/{{ item.dest }}"
    repo: "{{ item.repo }}"
    version: "{{ item.version | default(omit) }}"
    force: "{{ item.force | default(true) }}"
    accept_hostkey: "{{ item.accept_hostkey | default(true) }}"
    single_branch: "{{ item.single_branch | default(true) }}"
    recursive: "{{ item.recursive | default(false) }}"
    key_file: "~/.ssh/id_ed25519_deploykey"
  loop:
    # runs all the pre-/post-upgrade tests on Rosetta and SubApp servers
    - dest: "rosetta_update_test/"
      repo: "git@{{ vault_slub_git_repo_fqdn }}:slub-digitalpreservation/rosetta_update_test.git"
      version: "c61918f9cbcba28b1ac0490055fe3fa69467eaee"
    # runs the Exit Strategy script to build an emergency database
    - dest: "rosettaExitStrategy/"
      repo: "git@{{ vault_slub_git_repo_fqdn }}:slub-digitalpreservation/rosettaExitStrategy.git"
    - dest: "rosettaDeepFixity/"
      repo: "git@{{ vault_slub_git_repo_fqdn }}:digital-preservation/rosettadeepfixity.git"

- name: Perl syntax check for exit strategy script
  command: "perl -c /usr/local/bin/rosettaExitStrategy/perl/exit_strategy.pl"
  register: depcheck_exit
  failed_when: "'syntax OK' not in depcheck_exit.stderr"
  changed_when: false
- name: test if prerequisites for exit strategy script are installed
  ansible.builtin.assert:
    that:
      - "'syntax OK' in depcheck_exit.stderr"
      - "depcheck_exit.rc == 0"
    fail_msg: "{{ depcheck_exit.stderr }}"
    success_msg: "exit strategy script has all required prerequisites installed"