Skip to content

Commit

Permalink
🧪 TEST: Start molecule container with systemd as PID1 (#62)
Browse files Browse the repository at this point in the history
This allows for the tests to run in an environment more closely representing that of the Quantum Mobile VM, and won't skip all the systemd specific tasks.
  • Loading branch information
chrisjsewell authored Dec 6, 2020
1 parent 5e09428 commit 4b22ace
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ aiida_install_packages:
- reentry~=1.3
- fastentrypoints~=0.12
- ipykernel # required to add the venv as a kernel
- numpy~=1.17 # required for pymatgen install (to build c-extesions)
- numpy~=1.17 # required for pymatgen install (see https://github.com/aiidateam/aiida-core/issues/4614)
# these are additional to those extracted from aiida-core and its extras
aiida_extra_packages: []
aiida_jupyter_packages:
Expand Down
5 changes: 3 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@
vars:
nodejs_version: 12.x
nodejs_install_npm_user: root

- name: Create dummy pw executable
copy:
content: ""
dest: /usr/bin/pw.x
force: no
mode: 0666

- include_role:
name: marvel-nccr.aiida
vars:
Expand All @@ -27,6 +29,5 @@
folder: "/usr/bin"
executable: "pw.x"
plugin: quantumespresso.pw
# dashes used to break systemd templates for daemon/rest api
aiida_profile_name: name-with-dashes
aiida_profile_name: name-with-dashes # use dashes to check systemd compatibility
vm_headless: false # test creation of desktop shortcut
3 changes: 2 additions & 1 deletion molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ driver:
platforms:
- name: instance
image: "marvelnccr/docker-${MOLECULE_DISTRO:-ubuntu1804}-ansible:latest"
command: "${MOLECULE_DOCKER_COMMAND:-sleep infinity}"
# by default the container will initialise with systemd as PID1
command: ${MOLECULE_DOCKER_COMMAND:-""}
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
Expand Down
1 change: 1 addition & 0 deletions tasks/aiida-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
value: >-
AiiDA is installed in a Python {{ aiida_python_version }} venv: {{ aiida_venv }}.
Type 'workon aiida' to get access to the 'verdi' commands.
See https://aiidateam.github.io/aiida-registry for plugin information.
- name: Document plugins
when: release_notes is defined and release_notes
Expand Down
6 changes: 3 additions & 3 deletions tasks/aiida-daemon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@
daemon_aiida_venv: "{{ aiida_venv | regex_replace('\\$\\{HOME}', current_user_home) }}"
when: ansible_service_mgr == "systemd"

- name: Start AiiDA Daemon system service
- name: Start AiiDA Daemon system service (systemd)
become: true
become_user: "{{ root_user }}"
systemd:
name: aiida-daemon@{{ aiida_profile_name }}
enabled: true
masked: false
daemon-reload: true
state: restarted
state: started
when: ansible_service_mgr == "systemd"

- block:
- name: Check if the AiiDA daemon is running
command: "{{ aiida_venv }}/bin/verdi -p {{ aiida_profile_name }} daemon status"
changed_when: false
rescue:
- name: Start AiiDA Daemon
- name: Start AiiDA Daemon (non-systemd)
command: "{{ aiida_venv }}/bin/verdi -p {{ aiida_profile_name }} daemon start"
when: ansible_service_mgr != "systemd"
1 change: 0 additions & 1 deletion tasks/aiida-deps-rhel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
command: "{{ aiida_postgres_bin_location }}/initdb {{ aiida_postgres_data_location }}"
args:
creates: "{{ aiida_postgres_data_location }}/pg_hba.conf"
when: ansible_service_mgr != "systemd"

# Avoid password on postgres, fix in future so that we can use md5
- name: put a trust configured pg_hba in place of the default
Expand Down
10 changes: 5 additions & 5 deletions tasks/aiida-prepare.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
- name: Start services for systemd
when: ansible_service_mgr == "systemd"
block:
- name: Start Postgresql service
- name: Start Postgresql service (systemd)
become: true
become_user: "{{ root_user }}"
service:
name: "postgresql"
state: "started"
enabled: true
# see https://github.com/marvel-nccr/quantum-mobile/issues/111
- name: Ensure correct RabbitMQ shutdown
- name: Ensure correct RabbitMQ shutdown (systemd)
become: true
become_user: "{{ root_user }}"
lineinfile:
path: /lib/systemd/system/rabbitmq-server.service
regexp: ExecStop=/usr/sbin/rabbitmqctl stop
line: ExecStop=/usr/sbin/rabbitmqctl shutdown
- name: Start RabbitMQ service
- name: Start RabbitMQ service (systemd)
become: true
become_user: "{{ root_user }}"
service:
Expand All @@ -31,7 +31,7 @@
shell: pgrep postgres
changed_when: false
rescue:
- name: Start Postgresql
- name: Start Postgresql (non-systemd)
become: true
become_user: "{{ aiida_postgres_user }}"
command: "{{ aiida_postgres_bin_location }}/pg_ctl start -D {{ aiida_postgres_data_location }} -s -o '-p 5432' -w -t 300"
Expand All @@ -43,7 +43,7 @@
shell: pgrep rabbitmq
changed_when: false
rescue:
- name: Start RabbitMQ
- name: Start RabbitMQ (non-systemd)
become: true
become_user: "{{ root_user }}"
shell: rabbitmq-server > /dev/null 2>&1 &
Expand Down

0 comments on commit 4b22ace

Please sign in to comment.