Skip to content

Commit

Permalink
update_structure (#3)
Browse files Browse the repository at this point in the history
* update_structure

* update_structure

* update_structure
  • Loading branch information
Sohan authored and anmolnagpal committed Aug 27, 2019
1 parent 2545c78 commit 01d7920
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</h1>

<p align="center" style="font-size: 1.2rem;">
This ansible role install docker at Debian and Centos.
This ansible role install docker on linux.
</p>

<p align="center">
Expand Down Expand Up @@ -68,6 +68,7 @@ This module has a few dependencies:

Followiing things includes in this role:
- docker
- docker-compose



Expand All @@ -92,6 +93,8 @@ Followiing things includes in this role:

```yaml
docker_users: ['docker']
docker_compose_install: true
docker_compose_version: "1.21.2"
```


Expand Down
5 changes: 4 additions & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ prerequesties:
# What Includes to display
what_includes:
- name: "docker"
- name: "docker-compose"

# description of this project
description: |-
This ansible role install docker at Debian and Centos.
This ansible role install docker on linux.
# How to use this project
usage: |-
Expand All @@ -60,6 +61,8 @@ usage: |-
variables: |-
```yaml
docker_users: ['docker']
docker_compose_install: true
docker_compose_version: "1.21.2"
```
# How to install project
Expand Down
4 changes: 4 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@

# A list of users who will be added to the docker group.
docker_users: ['docker']

# compose
docker_compose_install: true
docker_compose_version: "1.21.2"
18 changes: 18 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,21 @@
name: docker
state: reloaded
enabled: true

- name: restart docker-compose
service:
name: docker-compose
state: restarted
enabled: true

- name: start docker-compose
service:
name: docker-compose
state: started
enabled: true

- name: reload docker-compose
service:
name: docker-compose
state: reloaded
enabled: true
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ galaxy_info:
- server
- ubuntu
- centos
- compose
53 changes: 53 additions & 0 deletions tasks/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---

- name: Check current docker-compose version.
command: docker-compose --version
register: docker_compose_current_version
changed_when: false
failed_when: false

- name: Delete existing docker-compose version if it's different.
file:
path: "/usr/local/bin/docker-compose"
state: absent
when: >
docker_compose_current_version.stdout is defined
and docker_compose_version not in docker_compose_current_version.stdout
- name: ensure dependencies are installed on debian
apt:
pkg: ['python-setuptools',
'python-pip']
state: present
update_cache: true
cache_valid_time: 5400
changed_when: false
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'


- name: ensure dependencies are installed on centos/redhat
yum:
pkg: [
'epel-release',
'python-setuptools'
]
state: present
changed_when: false
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'

- name: ensure pip are installed on centos/redhat
yum:
pkg: python-pip
state: present
changed_when: false
when: ansible_distribution == 'CentOS' or ansible_distribution == 'Red Hat Enterprise Linux'


- name: install docker compose
pip:
name: docker-compose
state: present
version: '{{ docker_compose_version | default(omit) }}'
changed_when: false
notify:
- restart docker-compose
1 change: 1 addition & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---

- name: ensure docker config folder is present
changed_when: false
file:
Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---

- import_tasks: configure.yml
- import_tasks: install.yml
- import_tasks: docker.yml
- import_tasks: compose.yml
when: docker_compose_install

0 comments on commit 01d7920

Please sign in to comment.