Skip to content

Commit 9cebdb4

Browse files
committed
lab6
1 parent 7b5770f commit 9cebdb4

30 files changed

Lines changed: 1226 additions & 128 deletions
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Ansible Deployment
2+
3+
on:
4+
push:
5+
branches: [ main, master ]
6+
paths:
7+
- 'ansible/'
8+
- '.github/workflows/ansible-deploy.yml'
9+
pull_request:
10+
branches: [ main, master ]
11+
paths:
12+
- 'ansible/'
13+
14+
jobs:
15+
lint:
16+
name: Ansible Lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: '3.12'
26+
27+
- name: Install dependencies
28+
run: |
29+
pip install ansible ansible-lint
30+
ansible-galaxy collection install community.docker
31+
32+
- name: Run ansible-lint
33+
run: |
34+
cd ansible
35+
ansible-lint playbooks/*.yml
36+
37+
deploy:
38+
name: Deploy Application
39+
needs: lint
40+
runs-on: ubuntu-latest
41+
steps:
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: '3.12'
49+
50+
- name: Install Ansible
51+
run: |
52+
pip install ansible
53+
ansible-galaxy collection install community.docker
54+
55+
- name: Create vault password file
56+
run: |
57+
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > /tmp/vault_pass
58+
59+
- name: Deploy with Ansible
60+
run: |
61+
cd ansible
62+
ansible-playbook playbooks/deploy.yml \
63+
--vault-password-file /tmp/vault_pass
64+
65+
- name: Verify Deployment
66+
run: |
67+
echo "Deployment completed"

ansible/.vault_pass

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
123123

ansible/docs/compose.yml.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
devops-app:
3+
image: ramzeus1/devops-info-service:latest
4+
container_name: devops-app
5+
restart: unless-stopped
6+
ports:
7+
- "5000:5000"
8+
environment:
9+
- HOST=0.0.0.0
10+
- PORT=5000
11+
logging:
12+
driver: json-file
13+
options:
14+
max-size: 10m
15+
max-file: "3"
16+
healthcheck:
17+
test: ["CMD", "curl", "-f", "http://localhost:5000/health"]
18+
interval: 30s
19+
timeout: 10s
20+
retries: 3
21+
start_period: 10s

ansible/docs/deploy_first.txt

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
PLAY [Deploy application] ******************************************************
3+
4+
TASK [Gathering Facts] *********************************************************
5+
ok: [ramzuka]
6+
7+
TASK [docker : Add Docker GPG key] *********************************************
8+
ok: [ramzuka]
9+
10+
TASK [docker : Add Docker repository] ******************************************
11+
ok: [ramzuka]
12+
13+
TASK [docker : Verify repository exists] ***************************************
14+
ok: [ramzuka]
15+
16+
TASK [docker : Install Docker packages] ****************************************
17+
ok: [ramzuka]
18+
19+
TASK [docker : Show installation status] ***************************************
20+
skipping: [ramzuka]
21+
22+
TASK [docker : Ensure Docker is running] ***************************************
23+
ok: [ramzuka]
24+
25+
TASK [docker : Add user to docker group] ***************************************
26+
ok: [ramzuka]
27+
28+
TASK [docker : Install Docker Python module] ***********************************
29+
ok: [ramzuka]
30+
31+
TASK [docker : Verify Docker installation] *************************************
32+
ok: [ramzuka]
33+
34+
TASK [docker : Show Docker version] ********************************************
35+
ok: [ramzuka] => {
36+
"msg": "Docker version 29.2.1, build a5c7197"
37+
}
38+
39+
TASK [web_app : Include wipe tasks] ********************************************
40+
skipping: [ramzuka]
41+
42+
TASK [web_app : Create application directory] **********************************
43+
ok: [ramzuka]
44+
45+
TASK [web_app : Template docker-compose.yml] ***********************************
46+
ok: [ramzuka]
47+
48+
TASK [web_app : Login to Docker Hub] *******************************************
49+
ok: [ramzuka]
50+
51+
TASK [web_app : Pull Docker image] *********************************************
52+
ok: [ramzuka]
53+
54+
TASK [web_app : Deploy with Docker Compose] ************************************
55+
changed: [ramzuka]
56+
57+
TASK [web_app : Verify deployment] *********************************************
58+
ok: [ramzuka] => {
59+
"msg": "Deployment completed"
60+
}
61+
62+
TASK [web_app : Wait for container to be ready] ********************************
63+
ok: [ramzuka]
64+
65+
TASK [web_app : Check health endpoint] *****************************************
66+
ok: [ramzuka]
67+
68+
TASK [web_app : Display application info] **************************************
69+
ok: [ramzuka] => {
70+
"msg": [
71+
"Container devops-app is running",
72+
"Application: http://127.0.0.1:5000",
73+
"Health check: 200"
74+
]
75+
}
76+
77+
PLAY RECAP *********************************************************************
78+
ramzuka : ok=19 changed=1 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
79+

ansible/docs/deploy_second.txt

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
PLAY [Deploy application] ******************************************************
3+
4+
TASK [Gathering Facts] *********************************************************
5+
ok: [ramzuka]
6+
7+
TASK [docker : Add Docker GPG key] *********************************************
8+
ok: [ramzuka]
9+
10+
TASK [docker : Add Docker repository] ******************************************
11+
ok: [ramzuka]
12+
13+
TASK [docker : Verify repository exists] ***************************************
14+
ok: [ramzuka]
15+
16+
TASK [docker : Install Docker packages] ****************************************
17+
ok: [ramzuka]
18+
19+
TASK [docker : Show installation status] ***************************************
20+
skipping: [ramzuka]
21+
22+
TASK [docker : Ensure Docker is running] ***************************************
23+
ok: [ramzuka]
24+
25+
TASK [docker : Add user to docker group] ***************************************
26+
ok: [ramzuka]
27+
28+
TASK [docker : Install Docker Python module] ***********************************
29+
ok: [ramzuka]
30+
31+
TASK [docker : Verify Docker installation] *************************************
32+
ok: [ramzuka]
33+
34+
TASK [docker : Show Docker version] ********************************************
35+
ok: [ramzuka] => {
36+
"msg": "Docker version 29.2.1, build a5c7197"
37+
}
38+
39+
TASK [web_app : Include wipe tasks] ********************************************
40+
skipping: [ramzuka]
41+
42+
TASK [web_app : Create application directory] **********************************
43+
ok: [ramzuka]
44+
45+
TASK [web_app : Template docker-compose.yml] ***********************************
46+
ok: [ramzuka]
47+
48+
TASK [web_app : Login to Docker Hub] *******************************************
49+
ok: [ramzuka]
50+
51+
TASK [web_app : Pull Docker image] *********************************************
52+
ok: [ramzuka]
53+
54+
TASK [web_app : Deploy with Docker Compose] ************************************
55+
changed: [ramzuka]
56+
57+
TASK [web_app : Verify deployment] *********************************************
58+
ok: [ramzuka] => {
59+
"msg": "Deployment completed"
60+
}
61+
62+
TASK [web_app : Wait for container to be ready] ********************************
63+
ok: [ramzuka]
64+
65+
TASK [web_app : Check health endpoint] *****************************************
66+
ok: [ramzuka]
67+
68+
TASK [web_app : Display application info] **************************************
69+
ok: [ramzuka] => {
70+
"msg": [
71+
"Container devops-app is running",
72+
"Application: http://127.0.0.1:5000",
73+
"Health check: 200"
74+
]
75+
}
76+
77+
PLAY RECAP *********************************************************************
78+
ramzuka : ok=19 changed=1 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
79+

ansible/docs/docker_ps.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2+
4880ba11c904 ramzeus1/devops-info-service:latest "python app.py" 20 minutes ago Up 20 minutes (unhealthy) 0.0.0.0:5000->5000/tcp, [::]:5000->5000/tcp devops-app

ansible/docs/docker_run.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
PLAY [Provision web servers] ***************************************************
3+
4+
TASK [Gathering Facts] *********************************************************
5+
ok: [ramzuka]
6+
7+
TASK [docker : Add Docker GPG key] *********************************************
8+
ok: [ramzuka]
9+
10+
TASK [docker : Add Docker repository] ******************************************
11+
ok: [ramzuka]
12+
13+
TASK [docker : Verify repository exists] ***************************************
14+
ok: [ramzuka]
15+
16+
TASK [docker : Install Docker packages] ****************************************
17+
ok: [ramzuka]
18+
19+
TASK [docker : Show installation status] ***************************************
20+
skipping: [ramzuka]
21+
22+
TASK [docker : Ensure Docker is running] ***************************************
23+
ok: [ramzuka]
24+
25+
TASK [docker : Add user to docker group] ***************************************
26+
ok: [ramzuka]
27+
28+
TASK [docker : Install Docker Python module] ***********************************
29+
ok: [ramzuka]
30+
31+
TASK [docker : Verify Docker installation] *************************************
32+
ok: [ramzuka]
33+
34+
TASK [docker : Show Docker version] ********************************************
35+
ok: [ramzuka] => {
36+
"msg": "Docker version 29.2.1, build a5c7197"
37+
}
38+
39+
TASK [Provisioning completed] **************************************************
40+
ok: [ramzuka] => {
41+
"msg": "System provisioning completed successfully"
42+
}
43+
44+
PLAY RECAP *********************************************************************
45+
ramzuka : ok=11 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0
46+

ansible/docs/health_check.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"status":"healthy","timestamp":"2026-03-04T06:52:52.268039+00:00","uptime_seconds":9}

ansible/docs/scenario1_normal.txt

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
2+
PLAY [Deploy application] ******************************************************
3+
4+
TASK [Gathering Facts] *********************************************************
5+
ok: [ramzuka]
6+
7+
TASK [docker : Add Docker GPG key] *********************************************
8+
ok: [ramzuka]
9+
10+
TASK [docker : Add Docker repository] ******************************************
11+
ok: [ramzuka]
12+
13+
TASK [docker : Verify repository exists] ***************************************
14+
ok: [ramzuka]
15+
16+
TASK [docker : Install Docker packages] ****************************************
17+
ok: [ramzuka]
18+
19+
TASK [docker : Show installation status] ***************************************
20+
skipping: [ramzuka]
21+
22+
TASK [docker : Ensure Docker is running] ***************************************
23+
ok: [ramzuka]
24+
25+
TASK [docker : Add user to docker group] ***************************************
26+
ok: [ramzuka]
27+
28+
TASK [docker : Install Docker Python module] ***********************************
29+
ok: [ramzuka]
30+
31+
TASK [docker : Verify Docker installation] *************************************
32+
ok: [ramzuka]
33+
34+
TASK [docker : Show Docker version] ********************************************
35+
ok: [ramzuka] => {
36+
"msg": "Docker version 29.2.1, build a5c7197"
37+
}
38+
39+
TASK [web_app : Include wipe tasks] ********************************************
40+
skipping: [ramzuka]
41+
42+
TASK [web_app : Create application directory] **********************************
43+
ok: [ramzuka]
44+
45+
TASK [web_app : Template docker-compose.yml] ***********************************
46+
ok: [ramzuka]
47+
48+
TASK [web_app : Login to Docker Hub] *******************************************
49+
ok: [ramzuka]
50+
51+
TASK [web_app : Pull Docker image] *********************************************
52+
ok: [ramzuka]
53+
54+
TASK [web_app : Deploy with Docker Compose] ************************************
55+
changed: [ramzuka]
56+
57+
TASK [web_app : Verify deployment] *********************************************
58+
ok: [ramzuka] => {
59+
"msg": "Deployment completed"
60+
}
61+
62+
TASK [web_app : Wait for container to be ready] ********************************
63+
ok: [ramzuka]
64+
65+
TASK [web_app : Check health endpoint] *****************************************
66+
ok: [ramzuka]
67+
68+
TASK [web_app : Display application info] **************************************
69+
ok: [ramzuka] => {
70+
"msg": [
71+
"Container devops-app is running",
72+
"Application: http://127.0.0.1:5000",
73+
"Health check: 200"
74+
]
75+
}
76+
77+
PLAY RECAP *********************************************************************
78+
ramzuka : ok=19 changed=1 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0
79+

0 commit comments

Comments
 (0)