Skip to content

Commit 18e7d70

Browse files
committed
lab5 ansible docker role done
1 parent 0d83e0f commit 18e7d70

File tree

14 files changed

+177
-9
lines changed

14 files changed

+177
-9
lines changed

ansible/ANSIBLE.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Ansible Playbook Deployment output:
2+
3+
```bash
4+
tjann@fedora:~/DevOps-Course/ansible$ ansible-playbook playbooks/dev/main.yaml | tail -n 50
5+
[WARNING]: Platform linux on host yandex_vm is using the discovered Python
6+
interpreter at /usr/bin/python3.10, but future installation of another Python
7+
interpreter could change the meaning of that path. See
8+
https://docs.ansible.com/ansible-
9+
core/2.18/reference_appendices/interpreter_discovery.html for more information.
10+
11+
PLAY [install Docker] **********************************************************
12+
13+
TASK [Gathering Facts] *********************************************************
14+
ok: [yandex_vm]
15+
16+
TASK [docker : Install Docker & compose] ***************************************
17+
included: /home/tjann/DevOps-Course/ansible/roles/docker/tasks/install_docker.yml for yandex_vm
18+
19+
TASK [docker : Install prerequisites] ******************************************
20+
ok: [yandex_vm]
21+
22+
TASK [docker : Add Docker official GPG key] ************************************
23+
ok: [yandex_vm]
24+
25+
TASK [docker : Add Docker repository] ******************************************
26+
ok: [yandex_vm]
27+
28+
TASK [docker : Update package cache] *******************************************
29+
changed: [yandex_vm]
30+
31+
TASK [docker : Install Docker] *************************************************
32+
ok: [yandex_vm]
33+
34+
TASK [docker : Ensure Docker is running] ***************************************
35+
ok: [yandex_vm]
36+
37+
TASK [docker : Install Docker Compose] *****************************************
38+
included: /home/tjann/DevOps-Course/ansible/roles/docker/tasks/install_compose.yml for yandex_vm
39+
40+
TASK [docker : Install Docker Compose] *****************************************
41+
ok: [yandex_vm]
42+
43+
PLAY RECAP *********************************************************************
44+
yandex_vm : ok=10 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
45+
```
46+
# Inventory Details
47+
48+
## Inventory list
49+
50+
```bash
51+
tjann@fedora:~/DevOps-Course/ansible$ ansible-inventory -i inventory/default_aws_ec2.yml --list
52+
{
53+
"_meta": {
54+
"hostvars": {
55+
"yandex_vm": {
56+
"ansible_host": "89.169.129.233",
57+
"ansible_ssh_private_key_file": "~/.ssh/yandex_vm",
58+
"ansible_user": "tjann"
59+
}
60+
}
61+
},
62+
"all": {
63+
"children": [
64+
"ungrouped"
65+
]
66+
},
67+
"ungrouped": {
68+
"hosts": [
69+
"yandex_vm"
70+
]
71+
}
72+
}
73+
```
74+
75+
## Inventory Structure
76+
77+
```bash
78+
tjann@fedora:~/DevOps-Course/ansible$ ansible-inventory -i inventory/default_aws_ec2.yml --graph
79+
@all:
80+
|--@ungrouped:
81+
| |--yandex_vm
82+
```
83+
84+

ansible/inventory/default_aws_ec2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
all:
33
hosts:
44
yandex_vm:
5-
ansible_host: 51.250.91.179
5+
ansible_host: 89.169.129.233
66
ansible_user: tjann
77
ansible_ssh_private_key_file: ~/.ssh/yandex_vm

ansible/roles/docker/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Docker Role
2+
3+
This role installs and configures Docker and Docker Compose.
4+
5+
## Requirements
6+
7+
- Ansible 2.10+
8+
- Ubuntu 22.04
9+
- 'sudo' privileges on the target machine
10+
11+
## Role Variables
12+
13+
- `docker_version`: The version of Docker to install (default: `latest`).
14+
- `docker_compose_version`: The version of Docker Compose to install (default: `1.29.2`).
15+
16+
## Example Playbook
17+
18+
```yaml
19+
- name: install Docker
20+
hosts: all
21+
roles:
22+
- role: docker
23+
```
24+
25+
## Configured Tasks
26+
27+
1. Dependencies installation
28+
2. Docker repository adding
29+
3. Docker installation
30+
4. Docker compose installation
31+
5. Enabling Docker autolaunching (systemctl enable docker)
32+
6. User adding to the 'docker' group
33+
7. Install completion check
34+
35+

ansible/roles/docker/tasks/install_docker.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
- name: Install prerequisites
22
apt:
33
name:
4+
- apt-transport-https
45
- ca-certificates
56
- curl
7+
- software-properties-common
8+
- python3-pip
69
state: present
710
update_cache: yes
811

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
- name: Install Docker & compose
22
include_tasks: install_docker.yml
3+
4+
- name: Install Docker Compose
5+
include_tasks: install_compose.yml

ansible/roles/web_app/defaults/main.yml

Whitespace-only changes.

ansible/roles/web_app/handlers/main.yml

Whitespace-only changes.

ansible/roles/web_app/meta/main.yml

Whitespace-only changes.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
- name: Install Docker Compose
2+
ansible.builtin.apt:
3+
name: "docker-compose-plugin"
4+
state: present
5+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
- name: Install prerequisites
2+
apt:
3+
name:
4+
- ca-certificates
5+
- curl
6+
state: present
7+
update_cache: yes
8+
9+
- name: Add Docker official GPG key
10+
apt_key:
11+
url: https://download.docker.com/linux/ubuntu/gpg
12+
state: present
13+
14+
- name: Add Docker repository
15+
apt_repository:
16+
repo: "deb [arch={{ ansible_architecture }}] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable"
17+
state: present
18+
19+
- name: Update package cache
20+
apt:
21+
update_cache: yes
22+
23+
- name: Install Docker
24+
apt:
25+
name:
26+
- docker-ce
27+
- docker-ce-cli
28+
- containerd.io
29+
state: present
30+
update_cache: yes
31+
32+
- name: Ensure Docker is running
33+
systemd:
34+
name: docker
35+
state: started
36+
enabled: true
37+

0 commit comments

Comments
 (0)