{"id":24576157,"url":"https://github.com/kayvansol/ansibledockerinstallation","last_synced_at":"2026-05-10T00:42:49.734Z","repository":{"id":271015553,"uuid":"912157417","full_name":"kayvansol/AnsibleDockerInstallation","owner":"kayvansol","description":"Install and Configure Docker via Ansible","archived":false,"fork":false,"pushed_at":"2025-01-05T05:46:32.000Z","size":363,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T22:23:28.578Z","etag":null,"topics":["ansible","ansible-playbook","ansible-role","containerd","docker","ubuntu-server"],"latest_commit_sha":null,"homepage":"https://medium.com/@kayvan.sol2/install-and-configure-docker-via-ansible-cd515510862f","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kayvansol.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-01-04T19:04:01.000Z","updated_at":"2025-01-15T07:32:41.000Z","dependencies_parsed_at":"2025-01-04T20:34:07.090Z","dependency_job_id":null,"html_url":"https://github.com/kayvansol/AnsibleDockerInstallation","commit_stats":null,"previous_names":["kayvansol/ansibledockerinstallation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayvansol%2FAnsibleDockerInstallation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayvansol%2FAnsibleDockerInstallation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayvansol%2FAnsibleDockerInstallation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kayvansol%2FAnsibleDockerInstallation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kayvansol","download_url":"https://codeload.github.com/kayvansol/AnsibleDockerInstallation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244036251,"owners_count":20387482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-playbook","ansible-role","containerd","docker","ubuntu-server"],"created_at":"2025-01-23T22:21:51.126Z","updated_at":"2026-05-10T00:42:49.696Z","avatar_url":"https://github.com/kayvansol.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Install and Configure Docker via Ansible\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/1.webp?raw=true)\n\n`Docker` is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. The service has both free and premium tiers. The software that hosts the containers is called Docker Engine. It was first released in 2013 and is developed by Docker, Inc.\n\nDocker is a tool that is used to automate the deployment of applications in lightweight containers so that applications can work efficiently in different environments in isolation.\n\n`Ansible` is a suite of software tools that enables infrastructure as code. It is open-source and the suite includes software provisioning, configuration management, and application deployment functionality.\n\nAnsible is an open source IT automation engine that automates provisioning, configuration management, application deployment, orchestration, and many other IT processes. It is free to use, and the project benefits from the experience and intelligence of its thousands of contributors.\n\n# Senario :\n\nWe have 3 machine, one for ansible management and 2 for hosts to install docker on them :\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/1.png?raw=true)\n\nAt first we must install ansible on the DesktopTest (ansible management) :\n```\nsudo apt-add-repository ppa:ansible/ansible\n\nsudo apt update\n\nsudo apt install ansible\n\nansible --version\n```\n\nNote : python must be installed at any linux and consider that we have one linux for source (ansible management node) where the ansible is installed on it and one or many linux for destination that must be install docker by ansible.\n\nImportant : management node must can ssh to any destination node passwordlesslly.\n\nfor this reason, we generate a ssh key on management node and copy it to any destination nodes.\n\nthen check the ansible project and files at management node :\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/10.png?raw=true)\n\n# Requirements File requirements.txt\nThe requirements.txt file is used in Python projects to list all the dependencies (external libraries or packages) that are required to run your application or project. This file allows users to easily install the necessary dependencies using pip, the Python package installer.\n```\ncd ansible\n\npip install -r requirements.txt\n```\n\n# Ansible Configuration File ansible.cfg\nThe ansible.cfg file defines key configuration settings for running Ansible playbooks and managing target servers. This file allows customization of various options, including connection details, logging, and roles directory paths, making it easier to manage Ansible behavior across different environments.\n\n# Playbooks :\nPlaybooks are used to execute multiple roles and tasks across targeted servers.\n\n‍‍docker.yml This is a Docker playbook that allows us to invoke the Docker role\n\n# Roles:\nEach role in this project is modular, focused on a specific area of system security, and designed to be reusable.\n\ndocker_installation With this role, you can install and configure Docker.\n\nEdit the inventory file based on destination node(s) :\n```\nall:\n  vars:\n    ansible_user: root\n    ansible_port: 22 #8090\n  hosts:\n    server01:\n      ansible_host: 192.168.56.157\n    server02:\n      ansible_host: 192.168.56.158\n```\n\nthen ping all destination host(s) to be ok before running the ansible playbooks :\n```\nansible all -m ping\n```\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/2.png?raw=true)\n\ncheck 2 machines that does not have docker installed on them :\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/3.png?raw=true)\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/4.png?raw=true)\n\nthen run the playbook :\n```\nansible-playbook -i inventory/RahBia.yml playbooks/docker.yml\n\nor\n\nansible-playbook playbooks/docker.yml\n```\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/5.png?raw=true)\n\nhtop on one of 2 machine :\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/6.png?raw=true)\n\nif any error happens, check and correct it and run the playbook again.\n\nNote : ansible process is idempotent, an idempotent operation is one that has no additional effect if it is called more than once with the same input parameters.\n\nat final we have the result like below :\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/7.png?raw=true)\n\nand now check 2 machines that have docker.\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/8.png?raw=true)\n\n![alt text](https://raw.githubusercontent.com/kayvansol/AnsibleDockerInstallation/refs/heads/main/img/9.png?raw=true)\n\nCongratulation. 🍹\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayvansol%2Fansibledockerinstallation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkayvansol%2Fansibledockerinstallation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkayvansol%2Fansibledockerinstallation/lists"}