Skip to content

Instantly share code, notes, and snippets.

@Inderpreet90
Created September 20, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Inderpreet90/f17fc8e8a99333f7503669f273745eed to your computer and use it in GitHub Desktop.
Save Inderpreet90/f17fc8e8a99333f7503669f273745eed to your computer and use it in GitHub Desktop.
---
- 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