cron ping 12h
This commit is contained in:
77
dockerapps.yml
Normal file
77
dockerapps.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
- name: Docker and Docker-Compose playbook
|
||||
hosts: all
|
||||
become: true
|
||||
|
||||
# #
|
||||
# # @author Stéphane Gratias (2021).
|
||||
#
|
||||
|
||||
roles:
|
||||
# manage docker-compose@dev systemd unit file
|
||||
- { role: tumf.systemd-service, tags: docker-compose,
|
||||
when: ansible_service_mgr == 'systemd',
|
||||
vars: {
|
||||
# do not restart service via systemd
|
||||
ansible_unit_test: true,
|
||||
systemd_service_name: "docker-compose@lab",
|
||||
# [Unit]
|
||||
systemd_service_Unit_Description: "%i service with docker compose",
|
||||
systemd_service_Service_Type: "simple",
|
||||
systemd_service_Unit_After: [ "docker.service" ],
|
||||
systemd_service_Unit_Requires: [ "docker.service" ],
|
||||
# [Service]
|
||||
systemd_service_Service_WorkingDirectory: "{{ dockerapp_tree_base_dir | last }}/{{ dockerapp_service }}",
|
||||
# Remove old containers, images and volumes
|
||||
systemd_service_Service_ExecStartPre: [
|
||||
"{{ '/usr/local/bin' if docker_install_compose else '/usr/bin' }}/docker-compose down -v",
|
||||
"{{ '/usr/local/bin' if docker_install_compose else '/usr/bin' }}/docker-compose rm -fv",
|
||||
],
|
||||
# Compose up
|
||||
systemd_service_Service_ExecStart: "{{ '/usr/local/bin' if docker_install_compose else '/usr/bin' }}/docker-compose up",
|
||||
# Compose down, remove containers and volumes
|
||||
systemd_service_Service_ExecStop: "{{ '/usr/local/bin' if docker_install_compose else '/usr/bin' }}/docker-compose down -v",
|
||||
systemd_service_Service_Restart: "always",
|
||||
# [Install]
|
||||
systemd_service_Install_WantedBy: "multi-user.target"
|
||||
}
|
||||
}
|
||||
|
||||
tasks:
|
||||
- name: create docker app base dir
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
owner: root
|
||||
group: root
|
||||
with_items:
|
||||
- "{{ dockerapp_tree_base_dir | last }}"
|
||||
- "{{ dockerapp_tree_base_dir | last }}/{{ dockerapp_service }}"
|
||||
- "{{ dockerapp_tree_base_dir | last }}/{{ dockerapp_service }}/logs"
|
||||
tags:
|
||||
- docker-compose
|
||||
- bootstrap_dockerapp_create_base_dir
|
||||
|
||||
- name: create docker volumes tree for containers
|
||||
file:
|
||||
path: "{{ dockerapp_tree_base_dir | last }}/{{ dockerapp_service }}/{{ item | default('') }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
with_items: "{{ dockerapp_tree_volumes | default([]) }}"
|
||||
tags:
|
||||
- docker-compose
|
||||
- bootstrap_dockerapp_create_app_dir
|
||||
|
||||
- name: create the main docker-compose file (docker-compose.yml)
|
||||
template:
|
||||
src: "../templates/docker-compose.yml.j2"
|
||||
dest: "{{ dockerapp_tree_base_dir | last }}/{{ dockerapp_service }}/docker-compose.yml"
|
||||
mode: 0600
|
||||
tags:
|
||||
- docker-compose
|
||||
- bootstrap_dockerapp_configure_docker_compose
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user