Ansible - Add Host Ubuntu

Install pre-requisites:

apt-get install ssh python

Do not prompt for password when user is a member of sudo group:

visudo
%sudo   ALL=(ALL:ALL) NOPASSWD:ALL

Add pub-key on authorized_keys file to allow login using priv-key:

useradd x
mkdir /home/x/.ssh
echo "ssh-rsa x [email protected]" > /home/x/.ssh/authorized_keys
chmod 664 /home/x/.ssh/authorized_keys
chown -R x.x /home/x/.ssh
sudo usermod -aG sudo x

This is still a manual task, working on conditional rules to ignore x.x.x.x(MX Relay):

/etc/postfix/main.cf:
myorigin = /etc/mailname
relayhost = x.x.x.x