kibatic.docker-systemd
kibatic.docker-systemd
This tool lets you create unit files in YAML format (like Docker Compose) and use them to set up systemd units on remote machines. It’s a simple, lightweight, but powerful way to manage containers.
Requirements
- Docker must be installed on the host machine.
Installation
To install the role, run:
$ ansible-galaxy install kibatic.docker-systemd
Role Variables
Here are some default settings you can adjust:
# Default Docker volumes that will be attached to each container
# /etc/localtime is needed to share the host's time zone with the containers
default_volumes:
- /etc/localtime:/etc/localtime:ro
# Directory for storing all container-related data (volumes, config files, etc.)
container_data_home: '/home/cloud/containers'
# Default options for the Docker run command
default_docker_options: ''
# Default labels for each container
default_docker_labels: []
# Default network name
default_network_name: default_network
# List of units to be removed from the system
removed_units: []
Example Playbook
Here’s an example of how to use this role, including parameters:
- hosts: my.awsome.host.example.com
roles: [ kibatic.docker-systemd ]
vars_files: [ vars/units/my-awsome-service/units.yml ]
tags:
- my-awsome-service
# This ensures that a removed service does not exist on the system
- hosts: my.awsome.host.example.com
roles: [ kibatic.docker-systemd ]
vars:
removed_units:
- my-removed-service
Example Unit
Here is an example of how to define a unit:
systemd_units:
- name: symfony_web
image: my_awsome_symfony_image
restart_unit: true # whether to restart the unit when running the role (can be risky for SQL clusters)
host_copy: []
environment:
SYMFONY__DATABASE__HOST: symfony_db
SYMFONY__DATABASE__USER: root
SYMFONY__DATABASE__PASSWORD: root
SYMFONY__DATABASE__NAME: demo
- name: symfony_db
image: mysql:5.5
host_copy: []
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: demo
License
MIT