Pre-requisites to setup Ansible


There are certain pre-requisites before we start with the installation and configuration of Ansible in our setup.


Control Node Requirements

  • Currently Ansible can be run from any machine with Python 2 (version 2.7) or Python 3 (versions 3.5 and higher) installed.
  • This includes Red Hat, Debian, CentOS, macOS, any of the BSDs, and so on.
  • Windows is not supported for the control node.
  • macOS by default is configured for a small number of file handles, so if you want to use 15 or more forks you’ll need to raise the ulimit with sudo launchctl limit maxfiles unlimited. This command can also fix any “Too many open files” error.
  • Your node must have access to internet connection to download and install rpms from third party repositories.


Managed node requirements

  • On the managed nodes, you need a way to communicate, which is normally SSH. By default this uses SFTP.
  • If that’s not available, you can switch to SCP in ansible.cfg.
  • You also need Python 2 (version 2.6 or later) or Python 3 (version 3.5 or later).
  • We will not use SELinux on your environment but if you have a requirement to use SELinux then follow ansible documentation for additional steps


Update /etc/hosts on all the nodes

You can either configure BIND DNS server to resolve hostname or alternatively update /etc/hosts file with the hostname and IP details of your controller and managed hosts in your setup

 ~]# cat /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6  controller   server1  server2

When working with Amazon AWS the public IP may keep changing so at one point of time we may have to rely on dynamic inventory instead of static inventory. But it is still a good idea to have the private addresses configured in /etc/hosts or if you are using a different setup then you should use /etc/hosts for hostname resolution instead of IP Address to communicate with the managed nodes.


Install mandatory prerequisites on ansible client nodes

Now we don’t need any agent running on the client nodes but we do need python to be installed on the managed nodes for the controller to be able to execute playbooks using modules on the managed nodes.

Install python3 on all the client nodes (if not installed already). To install python3 we will use our default package manager

[root@server-1 ~]# dnf -y install python36.x86_64
[root@server-2 ~]# dnf -y install python36.x86_64

Verify the installed rpm version on both the managed nodes

[root@server-1 ~]# rpm -qa | grep python36

[root@server-2 ~]# rpm -qa | grep python36

Although I will also share you with the tips to work with Ansible without installing python on the managed nodes. But if possible it is strongly recommended to install python3 on the managed nodes as well.



What’s Next

Next in our Ansible Tutorial we will perform the installation of Ansible nodes using different possible methods.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can either use the comments section or contact me form.

Thank You for your support!!

Leave a Comment