Thursday, August 6, 2020

Installing Ansible on CentOS 8

Server information

I have three CentOS servers. These servers are also going to be used for kubernetes.

master    192.168.56.5
worker1    192.168.56.6
worker2 192.168.56.7

Add this entry to your /etc/hosts file since we won't have DNS server.
You should be able to make a connection between master and the worker nodes.
Add user sam to wheel group. or
add sam to sudoers file to run commnads without prompting for password.
# cat > /etc/sudoers.d/sam
sam ALL=(ALL) NOPASSWD:ALL

or
$ echo "$(whoami) ALL=(ALL) NOPASSWD:ALL" | sudo tee /etc/sudoers.d/$(whoami)


Installing ansible on Centos 8.x
On master server perform the following tasks.

1. Update the DNF package repository cache
# dnf makecache

2. Download and Install epel-release package
# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# yum localinstall epel-release-latest-8.noarch.rpm

3. update the DNF package repository cache again
# dnf makecache

4. Now, Install ansible
# dnf install ansible

5. Verify ansible is installed.
# ansible --version
# ip a s | more


6. Set up passwordless authentication.
Generate ssh-key and copy to worker node
[sam@master ~]$ ssh-keygen -b 2048
[sam@master ~]$ ssh-copy-id master
[sam@master ~]$ ssh-copy-id worker1
[sam@master ~]$ ssh-copy-id worker2
[sam@master ~]$ ssh worker1
[sam@master ~]$ ssh worker2

7. Now, lets create an inverntory file which contains all your systems.
[sam@master ~]$ mkdir ansible
[sam@master ~]$ cat myhosts
master
worker1
worker2

List all your hosts from hostfile 'myhosts' and test the connection
[sam@master ~]$ ansible -i myhosts-m ping worker1
[sam@master ~]$ ansible -i myhosts all

You will see SUCCESS result.




No comments:

Post a Comment

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...