For this installation it was used latest debian bullseye.
Do install as root.
Install latest debian image and run on all nodes:
apt-get update
apt-get install -y wget bash-completion git python3
1.1) Setup Master and Slave node
On Master node generate ssh-key ( ssh-keygen ). Put .pub key of master to authorized_keys on slave nodes.
check if ssh from master to slaves work.
With your favorite editor edit /etc/hosts, add all hosts ( IP hostname )
example:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.253.180 portainer1
192.168.253.181 portainer2
192.168.253.182 portainer3
On Master node :
in root folder clone repo
git clone https://github.com/brucar18/automate.git
Move into automate dir and edit hosts.yaml to match your configuration
Edit host name and ip addresses to match yours in /etc/hosts
Move to automate folder and run installBase.sh script
./installBase.sh
To have access to ansible links run this command:
export PATH=$HOME/.local/bin:$PATH
In automate folder run:
This will prepare master and slave hosts
All playbooks are run from master as root
ansible-playbook -i hosts.yaml main.yaml
Setup portainer master and init swarm:
ansible-playbook -i hosts.yaml server.yaml
Setup swarm agents
First generate swarm agent task and then deploy it to slaves.
./gen_swarm.sh
ansible-playbook -i hosts.yaml swarm.yaml
Then login to portainer master node and create admin account
https://masternodeip:9443
Run playbook for dockers it will build image on all 3 nodes.
ansible-playbook -i hosts.yaml buildImages.yaml
after this task is completed go to Portainer web and create new stack
1.) Choose local, then select stack and Add stack
Copy content of docker-compose.yaml into web editor. Disable access control and deploy stack.