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
  1. Install Python and Git in both EC2 Instances:

        $ sudo yum install python3
        $ sudo yum install git
    
    Ansible Installation
  2. Perform update

    Ansible Installation
  3. Install pip

        $ sudo yum -y install python3-pip
    
    Ansible Installation
  4. Install ansible

        $ sudo pip3 install ansible
    
    Ansible Installation
  5. Create new ansible user for all hosts (master and host)

        $ sudo useradd ansible ;  echo "" | passwd --stdin ansible
    

    Please refer from the AWS documentation on managing users:

    https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html

  6. Modify the entry in sudoers file /etc/sudoers for the ansible user for password-less sudo access:

        $ sudo visudo
    
    Add this line at the end of the file.
    
        ansible ALL=(ALL) NOPASSWD: ALL
    
  7. Generate ssh key in the ansible master server

    Ansible Installation
  8. 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.

    Ansible Installation
  9. 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_keys
    
  10. Verify the login to host from the master server.

      $ ssh ansible@hostserver
    
  11. Create the ansible inventory file, the default is /etc/ansible/hosts.

    Ansible Installation
  12. Use the ping module to test ansible and you should see similar output below for a successful host connection

    Ansible Installation