Files
cobald-testenv/roles/cobald/tasks/main.yml

150 lines
4.2 KiB
YAML

- include_vars: cobald-slurm.yml
when: cobald_slurm | default(False)
tags: always
- name: build cobald:slurm docker image
include_role:
name: slurm
tasks_from: dockerimage
vars:
slurm_image_prefix: cobald
image_name: "{{cobald_image_tag}}"
dockerfile: "{{ lookup('template', 'cobald.Dockerfile') }}"
files_list:
- cobald-entrypoint.sh
- init-cobaldmodules.sh
- start-drone
- 28-sync-container-slurmd
files: "
{%- set files = [] -%} {%- for i in files_list -%}
{%- set files = files.append(
{ 'dest': i, 'content': lookup('file', i) }) -%}
{%- endfor %}{{ files }}"
when: cobald_slurm | default(False)
- name: build generic cobald docker image
include_tasks: dockerimage-generic.yml
when: not (cobald_slurm | default(False))
- name: make cobald data volume
file:
path: "/container/volumes/cobald/"
state: directory
owner: "{{unpriv_user}}"
group: docker
- name: copy cobald config
copy:
src: cobald-config/
dest: "~{{unpriv_user}}/cobald/"
force: False
owner: "{{unpriv_user}}"
group: docker
mode: "0644"
- name: ensure network for cobald container exists
docker_network:
name: "{{cobald_docker_network}}"
state: present
# docker run -v $(pwd)/cobald-config-host:/etc/cobald -v $(pwd)/cobald:/cobald --rm -it cobald bash
- name: install git
yum:
name: git
state: present
- name: make directories for cobald configuration and modules
file:
path: "{{item}}"
owner: "{{unpriv_user}}"
group: "{{unpriv_user}}"
mode: "a=rx,u=rwx"
state: directory
with_items:
- "~{{unpriv_user}}/cobald/modules"
- "~{{unpriv_user}}/cobald"
- name: clone cobald code from git
git:
repo: https://github.com/thoto/cobald
dest: "~{{unpriv_user}}/cobald-src"
version: bugfix/mixed_construction_methods
update: no # FIXME
become: yes
become_user: "{{unpriv_user}}"
register: cobald_git_pull
- name: clone tardis code from git
git:
repo: https://github.com/MatterMiners/tardis
dest: "~{{unpriv_user}}/tardis-src"
version: master
update: no # FIXME
become: yes
become_user: "{{unpriv_user}}"
register: tardis_git_pull
- name: "get unpriv_user {{unpriv_user}} uid and gid"
getent:
database: passwd
key: "{{unpriv_user}}"
- name: run pip install on cobald and tardis
docker_container:
image: "cobald:{{cobald_image_tag|default('latest')}}"
name: "cobald-src-{{item.name}}-install"
volumes:
- "~{{unpriv_user}}/{{item.name}}-src:/usr/local/src/{{item.name}}:rw"
state: started
detach: False
cleanup: True
user: "{{getent_passwd[unpriv_user][1]}}:{{getent_passwd[unpriv_user][2]}}"
entrypoint: ""
command: |
bash -c 'HOME=/tmp pip3 install --editable /usr/local/src/{{item.name}}'
with_items:
- name: cobald
run: "{{cobald_git_pull.changed}}"
- name: tardis
run: "{{tardis_git_pull.changed}}"
when: item.run
- import_tasks: telegraf.yml
- name: get cobald hostname
include_tasks: facts.yml
when: cobald_container_hostname is not defined
- name: build singularity container
include_tasks:
file: singularity.yml
apply:
tags: singularity
tags: singularity
- name: run cobald container
docker_container:
name: "{{ container_name | default('cobald') }}"
image: "cobald:{{cobald_image_tag|default('latest')}}"
hostname: "{{cobald_container_hostname}}"
domainname: "{{ cobald_domainname | default('cobald.local')}}"
volumes: "{{default_mounts + cobald_mounts }}"
networks:
- name: "{{cobald_docker_network}}"
networks_cli_compatible: True
state: started
detach: True
cleanup: True
interactive: True
# command: python3 -m cobald.daemon /etc/cobald/config.yaml
vars:
default_mounts: "{{cobald_slurm_mounts | default([])}}"
cobald_mounts:
- "~{{unpriv_user}}/cobald:/etc/cobald"
# - /container/volumes/cobald:/etc/cobald:ro
- "/container/docker-images/sing-slurmd/build/:/slurm-singimage/:ro"
- "~{{unpriv_user}}/cobald/modules:/usr/local/src/cobaldmodules"
- "~{{unpriv_user}}/cobald-src:/usr/local/src/cobald:ro"
- "~{{unpriv_user}}/tardis-src:/usr/local/src/tardis:ro"