ansible

Install basic dependencies for ansible

apt update && apt upgrade -y && apt autoremove -y && reboot
apt update
apt install software-properties-common -y
apt-add-repository --yes --update ppa:ansible/ansible
apt install python-argcomplete
vim /etc/ansible/hosts

Add the following configuration to your /etc/asible/hosts file.

[master]
apu03.home

[k8s]
apu[03:06].home

[nodes]
apu[04:06].home

[k8s:vars]
ansible_python_interpreter=/usr/bin/python3

Add an ansible user

useradd -m ansible

With group ansible and sudo allowance

usermod -a -G sudo ansible

Switch to the user

su - ansible

Start bash

bash

Create an ssh key

ssh-keygen

Give the user ansible the bash shell as default

usermod --shell /bin/bash ansible

Allow to sudo without password from the ansible user

echo "ansible ALL = (root) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/ansible
sudo chmod 0440 /etc/sudoers.d/ansible

Copy the public ssh key of the ansible user

vim .ssh/id_rsa.pub

Add it on all nodes as authorized key

mkdir .ssh
vim .ssh/authorized_keys

Find my first playbook on github


Revision #6
Created Sat, Dec 14, 2019 3:58 AM by Bodo
Updated Wed, Dec 18, 2019 4:45 AM by Bodo