barker/docker/playbook-frank.yml

69 lines
1.8 KiB
YAML
Raw Normal View History

#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/frank.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/home/pi/dockerfile
- name: Build frank image
docker_image:
name: frank:latest
build:
path: /home/pi/dockerfile/app
dockerfile: /home/pi/dockerfile/app/frank.Dockerfile
pull: yes
state: present
source: build
- name: Check if frank .env file exists
stat: path="/home/pi/frank.env"
register: status
- name: No need to upload the frank .env file
debug: msg= {{ "No need to upload the frank .env file as it already exists." }}
- name: Upload the frank .env file
when: status.stat.exists == false
template:
src: "files/frank.env"
dest: "/home/pi/frank.env"
- name: Create frank worker container
docker_container:
name: "frank"
image: frank:latest
state: started
restart_policy: "no"
env_file: "/home/pi/frank.env"
network_mode: "host"
devices:
- "{{ printer_port }}:/printer"
- name: Copy docker build script
synchronize: src=files/build-frank.sh dest=/home/pi/dockerfile/build-frank.sh
- name: Copy docker run script
synchronize: src=files/frank.sh dest=/home/pi/dockerfile/frank.sh
- name: install frank systemd unit file
template:
src: "files/frank.service"
dest: "/etc/systemd/system/frank.service"
- name: enable service frank and ensure it is not masked
systemd:
name: frank
enabled: yes
masked: no
- name: Make sure frank service is running
systemd:
state: started
name: frank