initial commit

This commit is contained in:
Egon Rijpkema 2017-04-18 13:17:32 +02:00
commit e0a7bdb45d
2 changed files with 39 additions and 0 deletions

16
files/mysql.service Normal file
View File

@ -0,0 +1,16 @@
[Unit]
Description=Mariadb Container
After=docker.service
Requires=docker.service
[Service]
TimeoutStartSec=0
Restart=always
ExecStartPre=-/usr/bin/docker stop %n
ExecStartPre=-/usr/bin/docker rm %n
ExecStartPre=/usr/bin/docker pull mariadb:10.1.22
ExecStart=/usr/bin/docker run -p 3306:3306 --name %n -v /srv/lib/mysql:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=geheim mariadb:10.1.22
[Install]
WantedBy=multi-user.target

23
mariadb.yml Normal file
View File

@ -0,0 +1,23 @@
# Install a docker based mariadb.
---
- name: Install a mariadb server with databases in a persistent volume
hosts: all # Should be specified of course
become: True
tasks:
- name: install docker packages
apt: pkg={{ item }} state=latest update_cache=yes
with_items:
- docker-engine
- name: install service file.
template:
src: files/mysql.service
dest: /etc/systemd/system/mysql.service
mode: 644
owner: root
group: root
- name: install service file
command: systemctl daemon-reload
- name: make sure service is started
systemd:
name: mariadb.service
state: started