adc/ansible/roles/znc/tasks/znc.yml

32 lines
1.3 KiB
YAML
Raw Normal View History

2020-01-05 00:13:19 +00:00
- name: deploy znc server
hosts: dockerhosts
remote_user: josiah
tasks:
- name: update or create the directory
shell: cd /home/josiah/znc-docker/ && git pull
register: result
ignore_errors: True
# if the folder doesn't exist, clone source.
- command: cd /home/josiah && git clone https://github.com/jowj/znc-docker.git
when: result is failed
- name: build from latest version
shell: cd ~/znc-docker/full && docker build -t znc -f Dockerfile .
- name: Check if there are any existing ZNC containers running and kill it
shell: docker ps | grep 'znc' | awk '{print $1}'
register: result
- name: if there are running containers, remove them
shell: docker ps | grep 'znc' | awk '{print $1}' | xargs docker kill
when: result.stdout != ""
- name: discover if any containers with ZNC in name
# this has to be a shell because command: isn't interactive
shell: docker container ls | grep 'znc'
register: result
ignore_errors: True
- name: remove any existing containers with ZNC in name
shell: docker container rm znc
when: result is succeeded
- name: run the container (assumes the volume is already set up)
command: docker run -d -p 5000:5000 --mount type="bind",source="/mnt/volume_sfo2_znc/",target=/znc-data znc