ansible creates docker-compose

This commit is contained in:
Adrien Luxey 2020-01-28 01:07:58 +01:00
parent ab4e139adc
commit 804c7ae65d
4 changed files with 87 additions and 0 deletions

View file

@ -0,0 +1 @@
localhost

View file

@ -0,0 +1,41 @@
---
- hosts: localhost
# ask_pass: yes
gather_facts: no
vars:
# short site name to use as dir/file name
site_name: lexperimental
site_url: lexperimental.fr
docker_image: wordpress:apache
docker_volumes:
- "/var/www/arvuhez/wp-content/:/var/www/html/wp-content"
mysql_database: lexperimental
mysql_username: lexperimental
mysql_password: "azlhqsdh"
subnet_cidr_address: 172.100.0.0/24
subnet_gateway_ip: 172.100.0.1
subnet_site_ip: 172.100.0.2
tasks:
- name: "Create target directory {{ site_name }}"
file:
name: "{{ site_name }}"
state: directory
- name: Generate a docker-compose.yml file for our site
template:
src: templates/docker-compose.yml.j2
dest: "{{ site_name }}/docker-compose.yml"
# - debug: "Do the MySQL users thingy"
#- name: Generate a new nginx server config file
#- template:
#- src: templates/site.conf.j2
#- dest: "/etc/nginx/sites-available/{{ site_url }}"
# become: yes
# - debug: "Now do `ln -s /etc/nginx/sites-available/{{ site_url }} /etc/nginx/sites-enabled/"

View file

@ -0,0 +1,23 @@
version: '3'
services:
wp:
image: wordpress:apache
restart: always
environment:
WORDPRESS_DB_HOST: "172.100.0.1"
WORDPRESS_DB_USER: "lexperimental"
WORDPRESS_DB_PASSWORD: "azlhqsdh"
WORDPRESS_DB_NAME: "lexperimental"
volumes: ['/var/www/arvuhez/wp-content/:/var/www/html/wp-content']
networks:
net:
ipv4_address: "172.100.0.2"
networks:
net:
ipam:
driver: default
config:
- subnet: "172.100.0.0/24"

View file

@ -0,0 +1,22 @@
version: '3'
services:
wp:
image: {{ docker_image }}
restart: always
environment:
WORDPRESS_DB_HOST: "{{ subnet_gateway_ip }}"
WORDPRESS_DB_USER: "{{ mysql_username }}"
WORDPRESS_DB_PASSWORD: "{{ mysql_password }}"
WORDPRESS_DB_NAME: "{{ mysql_database }}"
volumes: {{ docker_volumes | to_yaml }}
networks:
net:
ipv4_address: "{{ subnet_site_ip }}"
networks:
net:
ipam:
driver: default
config:
- subnet: "{{ subnet_cidr_address }}"