Initial commit
This commit is contained in:
parent
9efd872019
commit
933293e8ef
8 changed files with 99 additions and 3 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# ---> Ansible
|
||||||
|
*.retry
|
||||||
|
|
19
README.md
19
README.md
|
@ -1,3 +1,22 @@
|
||||||
# Ansible-Docker
|
# Ansible-Docker
|
||||||
|
|
||||||
Ansible playbook that provisions a server to run Docker.
|
Ansible playbook that provisions a server to run Docker.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
Execute playbook with needed variables to setup a server to run Docker.
|
||||||
|
|
||||||
|
`ansible-playbook -i hosts site.yml`
|
||||||
|
|
||||||
|
```yml
|
||||||
|
---
|
||||||
|
# file: hosts
|
||||||
|
|
||||||
|
docker:
|
||||||
|
hosts:
|
||||||
|
doc01:
|
||||||
|
ansible_host: 10.10.10.14
|
||||||
|
|
||||||
|
vars:
|
||||||
|
ansible_user: ansible
|
||||||
|
```
|
||||||
|
|
7
docker.yml
Normal file
7
docker.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# file: docker.yml
|
||||||
|
|
||||||
|
- hosts: docker
|
||||||
|
become: true
|
||||||
|
roles:
|
||||||
|
- docker
|
10
hosts.yml
Normal file
10
hosts.yml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
# file: hosts
|
||||||
|
|
||||||
|
docker:
|
||||||
|
hosts:
|
||||||
|
doc1:
|
||||||
|
ansible_host: 10.10.10.14
|
||||||
|
|
||||||
|
vars:
|
||||||
|
ansible_user: ansible
|
9
roles/docker/defaults/main.yml
Normal file
9
roles/docker/defaults/main.yml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
# file: roles/docker/defaults/main.yml
|
||||||
|
|
||||||
|
docker_repo_url: "https://download.docker.com/linux/rhel/docker-ce.repo"
|
||||||
|
docker_manager_enabled: false
|
||||||
|
docker_manager_account: "{{ ansible_user }}"
|
||||||
|
docker_service_options: {
|
||||||
|
"selinux-enabled": true
|
||||||
|
}
|
7
roles/docker/handlers/main.yml
Normal file
7
roles/docker/handlers/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
# file: roles/docker/handlers/main.yml
|
||||||
|
|
||||||
|
- name: Restart docker
|
||||||
|
service:
|
||||||
|
name: docker
|
||||||
|
state: restarted
|
37
roles/docker/tasks/main.yml
Normal file
37
roles/docker/tasks/main.yml
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
---
|
||||||
|
# file: roles/docker/tasks/main.yml
|
||||||
|
|
||||||
|
- name: Add Docker repository
|
||||||
|
get_url:
|
||||||
|
url: "{{ docker_repo_url }}"
|
||||||
|
dest: '/etc/yum.repos.d/docker-ce.repo'
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-compose-plugin
|
||||||
|
state: latest
|
||||||
|
tags: packages
|
||||||
|
|
||||||
|
- name: Add manager user to Docker group
|
||||||
|
user:
|
||||||
|
name: "{{ docker_manager_account }}"
|
||||||
|
groups: docker
|
||||||
|
append: yes
|
||||||
|
when: docker_manager_enabled
|
||||||
|
|
||||||
|
- name: Configure Docker service options
|
||||||
|
copy:
|
||||||
|
content: "{{ docker_service_options | to_nice_json }}"
|
||||||
|
dest: /etc/docker/daemon.json
|
||||||
|
when: docker_service_options.keys() | length > 0
|
||||||
|
notify: Restart docker
|
||||||
|
|
||||||
|
- name: Start and enable Docker
|
||||||
|
service:
|
||||||
|
name: docker
|
||||||
|
state: started
|
||||||
|
enabled: yes
|
4
site.yml
Normal file
4
site.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
## This playbook deploys the whole application stack in this site.
|
||||||
|
|
||||||
|
- import_playbook: docker.yml
|
Loading…
Reference in a new issue