GithubHelp home page GithubHelp logo

hifis-net / ansible-role-rsd Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 2.0 317 KB

Ansible role to set up the Research Software Directory.

Home Page: https://galaxy.ansible.com/hifis/rsd

License: Other

Jinja 100.00%
rsd research-software-directory ansible ansible-role ansible-galaxy rsd-as-a-service

ansible-role-rsd's People

Watchers

 avatar

ansible-role-rsd's Issues

Add preflight checks

Check if requirements are met before setting up the RSD:

  • Docker SDK for Python
  • docker available
  • docker-compose available
  • ...

Unsupported config option for services.initial-spotlight: pull_policy

When using

    rsd_migrate_spotlights: true
    rsd_spotlight_migration_image: >-
      ghcr.io/hifis-net/rsd-spotlight-migration:latest

The ansible role crashes in the task Copy docker-compose.yml:

fatal: [*********.de]: FAILED! => {"changed": false, "checksum": 
"08f25fcdc74731da899da1c735b4599835bea5a3", "exit_status": 1, "msg": "failed to validate", "stderr":
 "The POSTGRES_AUTHENTICATOR_PASSWORD variable is not set. Defaulting to a blank string.\nThe 
POSTGRES_DB variable is not set. Defaulting to a blank string.\nThe Compose file 
'/home/******/.ansible/tmp/ansible-tmp-1666613486.006113-46971-4951698144570/source' is invalid 
because:\nUnsupported config option for services.initial-spotlights: 'pull_policy'\n", 
"stderr_lines": ["The POSTGRES_AUTHENTICATOR_PASSWORD variable is not set. Defaulting to a blank 
string.", "The POSTGRES_DB variable is not set. Defaulting to a blank string.", "The Compose file 
'/home/******/.ansible/tmp/ansible-tmp-1666613486.006113-46971-4951698144570/source' is invalid 
because:", "Unsupported config option for services.initial-spotlights: 'pull_policy'"], "stdout": 
"", "stdout_lines": []}

As far as I could see this is related to docker-compose not being the latest version 2.x:

terra-money/LocalTerra#46

Add option to remove existing containers and volumes

Sometimes it is necessary to remove the previous RSD containers and/or volumes (for example if a new database table or column was added). It would be nice to have a way to remove the previously run containers. For database changes it is also needed to remove the connected volume rsd_pgdb, so a second option in the role for removing volumes would also be needed.

Remove dependency on the inventory when copying TLS certificates

Currently, the certificate files have to be located in a directory with the same name as the inventory directory.

- name: "Copy TLS certificates"
  ansible.builtin.copy:
--> src: "{{ (inventory_dir | basename, item.file) | path_join }}"  <---
    dest: "{{ (item.dest, item.file | basename ) | path_join }}"
    owner: "root"
    group: "root"
    mode: "{{ item.mode }}"
  loop:
    - { file: "{{ rsd_tls_cert_file }}", dest: "/etc/ssl/certs", mode: "0644" }
    - { file: "{{ rsd_tls_key_file }}", dest: "/etc/ssl/private", mode: "0600" }
  no_log: True

It should be independent of the Inventory in the future.

Bug: RSD environment template file not found

The environment template file rsd-secrets.env.j2 is currently not used due to multiple issues:

  • wrong file name stored in default role variable rsd_environment_file
  • task "Copy environment file" requires the module ansible.builtin.template but is using the copy module instead

Provide citation metadata

Manage citation metadata as part of the source code repository by providing a file codemeta.json (machine-readable information about your software including citation metadata) or providing a file CITATION.cff (human/machine-readable citation metadata).

Image by tag is not pulled if tag does not change

If the image tag does not change, a new image is not pulled by community.docker.docker_compose. This happens on the latest image tag.

The expected behavior on running the role again with the latest tag is that the new image is pulled, but this is not the case.

Possible solutions:

  • set pull: true in community.docker.docker_compose task, but that would always pull the image(s)
  • introduce a new configuration variable to force pull
  • set pull to true if rsd_version is latest

Use different Docker storage driver in Molecule tests

Currently, vfs is used as storage driver in Molecule tests If possible, this should be replaced by overlay2.

storage-driver: "vfs"

The reason for chosing vfs (copied from #11 (comment)): The Docker daemon did not start properly using overlay2, overlay, or devicemapper:

TASK [geerlingguy.docker : Ensure Docker is started and enabled at boot.] ******
fatal: [instance_rsd]: FAILED! => changed=false 
  msg: |-
    Unable to start service docker: Job for docker.service failed because the control process exited with error code.
    See "systemctl status docker.service" and "journalctl -xe" for details.

When using the default aufs storage driver, building Docker images failed:

TASK [rsd-role : Build containers with docker-compose] *************************
fatal: [instance_rsd]: FAILED! => changed=false 
  errors: []
  module_stderr: ''
  module_stdout: |-
    Step 1/11 : FROM node:14-alpine
     ---> 6f5dba13ae83
    Step 2/11 : RUN mkdir /app
  msg: 'Error: build failed with (<Service: admin>, ''error creating aufs mount to /var/lib/docker/aufs/mnt/1de234b3b477398643d1f2766c6e08a363a903a61dc7121eef9309ff16d8eef6-init: mount target=/var/lib/docker/aufs/mnt/1de234b3b477398643d1f2766c6e08a363a903a61dc7121eef9309ff16d8eef6-init data=br:/var/lib/docker/aufs/diff/1de234b3b477398643d1f2766c6e08a363a903a61dc7121eef9309ff16d8eef6-init=rw:/var/lib/docker/aufs/diff/aba21078893c364b22655c9e0e5670a996809bce3bfe38b010e582103227e2cc=ro+wh:/var/lib/docker/aufs/diff/39e9ed87202c43a70fd0cfffc6d5b2c21ced98cd16cfd10d69e354965c0095bb=ro+wh:/var/lib/docker/aufs/diff/8a680c493805ed7b28767cf21284d46cada253085b49b91d793c93750cbee25f=ro+wh:/var/lib/docker/aufs/diff/708cb20196eec28046307a58287351758e05d59e4396f15bb118ac79d72bbac0=ro+wh,dio,xino=/dev/shm/aufs.xino: invalid argument'')'

Unfortunately, the vfs driver was the only storage driver that worked (at least for me on my local machine).
The hint to use vfs did I found in this issue: geerlingguy/raspberry-pi-dramble#166

Display "under maintenance" message when updating

To avoid data being lost during updates, it would be handy to automatically display a message when we are updating the RSD.

During the last update, I used a replacement nginx template to solve this issue manually:

    location / {
        # Allow quick enabling/disabling of maintenance messages
        if (-f /usr/share/nginx/html/under_maintenance.html) {
            return 503;
        }

        [....]

        error_page 503 /under_maintenance.html;
        location = /under_maintenance.html {
            root /usr/share/nginx/html;
            internal;
        }
    }

As maintenance page I used a simple template:

Edit white-pond-975fre

If the update finished without errors, the maintenance page should disappear again.

Allow to specify how long nginx logs are stored

If I am correct, the nginx container currently stores the log files for 52 days. This is at least what I assume from looking at /etc/logrotate.d/nginx:

/var/log/nginx/*.log {
        daily
        missingok
        rotate 52
        compress
        delaycompress
        notifempty
        create 640 nginx adm
        sharedscripts
        postrotate
                if [ -f /var/run/nginx.pid ]; then
                        kill -USR1 `cat /var/run/nginx.pid`
                fi
        endscript
}

We need to specify that we can remove logs after X days.

docker compose validation fails on systems with Docker Compose CLI plugin

For docker-compose.yml validation the role is using the docker-compose command which may not be available on systems where Docker Compose has been installed as a CLI plugin for Docker which needs to be called via docker compose (without the - dash).

TASK [external/hifis.rsd : Copy docker-compose.yml] ******************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => changed=false 
  checksum: f36df77fa7a513d26a5df7fa2c308711900b8c1e
  cmd: docker-compose -f /root/.ansible/tmp/ansible-tmp-1661158400.6968887-31446-78589091894946/source config -q
  msg: '[Errno 2] No such file or directory: b''docker-compose'''
  rc: 2
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

`AUTH_*_TOKEN_URL` removed

The following environment variables will be removed with the next release of the RSD:

  • AUTH_SURFCONEXT_TOKEN_URL
  • AUTH_HELMHOLTZAAI_TOKEN_URL

Instead, they will be fetched upon each request.

Improve deployment by using docker-compose down + up

If changing a value for an environment variable only some containers are restarted, but this results in an undefined docker-compose state or containers loose their connection between each other. I would suggest to use docker-compose down + docker-compose up for each deployment to avoid errors.

Example: I change the value for rsd_hgfaai_client_id, then the containers auth and frontend are restarted (because the community.docker.docker_compose: state: present knows what changed), but the nginx container lost the connection to the upstream: connect() failed (113: No route to host) while connecting to upstream, ... only a restart of all containers helped in this case

Support custom themes via mounts

There is a new change in the RSD coming up: research-software-directory/RSD-as-a-service#506

If this gets merged we will need an option so that some additional docker mounts are made (via docker-compose.yml), in case of the HIFIS RSD like so:

  frontend:
    ...
    volumes:
      - ./deployment/helmholtz/styles:/app/public/styles
      - ./deployment/helmholtz/data:/app/public/data
      - ./deployment/helmholtz/images:/app/public/images

I would think of having some role variable like rsd_custom_theme which is unset by default. But if it is set then it is used for additional mounts:

  frontend:
    ...
    volumes:
      - ./deployment/{{ rsd_custom_theme }}/styles:/app/public/styles
      - ./deployment/{{ rsd_custom_theme }}/data:/app/public/data
      - ./deployment/{{ rsd_custom_theme }}/images:/app/public/images

I am preparing the merge of this new feature here: hifis-net/RSD-as-a-service#48

Errors during preflight checks in initial dry-run

In the initial dry-run, it is expected that things are missing since there hasn't been a real deployment yet.

TASK [external/hifis.rsd : Assert that required TLS files are present] ***********************************************************************************************************************************************************
fatal: [rsd-staging.hzdr.de]: FAILED! => changed=false 
  assertion: tls_cert.stat.exists
  evaluated_to: false
  msg: TLS certificate and/or private key missing!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.