Created
September 20, 2020 09:33
-
-
Save Inderpreet90/f17fc8e8a99333f7503669f273745eed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: dev-server | |
gather_facts: no | |
remote_user: ubuntu | |
become: yes | |
tasks: | |
- name: Install docker and some dependencies | |
apt: | |
name: python3-pip, docker.io | |
state: present | |
- name: Start docker service | |
service: | |
name: docker | |
state: started | |
- name: Install docker python module | |
pip: | |
name: docker | |
- name: Build an image and push | |
docker_image: | |
build: | |
path: ./nginx | |
name: inderpreetaps/nginx | |
tag: v1 | |
force_source: yes | |
push: yes | |
source: build | |
delegate_to: 127.0.0.1 | |
become: no | |
- name: Create Drupal container | |
docker_container: | |
name: drupal | |
image: drupal | |
state: started | |
recreate: yes | |
exposed_ports: | |
- "{{ drupal_port }}" | |
volumes: | |
- drupal_modules:/var/www/html/modules | |
- drupal_profiles:/var/www/html/profiles | |
- drupal_themes:/var/www/html/themes | |
- drupal_sites:/var/www/html/sites | |
- name: Create Mysql container | |
docker_container: | |
name: mysql | |
image: mysql | |
state: started | |
recreate: yes | |
env: | |
MYSQL_ROOT_PASSWORD: "{{ mysql_root_pass }}" | |
exposed_ports: | |
- "{{ mysql_port }}" | |
volumes: | |
- db_data:/var/lib/mysql/data | |
- name: Create nginx container | |
docker_container: | |
name: nginx | |
image: inderpreetaps/nginx:v1 | |
state: started | |
recreate: yes | |
links: | |
- "drupal:drupal" | |
published_ports: | |
- "{{ nginx_port }}:{{ nginx_port }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment