wpt-sync/ansible/wptsync_deploy.yml

44 строки
1.4 KiB
YAML

---
# assuming _repo_root, _tempdir, _image_name variables are defined in call to ansible-playbook
- name: reset local workspace
hosts: localhost
gather_facts: no
tasks:
- name: remove workspace
file:
path: "{{ _tempdir | mandatory }}"
state: absent
- name: create workspace
file:
path: "{{ _tempdir | mandatory }}"
state: directory
- name: prepare docker image for upload
hosts: localhost
gather_facts: no
tasks:
- name: docker build
command: "docker build -t {{ _image_name }} --file docker/Dockerfile.dev --build-arg PYTHON_BINARY={{ _python_binary | mandatory }} --build-arg PIP_BINARY={{ _pip_binary | mandatory }} ."
args:
chdir: "{{ _repo_root | mandatory }}"
- name: docker save and compress
shell: "docker save {{ _image_name }} | bzip2 > {{ _tempdir }}/{{ _image_name }}.tar.bz2"
- name: check for image archive
file:
path: "{{ _tempdir }}/{{ _image_name }}.tar.bz2"
state: file
- name: provision server
hosts: wptsync
pre_tasks:
- name: stop all docker containers
shell: if [ -f /usr/bin/docker ] && [ $(docker ps -aq) ]; then /usr/bin/docker stop -t 30 $(docker ps -aq); fi
become_user: wpt_user
roles:
- { role: geerlingguy.docker,
docker_edition: "ce",
docker_package: "docker-{{ docker_edition }}",
docker_package_state: "latest",
docker_install_compose: false }
- wptsync_host