Setup machines and install Anisble.
Before we begin to install ansible, we will setup server and client machines.
I am using Virtualbox to setup two machines.
Server Machine Specs:
Hostname:ansible.linux.com
2 Network Card: NAT and Internal
OS: Centos 6
Client Machine:
Hostname: node01.linux.com
1 Network Card: Internal
OS: Centos 6
Once machines are configure with OS, we need to setup passwordless ssh connection between server and client. Below are the steps.
Step1:
First login to server and add host entries with IPaddress in /etc/hosts file.
[root@ansible ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
11.0.0.62 ansible ansible.linux.com
11.0.0.63 node01 node01.linux.com
Same need to be done in client machine
Step2:
Now from server machine generate ssh private and public key as shown below
[root@ansible ~]# ssh-keygen -t rsa
output:
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
28:4b:f7:ab:d2:b5:06:29:5c:1c:54:c4:44:0f:ed:f1 root@ansible.linux.com
The key's randomart image is:
+--[ RSA 2048]----+
| ..**. |
| . .oo |
| . . ..o |
| o. . E |
| .o.o.S |
| .o+o.. |
| .o o.. |
| . . o. |
| ..o. |
+-----------------+
Step3:
Copy public to client machine using ssh-copy-id command as shown below
[root@ansible ~]# ssh-copy-id node01
root@node01's password:
Now try logging into the machine, with "ssh 'node01'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
Step4:
Now check if passwordless authentication works from server to client using SSH
[root@ansible ~]# ssh node01
Last login: Tue May 9 17:24:54 2017 from 11.0.0.62
Once server to client passwordless authentication works try similary from client to server
Install Anisble in Server
For ansible we need EPEL repository. If not present we need to manually install.
Step1:
Download and install EPEL
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
Step2:
Install ansible using yum
#yum install ansible
Step3:
Once installed check version of anisble installed.
[root@ansible ~]# ansible --version
ansible 2.3.0.0
Before we begin to install ansible, we will setup server and client machines.
I am using Virtualbox to setup two machines.
Server Machine Specs:
Hostname:ansible.linux.com
2 Network Card: NAT and Internal
OS: Centos 6
Client Machine:
Hostname: node01.linux.com
1 Network Card: Internal
OS: Centos 6
Once machines are configure with OS, we need to setup passwordless ssh connection between server and client. Below are the steps.
Step1:
First login to server and add host entries with IPaddress in /etc/hosts file.
[root@ansible ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
11.0.0.62 ansible ansible.linux.com
11.0.0.63 node01 node01.linux.com
Same need to be done in client machine
Step2:
Now from server machine generate ssh private and public key as shown below
[root@ansible ~]# ssh-keygen -t rsa
output:
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
28:4b:f7:ab:d2:b5:06:29:5c:1c:54:c4:44:0f:ed:f1 root@ansible.linux.com
The key's randomart image is:
+--[ RSA 2048]----+
| ..**. |
| . .oo |
| . . ..o |
| o. . E |
| .o.o.S |
| .o+o.. |
| .o o.. |
| . . o. |
| ..o. |
+-----------------+
Step3:
Copy public to client machine using ssh-copy-id command as shown below
[root@ansible ~]# ssh-copy-id node01
root@node01's password:
Now try logging into the machine, with "ssh 'node01'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
Step4:
Now check if passwordless authentication works from server to client using SSH
[root@ansible ~]# ssh node01
Last login: Tue May 9 17:24:54 2017 from 11.0.0.62
Once server to client passwordless authentication works try similary from client to server
Install Anisble in Server
For ansible we need EPEL repository. If not present we need to manually install.
Step1:
Download and install EPEL
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
Step2:
Install ansible using yum
#yum install ansible
Step3:
Once installed check version of anisble installed.
[root@ansible ~]# ansible --version
ansible 2.3.0.0
Comments
Post a Comment