Initial commit

This commit is contained in:
Tyler Hale 2024-11-05 14:00:56 -07:00
parent 9efd872019
commit 933293e8ef
Signed by: Tyler
GPG key ID: C7CC4B910D88EF96
8 changed files with 99 additions and 3 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
# ---> Ansible
*.retry

View file

@ -1,3 +1,22 @@
# Ansible-Docker
Ansible playbook that provisions a server to run Docker.
# Ansible-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
View file

@ -0,0 +1,7 @@
---
# file: docker.yml
- hosts: docker
become: true
roles:
- docker

10
hosts.yml Normal file
View file

@ -0,0 +1,10 @@
---
# file: hosts
docker:
hosts:
doc1:
ansible_host: 10.10.10.14
vars:
ansible_user: ansible

View 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
}

View file

@ -0,0 +1,7 @@
---
# file: roles/docker/handlers/main.yml
- name: Restart docker
service:
name: docker
state: restarted

View 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
View file

@ -0,0 +1,4 @@
---
## This playbook deploys the whole application stack in this site.
- import_playbook: docker.yml