From ccf2ffed00d08a31cfbf3d1d55929102dd70e6d7 Mon Sep 17 00:00:00 2001 From: Iliyan Vutov Date: Mon, 28 Oct 2024 18:01:20 +0200 Subject: [PATCH] Ansible homework --- M1-3-Ansible/README.md | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 M1-3-Ansible/README.md diff --git a/M1-3-Ansible/README.md b/M1-3-Ansible/README.md new file mode 100644 index 00000000..e44faf9c --- /dev/null +++ b/M1-3-Ansible/README.md @@ -0,0 +1,36 @@ +# M1-3-1 Configuration Management + +## Ansible Task + +Create an Ansible playbook that build, push and then run the Docker image for the Python +application. Let your playbook has the following variables: + +* `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app` +* `image_tag` - contains the tag you tagged your image with, i.e. `v0.2` +* `listen_port` - contains the listening port you're binding your app to. + +Make sure that you set environment variable `PORT` when you define your container +in the Ansible playbook that takes its value from `listen_port` variable. + +Use Ansible modules. Do not shell out. + +### Requirements + +* Make sure you have Python installed. Any version above 3.8 would suffice. +* The `requirements.txt` file in this directory contains the required Ansible version. Run + +```sh +pip install -r requirements.txt +``` + +* Make sure that Docker is running on your local machine. + +### Mind the following + +* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is + * Docker Desktop - `${HOME}/.docker/run/docker.sock` + * Rancher DEsktop - ${HOME}/.rd/run/docker.sock + +* If you're using one of the above, when you write your Ansible playbook you +must specify the path to the docker socket with the parameter `docker_host`, +i.e. `docker_host: "unix://{{ ansible_env.HOME }}/.rd/docker.sock"`. diff --git a/requirements.txt b/requirements.txt index b5ba78cc..38a10fb1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,7 @@ +ansible==10.3.0 +ansible-compat==24.9.1 +ansible-core==2.17.5 +ansible-lint==24.9.2 blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"