An easy way to install a docker SWARM cluster with ANSIBLE ?

Xavier Pestel (Xavki)
4 min readOct 8, 2021

In a previous, we installed a prometheus stack with ansible : node exporter, prometheus, grafana… And I propose to install a new stack : a docker swarm cluster and some tools.

In this post, we’ll just install a simple swarm cluster. And we’ll use vagrant to have our infrastructure to develop it. And after, with few lines of ansible code, we’ll have our docker cluster. And this is very very easy.

Our vagrant infrastructure

Vagrant allows us to create virtual machines and orchestrate its. In our case, we just want to have some servers. Exactly we want 3 masters and 2 workers. I give you my standard vagrant file to do it. You can reuse it and maybe you need to change it for you use case.

The vagrantfile

Vagrant.configure(2) do |config|

# Set some variables
etcHosts=""
common = <<-SHELL
sudo apt update -qq 2>&1 >/dev/null
sudo apt install -y -qq git vim tree net-tools telnet git python3-pip sshpass nfs-common 2>&1 >/dev/null
sudo echo "autocmd filetype yaml setlocal ai ts=2 sw=2 et" > /home/vagrant/.vimrc
sed -i 's/ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
sudo…

--

--

Xavier Pestel (Xavki)
Xavier Pestel (Xavki)

Written by Xavier Pestel (Xavki)

Microservices architecture and opensource. I’m maintainer of xavki https://youtube.com/c/xavki-linux about opensource. My blog : https://xavki.blog/

No responses yet