/ansible-role-aiida

An ansible role that installs and configures AiiDA on Ubuntu.

Primary LanguagePythonOtherNOASSERTION

CI (debian) CI (redhat) Ansible Role Release

Ansible Role: marvel-nccr.aiida

An ansible role that installs and configures AiiDA on Ubuntu, RHEL, CentOS and Fedora.

The role:

  • Installs and starts the PostgreSQL and RabbitMQ services
  • Installs a designated Python version
  • Creates an 'aiida' Python virtual environment and installs aiida-core and plugins into it
  • Creates a 'jupyter' Python virtual environment and installs Jupyter and Jupyter Lab into it, then links the virtual environment as a kernel.
  • Adds virtualenwrapper for managing the virtual environments.
  • Creates an AiiDA profile and starts the daemon
  • Starts the AiiDA REST API
  • Sets up localhost codes for the AiiDA plugins (where code paths are defined)
  • Sets up pseudopotential families in the AiiDA profile

Installation

ansible-galaxy install marvel-nccr.aiida

Role Variables

See defaults/main.yml

Example Playbook

- hosts: servers
  roles:
  - role: marvel-nccr.aiida

For full use of JupyterLab, install nodejs, e.g. using geerlingguy.nodejs:

- hosts: servers
  tasks:
  - include_role:
      name: geerlingguy.nodejs
    vars:
      nodejs_version: 12.x
      nodejs_install_npm_user: root
  - include_role:
      name: marvel-nccr.aiida

Note: When building a Docker container, the variable jupyter_ip: "0.0.0.0" should be set, for aiida-jupyterlab to correctly expose the port.

Usage

Once run, the user can "activate" the aiida environment in the terminal using:

$ workon aiida
(aiida) $ verdi status
verdi status
 ✔ config dir:  /root/.aiida
 ✔ profile:     On profile name-with-dashes
 ✔ repository:  /root/.aiida/repository/name-with-dashes
 ✔ postgres:    Connected as aiida@localhost:5432
 ✔ rabbitmq:    Connected as amqp://guest:guest@127.0.0.1:5672?heartbeat=600
 ✔ daemon:      Daemon is running as PID 9484 since 2020-11-30 21:51:30

To start a jupyter lab server:

$ aiida-jupyterlab
...
    To access the notebook, open this file in a browser:
        file:///root/.local/share/jupyter/runtime/nbserver-14617-open.html
    Or copy and paste one of these URLs:
        http://localhost:8890/?token=a7086764cda7aba8488a767386d57121429958771a8bccb2
     or http://127.0.0.1:8890/?token=a7086764cda7aba8488a767386d57121429958771a8bccb2

Development and testing

This role uses Molecule and Docker for tests.

After installing Docker:

Clone the repository into a package named marvel-nccr.aiida (the folder must be named the same as the Ansible Galaxy name)

git clone https://github.com/marvel-nccr/ansible-role-aiida marvel-nccr.aiida
cd marvel-nccr.aiida

Then run:

pip install -r requirements.txt  # Installs molecule
molecule test  # runs tests

or use tox (see tox.ini):

pip install tox
tox

To manually test the created docker container, first run:

tox converge

This will run the ansible role, leaving the container running. The recommended way to interact with the container is then to use the VS Code Docker extension. Using this you can then attach a visual studio code instance:

VS Code Docker extension

Inside the container run aiida-jupyterlab, and you will be able to access the supplied URL from your local browser.

When you are finished with the container, destroy the container with:

tox destroy

Code style

Code style is formatted and linted with pre-commit.

pip install pre-commit
pre-commit run -all

Deployment

Deployment to Ansible Galaxy is automated via GitHub Actions. Simply tag a release vX.Y.Z to initiate the CI and release workflow. Note, the release will only complete if the CI tests pass.

License

MIT

Contact

Please direct inquiries regarding Quantum Mobile and associated ansible roles to the AiiDA mailinglist.