2 minutes
Ansible Set Up and Configuration in AWS EC2 Instance
For this set up, we will be requiring the following:
- 1 RHEL EC2 Instance for the master/management node
- 1 RHEL EC2 Instance for the Unix host
Install Python and Git in both EC2 Instances:
$ sudo yum install python3 $ sudo yum install gitPerform update
Install pip
$ sudo yum -y install python3-pipInstall ansible
$ sudo pip3 install ansibleCreate new
ansibleuser for all hosts (master and host)$ sudo useradd ansible ; echo "" | passwd --stdin ansiblePlease refer from the AWS documentation on managing users:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html
Modify the entry in sudoers file
/etc/sudoersfor the ansible user for password-less sudo access:$ sudo visudoAdd this line at the end of the file.ansible ALL=(ALL) NOPASSWD: ALLGenerate ssh key in the ansible master server
Copy the public key to remote or host server as ansible user. You may need to create the .ssh directory and the authorized_keys if they don’t exist yet.
Change the permissions of the keys in the master server and authorized_keys in the host server.
$ chmod 600 id_rsa.pub $ chmod 600 id_rsa $ chmod 600 authorized_keysVerify the login to host from the master server.
$ ssh ansible@hostserverCreate the ansible inventory file, the default is
/etc/ansible/hosts.Use the ping module to test ansible and you should see similar output below for a successful host connection