WIP: cobald container containing and using slurm
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -f /usr/local/lib/cobaldmodules/setup.py -a \
|
||||
-d /usr/local/lib/cobaldmodules/cobaldmodules ] && \
|
||||
pip3 install --no-deps --editable /usr/local/lib/cobaldmodules
|
||||
for i in /usr/local/lib/entrypoints.d/* ; do
|
||||
[ -f $i ] && /bin/sh $i || break
|
||||
done
|
||||
|
||||
exec "${@:-/bin/bash}"
|
||||
|
5
roles/cobald/files/init-cobaldmodules.sh
Normal file
5
roles/cobald/files/init-cobaldmodules.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ -f /usr/local/lib/cobaldmodules/setup.py -a \
|
||||
-d /usr/local/lib/cobaldmodules/cobaldmodules ] && \
|
||||
pip3 install --no-deps --editable /usr/local/lib/cobaldmodules
|
@@ -1,33 +1,41 @@
|
||||
- include_vars: cobald-slurm.yml
|
||||
when: cobald_slurm | default(False)
|
||||
|
||||
- file:
|
||||
path: "/container/{{item}}/cobald/"
|
||||
path: "/container/{{item.name}}/cobald{{item.pfx|default('')}}/"
|
||||
state: directory
|
||||
owner: "{{unpriv_user}}"
|
||||
group: docker
|
||||
loop:
|
||||
- docker-images
|
||||
- volumes
|
||||
- name: docker-images
|
||||
pfx: ".{{cobald_image_tag|default('latest')}}"
|
||||
- name: volumes
|
||||
|
||||
- copy:
|
||||
- template:
|
||||
src: cobald.Dockerfile
|
||||
dest: /container/docker-images/cobald/Dockerfile
|
||||
dest: "/container/docker-images/cobald.{{cobald_image_tag|default('latest')}}/Dockerfile"
|
||||
owner: "{{unpriv_user}}"
|
||||
group: docker
|
||||
register: cobald_cp_dockerfile
|
||||
|
||||
- copy:
|
||||
src: cobald-entrypoint.sh
|
||||
dest: /container/docker-images/cobald/cobald-entrypoint.sh
|
||||
src: "{{item}}"
|
||||
dest: "/container/docker-images/cobald.{{cobald_image_tag|default('latest')}}/{{item}}"
|
||||
owner: "{{unpriv_user}}"
|
||||
group: docker
|
||||
mode: 0755
|
||||
with_items:
|
||||
- cobald-entrypoint.sh
|
||||
- init-cobaldmodules.sh
|
||||
register: cobald_cp_files
|
||||
|
||||
- docker_image:
|
||||
name: "cobald"
|
||||
tag: "{{cobald_image_tag|default('latest')}}"
|
||||
# pull: False
|
||||
build:
|
||||
pull: False
|
||||
path: "/container/docker-images/cobald/"
|
||||
path: "/container/docker-images/cobald.{{cobald_image_tag|default('latest')}}/"
|
||||
source: build
|
||||
force_source: "{{cobald_cp_dockerfile.changed or cobald_cp_files.changed}}"
|
||||
|
||||
@@ -39,7 +47,7 @@
|
||||
when: False
|
||||
|
||||
- docker_network:
|
||||
name: "{{docker_network}}"
|
||||
name: "{{cobald_docker_network}}" # FIXME
|
||||
state: present
|
||||
|
||||
# docker run -v $(pwd)/cobald-config-host:/etc/cobald -v $(pwd)/cobald:/cobald --rm -it cobald bash
|
||||
@@ -82,7 +90,7 @@
|
||||
|
||||
- name: run pip install
|
||||
docker_container:
|
||||
image: cobald
|
||||
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"
|
||||
@@ -102,29 +110,34 @@
|
||||
|
||||
- import_tasks: telegraf.yml
|
||||
|
||||
- docker_container_info:
|
||||
name: cobald
|
||||
register: cobald_container_info
|
||||
- name: get cobald hostname
|
||||
include_role:
|
||||
name: cobald_facts
|
||||
when: cobald_container_hostname is not defined
|
||||
|
||||
- docker_container:
|
||||
name: cobald
|
||||
image: cobald
|
||||
hostname: |-
|
||||
{{cobald_container_info.container.Config.Hostname | default('cobald-'+
|
||||
lookup('password', '/dev/null chars=ascii_lowercase length=6')) }}
|
||||
domainname: cobald.local
|
||||
volumes:
|
||||
- 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
|
||||
# env:
|
||||
# slurmuser: "{{slurm_user}}"
|
||||
# privileged: "{{ container_privileged | bool }}"
|
||||
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
|
||||
- "~{{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"
|
||||
networks:
|
||||
- name: "{{docker_network}}"
|
||||
state: started
|
||||
detach: True
|
||||
cleanup: True
|
||||
interactive: True
|
||||
# command: /bin/bash
|
||||
# python3 -m cobald.daemon /etc/cobald/config.yaml
|
||||
command: python3 -m cobald.daemon /etc/cobald/config.yaml
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM docker.io/library/centos:7
|
||||
FROM {{ cobald_docker_base_image | default("docker.io/library/centos:7") }}
|
||||
|
||||
RUN yum update -y && \
|
||||
yum install -y python3 git && pip3 install --upgrade pip && \
|
||||
@@ -41,11 +41,20 @@ VOLUME /usr/local/src/cobaldmodules
|
||||
|
||||
VOLUME /etc/cobald
|
||||
|
||||
COPY cobald-entrypoint.sh /usr/local/sbin/docker-entrypoint.sh
|
||||
RUN mkdir -p /usr/local/lib/entrypoints.d/
|
||||
|
||||
RUN chmod 755 /usr/local/sbin/docker-entrypoint.sh
|
||||
COPY init-cobaldmodules.sh /usr/local/lib/entrypoints.d/50-init-cobaldmodules.sh
|
||||
|
||||
ENTRYPOINT [ "/usr/local/sbin/docker-entrypoint.sh" ]
|
||||
RUN chmod 755 /usr/local/lib/entrypoints.d/50-init-cobaldmodules.sh
|
||||
|
||||
RUN echo -e "#!/bin/sh\npython3 -m cobald.daemon /etc/cobald/config.yaml" >> /etc/docker-init.d/70-cobald && chmod 755 /etc/docker-init.d/70-cobald
|
||||
|
||||
{% if cobald_docker_default_command | default(True) -%}
|
||||
COPY cobald-entrypoint.sh /usr/local/sbin/cobald-entrypoint.sh
|
||||
|
||||
RUN chmod 755 /usr/local/sbin/cobald-entrypoint.sh
|
||||
|
||||
ENTRYPOINT [ "/usr/local/sbin/cobald-entrypoint.sh" ]
|
||||
|
||||
RUN yum -y install iproute &&\
|
||||
yum clean all && rm -rf /var/cache/yum
|
||||
@@ -54,4 +63,6 @@ USER cobald
|
||||
|
||||
STOPSIGNAL SIGINT
|
||||
|
||||
CMD "python3 -m cobald.daemon /etc/cobald/config.yaml"
|
||||
# CMD "python3 -m cobald.daemon /etc/cobald/config.yaml"
|
||||
CMD /etc/docker-init.d/60-cobald
|
||||
{%- endif %}
|
12
roles/cobald/vars/cobald-slurm.yml
Normal file
12
roles/cobald/vars/cobald-slurm.yml
Normal file
@@ -0,0 +1,12 @@
|
||||
cobald_image_tag: slurm
|
||||
cobald_docker_base_image: "{{slurm.base_image}}"
|
||||
cobald_docker_default_command: False
|
||||
cobald_docker_network: "{{slurm.network}}"
|
||||
cobald_domainname: "{{slurm.domain}}"
|
||||
cobald_slurm_mounts: "{{slurm.mounts}}"
|
||||
#- /container/volumes/slurm/:/etc/slurm/:rw
|
||||
##- "{{slurm_cfg_path | mandatory}}:/etc/slurm/:rw"
|
||||
#- /container/volumes/munge/munge.key:/etc/munge/munge.key:rw
|
||||
## - "{{slurm_munge_path | mandatory}}:/etc/munge/munge.key:rw"
|
||||
#- slurm-shared:/shared/:rw
|
||||
## - "{{slurm_shared_path | mandatory}}:{{slurm_shared_target | default('/shared')}}:rw"
|
1
roles/cobald/vars/main.yml
Normal file
1
roles/cobald/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
||||
cobald_docker_network: "{{docker_network}}"
|
Reference in New Issue
Block a user