To deploy jenkins using this ansible script make sure you have ansible installed on the controller node or local machine
sudo su
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]"
Enter file in which to save the key (/home/yourusername/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
At this point you will now need to configure the target node to accept ssh from root user using ssh keys only
sudo su
passwd
vim /etc/ssh/sshd_config
From: #PermitRootLogin prohibit-password
To: PermitRootLogin: yes
sudo service sshd restart
OR
sudo /etc/init.d/sshd restart
ssh-copy-id root@target-server-ip-address or fqdn
ssh root@target-server-ip-address or fqdn
vim /etc/ssh/sshd_config
From: PermitRootLogin yes
To: PermitRootLogin prohibit-password
From: #PubkeyAuthentication yes
To: PubkeyAuthentication yes
From: #PasswordAuthentication yes
To: PasswordAuthentication no
From this point on you will only be able to access the server from certificate based ssh
sudo service sshd restart
OR
sudo /etc/init.d/sshd restart
apt-get install python python3 -y
vim /etc/ansible/hosts
[jenkins]
jenkins ansible_host=ip-of-target-node ansible_user=root
cd <dir of ansible playbook>
ansible-playbook deployJenkins.yml -v
** Make sure you use -v for verbose as the Initial Administration password for jenkins will be printed in the output in the second last play and you will need this to finish the configuration in the jenkins UI **