Getting started with Ansible : Managing Nodes

  • Ansible automates the management of remote systems and controls their desired state. A basic Ansible environment has three main components:Control node
  • A system on which Ansible is installed. You run Ansible commands such as ansible or ansible-inventory on a control node.Managed node
  • A remote system, or host, that Ansible controls.Inventory
  • A list of managed nodes that are logically organized. You create an inventory on the control node to describe host deployments to Ansible.
Basic components of an Ansible environment include a control node, an inventory of managed nodes, and a module copied to each managed node.
  • Ready to start using Ansible? Complete the following steps to get up and running:
  • Create an inventory by adding the IP address or fully qualified domain name (FQDN) of one or more remote systems to /etc/ansible/hosts. The following example adds the IP addresses of three virtual machines in KVM:
[myvirtualmachines]
192.0.2.50
192.0.2.51
192.0.2.52
  • Verify the hosts in your inventory.
ansible all --list-hosts
hosts (1):
  192.0.2.50
  192.0.2.51
  192.0.2.52

Set up SSH connections so Ansible can connect to the managed nodes.

  1. Add your public SSH key to the authorized_keys file on each remote system.
  2. Test the SSH connections, for example:
ssh username@192.0.2.50

If the username on the control node is different on the host, you need to pass the -u option with the ansible command.

Ping the managed nodes.

ansible all -m ping
192.0.2.50 | SUCCESS => {
  "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
    }
192.0.2.51 | SUCCESS => {
  "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
    }
192.0.2.52 | SUCCESS => {
  "ansible_facts": {
    "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
    }

Leave a Comment

MFH IT Solutions (Regd No -LIN : AP-03-46-003-03147775)

Consultation & project support organization.

Contact

MFH IT Solutions (Regd)
NAD Kotha Road, Opp Bashyam School, Butchurajupalem, Jaya Prakash Nagar Visakhapatnam, Andhra Pradesh – 530027