Added the inventory information for ansible in the project and made it so that the file is only run once.

Updated python dependencies
This commit is contained in:
2022-06-07 18:30:39 +05:30
parent 98d3e212c3
commit 92023caadc
13 changed files with 31 additions and 399 deletions

14
docker/hosts Normal file
View File

@ -0,0 +1,14 @@
# - Comments begin with the '#' character
# - Blank lines are ignored
# - Groups of hosts are delimited by [header] elements
# - You can enter hostnames or ip addresses
# - A hostname/ip can be a member of multiple groups
[brewman]
acc ansible_host=vancity var_file=vars/acc.yml
exp ansible_host=vancity var_file=vars/exp.yml
hops ansible_host=vancity var_file=vars/hops.yml
mhl ansible_host=vancity var_file=vars/mhl.yml
[all:vars]
ansible_python_interpreter=/usr/bin/python3

View File

@ -1,68 +0,0 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/acc.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
- name: Build brewman image
docker_image:
name: brewman:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/Dockerfile
pull: yes
state: present
source: build
- name: Upload the .env file
template:
src: "files/.env-acc"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: brewman:latest
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Check if Nginx conf file exists
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
handlers:
- name: Reload Nginx
service:
name: nginx
state: reloaded

View File

@ -2,10 +2,10 @@
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
- hosts: brewman
become: true
vars_files:
- vars/exp.yml
- "{{ var_file }}"
tasks:
- name: Copy dockerfile
@ -23,7 +23,7 @@
- name: Upload the .env file
template:
src: "files/.env-exp"
src: "{{ env_file }}"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container

View File

@ -1,68 +0,0 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/hops.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
- name: Build brewman image
docker_image:
name: brewman:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/Dockerfile
pull: yes
state: present
source: build
- name: Upload the .env file
template:
src: "files/.env-hops"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: brewman:latest
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Check if Nginx conf file exists
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
handlers:
- name: Reload Nginx
service:
name: nginx
state: reloaded

View File

@ -1,68 +0,0 @@
#################################################
# DO Community Playbooks: Docker
#################################################
---
- hosts: all
become: true
vars_files:
- vars/mhl.yml
tasks:
- name: Copy dockerfile
synchronize: src=app dest=/tmp
- name: Build brewman image
docker_image:
name: brewman:latest
build:
path: /tmp/app/
dockerfile: /tmp/app/Dockerfile
pull: yes
state: present
source: build
- name: Upload the .env file
template:
src: "files/.env-mhl"
dest: "/var/lib/{{ host_directory }}/.env"
- name: Create brewman container
docker_container:
name: "{{ host_directory }}"
image: brewman:latest
state: started
restart_policy: "unless-stopped"
env_file: "/var/lib/{{ host_directory }}/.env"
published_ports:
- "127.0.0.1:{{ host_port }}:80"
volumes:
- "/var/lib/{{ host_directory }}/frontend:/frontend"
- name: Check if Nginx conf file exists
stat: path="/etc/nginx/sites-available/{{ http_conf }}"
register: status
- name: No need to reload Nginx
debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }}
- name: Set Nginx conf file
when: status.stat.exists == false
template:
src: "files/nginx.conf.j2"
dest: "/etc/nginx/sites-available/{{ http_conf }}"
- name: Enable new site
when: status.stat.exists == false
file:
src: "/etc/nginx/sites-available/{{ http_conf }}"
dest: "/etc/nginx/sites-enabled/{{ http_conf }}"
state: link
notify: Reload Nginx
handlers:
- name: Reload Nginx
service:
name: nginx
state: reloaded

View File

@ -3,3 +3,4 @@ http_host: "acc.hopsngrains.com"
http_conf: "acc.hopsngrains.com.conf"
host_port: "8659"
host_directory: "brewman-acc"
env_file: "files/.env-acc"

View File

@ -3,3 +3,4 @@ http_host: "exp.tanshu.com"
http_conf: "exp.tanshu.com.conf"
host_port: "8656"
host_directory: "brewman-exp"
env_file: "files/.env-exp"

View File

@ -3,3 +3,4 @@ http_host: "hops.hopsngrains.com"
http_conf: "hops.hopsngrains.com.conf"
host_port: "8658"
host_directory: "brewman-hops"
env_file: "files/.env-hops"

View File

@ -3,3 +3,4 @@ http_host: "mhl.hopsngrains.com"
http_conf: "mhl.hopsngrains.com.conf"
host_port: "8657"
host_directory: "brewman-mhl"
env_file: "files/.env-mhl"