54 lines
1.3 KiB
YAML
54 lines
1.3 KiB
YAML
---
|
|
- hosts: localhost
|
|
|
|
vars:
|
|
my_image_mariadb: 'mariadb:10.3'
|
|
my_image_wordpress: 'wordpress'
|
|
|
|
tasks:
|
|
- name: Download Docker image
|
|
docker_image:
|
|
name: '{{ item }}'
|
|
state: present
|
|
tag: latest
|
|
source: pull
|
|
with_items:
|
|
- '{{ my_image_mariadb }}'
|
|
- '{{ my_image_wordpress }}'
|
|
|
|
- name: Create persistant volume (Ansible 2.4)
|
|
docker_volume:
|
|
name: db_data
|
|
state: present
|
|
|
|
- name: Create DB container (Ansible 2.1)
|
|
docker_container:
|
|
name: db
|
|
image: '{{ my_image_mariadb }}'
|
|
volumes:
|
|
- db_data:/var/lib/mysql
|
|
restart_policy: always
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: mysql
|
|
MYSQL_DATABASE: wordpress
|
|
MYSQL_USER: wordpress
|
|
MYSQL_PASSWORD: "{{ lookup('password', './wordpress.pw') }}"
|
|
|
|
- name: Create WP container (Ansible 2.1)
|
|
docker_container:
|
|
name: wordpress
|
|
image: '{{ my_image_wordpress }}'
|
|
restart_policy: always
|
|
exposed_ports:
|
|
- 80
|
|
published_ports:
|
|
- 8888:80
|
|
links:
|
|
- db:db
|
|
env:
|
|
WORDPRESS_DB_HOST: db:3306
|
|
WORDPRESS_DB_USER: wordpress
|
|
WORDPRESS_DB_PASSWORD: "{{ lookup('password', './wordpress.pw') }}"
|
|
|
|
|