В качестве хост ОС выступает Alma Linux
Установим Docker
sudo dnf update -y
sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo dnf remove podman buildah
sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin
sudo curl -L "https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/bin/docker-compose
sudo chmod +x /usr/bin/docker-compose
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
sudo docker run hello-world
Установим Git
sudo dnf install git
Добавим пользователя в группу docker
id $USER
sudo usermod -aG docker your_username (здесь имя вашего пользователя)
Проверяем
id $USER
Теперь запустим лабу и подождем
git clone https://github.com/stanleyogada/docker-ansible-env-setup.git
cd docker-ansible-env-setup/
sudo docker-compose up -d
Проверим
sudo docker-compose logs -f
SUCCESS! You can configure you servers with ansible!
Run 'cd /root/ansible-project' to start
Happy hacking!
Логин и пароль
Username: zero
Password: ][poiuy
Запустим управляющий хост
sudo docker container exec -it control-host bash
cd ~/ansible-project
Проверим
ansible all -m ping
zero@server-1 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
zero@server-2 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
[WARNING]: Platform linux on host zero@server-4 is using the discovered Python interpreter at /usr/libexec/platform-python, but future installation of another Python interpreter could change the meaning of
that path. See https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html for more information.
zero@server-4 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}
[WARNING]: Platform linux on host zero@server-3 is using the discovered Python interpreter at /usr/libexec/platform-python, but future installation of another Python interpreter could change the meaning of
that path. See https://docs.ansible.com/ansible-core/2.14/reference_appendices/interpreter_discovery.html for more information.
zero@server-3 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/libexec/platform-python"
},
"changed": false,
"ping": "pong"
}
Запустим сервер
sudo docker container exec -it server-1 bash
su - zero
Наш лабораторный стенд для Ansible готов