Now Docker is already installed and we can execute commands without sudo. So we run the next task adding ubuntu to docker group, which basically adds the user ubuntu -our running user- to the group docker. But we would be only able to run commands using sudo, which is not desirable. And we check docker group is in place with the task Ensure group “docker” exists.Īt this point, we should already have Docker installed in our machine. Then, with the task check docker is active, we are going to ensure that the service is running after installation.
#INSTALL DOCKER ON MAC USING BREW INSTALL#
More precisely, we are going to install the following: Time to install Docker needed packages in the next task. It installs the repository of Docker in the machine. If you are familiar with Ubuntu, you’ll already know this is need to install certain repositories.Īnd just below we have the task add docker repository to apt, which is pretty obvious. Next task, add GPG key, adds an APT key to the system. This means that Ansible is going to ensure that these packages are present in the machine, so it will install only if needed -this is how Ansible is idempotent. If you look at the task, you will see that the state has the value present. You can check in the documentation of Docker that these dependencies are required to install Docker. The first task, called install dependencies, installs the following packages: And the actions use to have params, like name or state in the apt one. Next, you find an array of tasks, which contains the different processes we are going to run over the remote host.Īny task has a name, an action -like apt, service, or, and optionally a loop. If you open Docker official documentation, you will find all of the commands are run as sudo. This is needed to install packages, change permissions, groups, etc. Then, we have the remote_user key: this is the user we use to SSH to the machine, let’s say ubuntu, but it could we whatever user with SSH access and proper permissions.īecome: this means that we are going to execute the different commands using sudo. As we only have one, we can just set all and things will go just fine. This is the whole playbook YAML content, and I will explain step by step:įirst things first, the hosts key, which value is all, means that the playbook is going to be executed over all the inventory hosts available. A playbook to install Docker and Docker Compose So if ssh is already working for you, you are ready to execute Ansible playbooks. The only thing to consider is that you need to be able to SSH this machine using an SSH key. Next, you need to create a file called inventory -it can be called whatever actually-, with the following content: This is where you will store YAML files with the steps needed to configure your remote host -the VPS where you want to install Docker and Docker Compose using Ansible. How to configure AnsibleĬonfiguring Ansible is a quite simple operation.įirst of all, you need to create a directory called playbooks. You can find more information in the official documentation.
#INSTALL DOCKER ON MAC USING BREW HOW TO#
I will teach you how to install Ansible in Mac and Ubuntu.įor Mac users: you can install Ansible using Homebrew, just by running the following command: brew install ansibleįor Ubuntu users: you can install Ansible running the following commands: sudo apt update sudo apt install software-properties-common sudo add-apt-repository -yes -update ppa:ansible/ansible sudo apt install ansible Installing Ansible consists of installing some CLI tools, and it’s very easy, regardless of the platform you are using. In this article, I will explain to you how to install, configure, and use Ansible to install Docker. Moreover, as cloud computing platforms like Google Cloud or AWS, or Azure, are providing managed Kubernetes clusters, the necessity of configuring machines is lower every day.īut, what happens if you cannot afford a cloud service and just want to buy a VPS or a dedicated machine and install Docker and Docker Compose to just run a couple of containers? With the advent of Docker and containerization in general, tools like Ansible, Puppet, or Chef have been losing weight as most of the configuration of the system occurs inside a container.