Commit 471fd2d79642c1eb6f59441ed15db5d47fe32491

Authored by Ricardo Gon├žalves
1 parent eda6992709
Exists in master

changes

playbook.yml
... ... @@ -2,7 +2,23 @@
2 2 - hosts: proxyserver
3 3 become: true
4 4 roles:
5   - - docker
  5 + - docker-git-pip
6 6 - proxyserver
7 7 vars_files:
  8 + - vars/vars.yaml
  9 +
  10 +- hosts: webservers
  11 + become: true
  12 + roles:
  13 + - docker-git-pip
  14 + - webservers
  15 + vars_files:
  16 + - vars/vars.yaml
  17 +
  18 +- hosts: dbservers
  19 + become: true
  20 + roles:
  21 + - docker-git-pip
  22 + - dbserver
  23 + vars_files:
8 24 - vars/vars.yaml
9 25 \ No newline at end of file
... ...
roles/dbserver/tasks/main.yml
1   -- name: Installing Git
2   - apt:
3   - update_cache: yes
4   - name: git
5   - state: present
6   -
7 1 - name: Get Dockerfiles from Git to {{db_dir}}
8 2 git:
9 3 repo: https://gitlab.fccn.pt/naux/dbserver.git
10 4 dest: "{{db_dir}}/"
11 5 clone: yes
12 6 force: yes
13   - when:
14   - - var
15   -
16   -- name: Installing docker dependencies
17   - pip:
18   - name: "{{item}}"
19   - state: present
20   - with_items:
21   - - docker-compose
22   - when:
23   - - var
24 7  
25 8 - name: Building docker-compose file to {{db_dir}}
26 9 win_template:
27 10 src: docker-compose.yml
28 11 dest: "{{db_dir}}/"
29   - when:
30   - - var
31 12  
32   -# - name: Running containers with docker-compose
33   -# docker_service:
34   -# project_src: "{{db_dir}}"
35   -# build: yes
36   -# nocache: yes
37   -# state: "{{'present' if var else 'absent'}}"
38   - # when:
39   - # - var
40 13 \ No newline at end of file
  14 +- name: Running containers with docker-compose
  15 + docker_service:
  16 + project_src: "{{db_dir}}"
  17 + build: yes
  18 + nocache: yes
  19 + state: "{{'present' if var else 'absent'}}"
41 20 \ No newline at end of file
... ...
roles/docker/tasks/main.yml
... ... @@ -1,12 +0,0 @@
1   - - name: Add Docker GPG key
2   - apt_key: url=https://download.docker.com/linux/ubuntu/gpg
3   -
4   - - name: Add Docker APT repository
5   - apt_repository:
6   - repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu {{ansible_distribution_release}} stable
7   -
8   - - name: Install list of packages
9   - apt:
10   - name: ['apt-transport-https','ca-certificates','curl','software-properties-common','docker-ce']
11   - state: present
12   - update_cache: yes
roles/proxyserver/tasks/main.yml
1   -- name: Installing Git and pip
2   - apt:
3   - update_cache: yes
4   - name: ['git', 'pip']
5   - state: present
6   -
7 1 - name: Get Dockerfiles from Git to {{proxy_dir}}
8 2 git:
9 3 repo: https://gitlab.fccn.pt/naux/proxyserver.git
... ... @@ -11,13 +5,6 @@
11 5 clone: yes
12 6 force: yes
13 7  
14   -- name: Installing docker dependencies
15   - pip:
16   - name: "{{item}}"
17   - state: present
18   - with_items:
19   - - docker-compose
20   -
21 8 - name: Building haproxy config to {{proxy_dir}}
22 9 win_template:
23 10 src: haproxy.cfg
... ... @@ -29,7 +16,6 @@
29 16 src: docker-compose.yml
30 17 dest: "{{proxy_dir}}/"
31 18  
32   -
33 19 - name: Running containers with docker-compose
34 20 docker_service:
35 21 project_src: "{{proxy_dir}}"
... ...
roles/webserver/tasks/main.yml
1   -- name: Installing Git
2   - apt:
3   - update_cache: yes
4   - name: git
5   - state: present
6   -
7 1 - name: Get Dockerfiles from Git to {{webs_dir}}
8 2 git:
9 3 repo: https://gitlab.fccn.pt/naux/webserver.git
10 4 dest: "{{webs_dir}}/"
11 5 clone: yes
12 6 force: yes
13   - when:
14   - - var
15   -
16   -- name: Installing docker dependencies
17   - pip:
18   - name: "{{item}}"
19   - state: present
20   - with_items:
21   - - docker-compose
22   - when:
23   - - var
24 7  
25 8 - name: Building nginx config to {{webs_dir}}nginx_cont/
26 9 win_template:
27 10 src: nginx.conf
28 11 dest: "{{webs_dir}}nginx_cont/"
29   - when:
30   - - var
31 12  
32 13 - name: Building app settings to {{webs_dir}}appdjango_cont/
33 14 win_template:
34 15 src: settings.py
35 16 dest: "{{webs_dir}}appdjango_cont/"
36   - when:
37   - - var
38 17  
39 18 - name: Building docker-compose file to {{webs_dir}}/
40 19 win_template:
41 20 src: docker-compose.yml
42 21 dest: "{{webs_dir}}/"
43   - when:
44   - - var
45 22  
46   -# - name: Running containers with docker-compose
47   -# docker_service:
48   -# project_src: "{{webs_dir}}"
49   -# build: yes
50   -# nocache: yes
51   -# state: "{{'present' if var else 'absent'}}"
52   - # when:
53   - # - var
54 23 \ No newline at end of file
  24 +- name: Running containers with docker-compose
  25 + docker_service:
  26 + project_src: "{{webs_dir}}"
  27 + build: yes
  28 + nocache: yes
  29 + state: "{{'present' if var else 'absent'}}"
55 30 \ No newline at end of file
... ...
roles/webserver/templates/docker-compose.yml
... ... @@ -7,8 +7,8 @@ services:
7 7 #image: app
8 8 ports:
9 9 - "{{app_port}}:8000"
10   - depends_on:
11   - - db
  10 + # depends_on:
  11 + # - db
12 12  
13 13 nginx:
14 14 build:
... ...