How Do You Set up Ansible for the First Time?

Problem scenario
You have Ansible installed as a control server (a centralized server to push down configurations to other servers).  You want to use it to manage another server.  How do you configure the other server to be a managed node?  In other words, how do you configure Ansible to push configuration changes down to servers?

Ansible must be installed. If you need directions, see this posting if you are using RHEL.  If you are using Linux SUSE and need directions for installing Ansible, see this posting.

1.  Configure passwordless SSH from the Ansible server to the managed node.  If you are not sure how to do this, see this posting.

2.  On the Ansible control server (not the managed node), modify the /etc/ansible/hosts file.  (This directory path would normally never exist on a managed node. Only a server with Ansible would have /etc/ansible/.) If the directory /etc/ansible/  does not exist on the Ansible server, create it.  Add these two lines to the hosts file in /etc/ansible/ but substitute x.x.x.x for the internal IP address of the managed node (change "group_name" to whatever you like as well as "alias" to whatever you like):

alias ansible_ssh_host=x.x.x.x

Each word in the first position (where the word "alias" is) should be unique. The "#" works as a comment in this file. You may comment out lines as you architect your environment.

3.  Run this command as a test:  ansible -m ping all

4.  To be even more sure, run this command: ansible -m shell -a 'free -m' all

Leave a comment

Your email address will not be published. Required fields are marked *