Files
SlurmTests/roles/docker-htcondor/tasks/main.yml
2021-04-22 21:48:32 +02:00

143 lines
3.7 KiB
YAML

- name: "htcondor docker image"
file:
path: "/container/docker-images/htcondor"
state: directory
owner: thoto
group: docker
mode: "u=rwx,g=rwx,o=rx"
- copy:
dest: "/container/docker-images/htcondor/Dockerfile"
src: "htcondor.Dockerfile"
owner: thoto
group: docker
register: cp_dockerfile
- docker_image:
name: "htcondor"
# pull: False
build:
pull: False
path: "/container/docker-images/htcondor"
source: build
force_source: "{{cp_dockerfile.changed}}"
- name: "copy htcondor container configuration"
copy:
src: "conf/{{item}}/"
dest: "/container/volumes/{{item}}/"
owner: thoto
group: docker
mode: "u=rwx,g=rwx"
with_items: [ "cm", "exec", "sub", "common"]
- name: "check if pool shared secret exists"
stat:
path: "/container/volumes/common/passwords.d/POOL"
register: pool_pw
- block:
- name: "create temporary password store"
tempfile:
state: directory
register: pool_pw_tmp
- name: "generate pool password"
copy:
dest: "{{pool_pw_tmp.path}}/poolpw"
content: "{{lookup('password','/dev/null')}}"
no_log: True
- name: "install pool password"
docker_container:
name: "condor-common"
image: htcondor
state: started
volumes:
- "/container/volumes/common/:/etc/condor/:rw"
- "{{pool_pw_tmp.path}}:/tmp/poolpw:ro"
detach: False
cleanup: True
command: "condor_store_cred add -c -i /tmp/poolpw/poolpw"
- name: "remove tokens since pool password (cert) changed"
file:
path: "/container/volumes/{{item}}/tokens.d/condor@htc.local"
state: absent
with_items: [ "cm", "exec", "sub" ]
always:
- name: "remove temporary password store"
file:
path: "{{pool_pw_tmp.path}}"
state: absent
when: pool_pw_tmp is defined and pool_pw_tmp.path
when: not pool_pw.stat.exists
- name: "sync common files to individual containers"
copy:
remote_src: True
force: True
directory_mode: preserve
mode: preserve
src: "/container/volumes/common/"
dest: "/container/volumes/{{item}}/"
with_items: [ "cm", "exec", "sub"]
- name: "collect tokens to generate"
stat:
path: "/container/volumes/{{item}}/tokens.d/condor@htc.local"
with_items: [ "cm", "exec", "sub" ]
register: tokens_state
- name: "generate tokens"
docker_container:
name: "condor-common"
image: htcondor
state: started
volumes:
- "/container/volumes/{{item}}/:/etc/condor/:rw"
detach: False
cleanup: True
command: "condor_token_create -identity condor@$(domainname) -token /etc/condor/tokens.d/condor@htc.local"
with_items: "{{tokens_state.results | rejectattr('stat.exists') | map(attribute='item') | list }}"
- name: "create docker network to make service discovery work"
docker_network:
name: condor
state: present
# TODO: reserve some address using docker_network_info and assign as aux
# address to enable cm to get a static address in order to be reachable from
# htcondor running on docker host to enable submitting jobs.
- name: "run htcondor containers"
docker_container:
name: "condor-{{item}}"
hostname: "condor-{{item}}"
domainname: "htc.local"
image: htcondor
state: started
detach: True
cleanup: True
networks_cli_compatible: True
networks:
- name: "condor"
aliases: [ "condor-{{item}}.htc.local" ]
volumes:
- "/container/volumes/{{item}}/:/etc/condor/:rw"
with_items: [ "cm", "exec", "sub"]
# auto_remove: True
# mounts:
# src: /container/volumes/cm/
# dest: /etc/condor/
#- add_host:
# hostname: foo
# ansible_connection: docker_api
# docker_host: ssh://ed-c7-1.virt.magni.thoto.net