2018-11-15 18:43:36 +00:00
|
|
|
- name: deploy znc server
|
2018-11-15 03:28:10 +00:00
|
|
|
hosts: dockerhosts
|
|
|
|
remote_user: josiah
|
|
|
|
tasks:
|
|
|
|
- name: update or create the directory
|
2018-11-15 18:42:11 +00:00
|
|
|
shell: cd /home/josiah/znc-docker/ && git pull
|
2018-11-15 03:28:10 +00:00
|
|
|
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
|
2018-11-15 18:45:15 +00:00
|
|
|
shell: cd ~/znc-docker/full && docker build -t znc -f Dockerfile .
|
2018-11-15 19:20:24 +00:00
|
|
|
- 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
|
2018-11-15 03:28:10 +00:00
|
|
|
shell: docker ps | grep 'znc' | awk '{print $1}' | xargs docker kill
|
2018-11-15 19:20:24 +00:00
|
|
|
when: result.stdout != ""
|
|
|
|
- name: discover if any containers with ZNC in name
|
2018-11-15 03:28:10 +00:00
|
|
|
# this has to be a shell because command: isn't interactive
|
2018-11-15 19:20:24 +00:00
|
|
|
shell: docker container ls | grep 'znc'
|
|
|
|
register: result
|
2018-11-15 19:22:42 +00:00
|
|
|
ignore_errors: True
|
2018-11-15 19:20:24 +00:00
|
|
|
- name: remove any existing containers with ZNC in name
|
2018-11-15 03:28:10 +00:00
|
|
|
shell: docker container rm znc
|
2018-11-15 19:22:42 +00:00
|
|
|
when: result is succeeded
|
2018-11-15 03:28:10 +00:00
|
|
|
- name: run the container (assumes the volume is already set up)
|
2018-11-15 20:00:53 +00:00
|
|
|
command: docker run -d -p 5000:5000 --mount type="bind",source="/mnt/volume_sfo2_znc/",target=/znc-data znc
|
2018-11-15 03:28:10 +00:00
|
|
|
|