Skip to content

Commit ccf2ffe

Browse files
committed
Ansible homework
1 parent 63b2492 commit ccf2ffe

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

M1-3-Ansible/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# M1-3-1 Configuration Management
2+
3+
## Ansible Task
4+
5+
Create an Ansible playbook that build, push and then run the Docker image for the Python
6+
application. Let your playbook has the following variables:
7+
8+
* `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app`
9+
* `image_tag` - contains the tag you tagged your image with, i.e. `v0.2`
10+
* `listen_port` - contains the listening port you're binding your app to.
11+
12+
Make sure that you set environment variable `PORT` when you define your container
13+
in the Ansible playbook that takes its value from `listen_port` variable.
14+
15+
Use Ansible modules. Do not shell out.
16+
17+
### Requirements
18+
19+
* Make sure you have Python installed. Any version above 3.8 would suffice.
20+
* The `requirements.txt` file in this directory contains the required Ansible version. Run
21+
22+
```sh
23+
pip install -r requirements.txt
24+
```
25+
26+
* Make sure that Docker is running on your local machine.
27+
28+
### Mind the following
29+
30+
* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is
31+
* Docker Desktop - `${HOME}/.docker/run/docker.sock`
32+
* Rancher DEsktop - ${HOME}/.rd/run/docker.sock
33+
34+
* If you're using one of the above, when you write your Ansible playbook you
35+
must specify the path to the docker socket with the parameter `docker_host`,
36+
i.e. `docker_host: "unix://{{ ansible_env.HOME }}/.rd/docker.sock"`.

requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
ansible==10.3.0
2+
ansible-compat==24.9.1
3+
ansible-core==2.17.5
4+
ansible-lint==24.9.2
15
blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0"
26
click==8.1.7 ; python_version >= "3.10" and python_version < "4.0"
37
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"

0 commit comments

Comments
 (0)