Skip to main content

Command Palette

Search for a command to run...

Day 55 : Understanding Configuration Management with Ansible

DevOps Learning

Published
2 min read
Day 55 : Understanding Configuration Management with Ansible

Ansible is an open-source automation tool used for configuration management, application deployment, and task automation. It simplifies complex tasks by allowing you to define them in a human-readable language called YAML.

Key Features of Ansible

  1. Agentless: Ansible does not require any agent software to be installed on the managed nodes. It uses SSH for Linux/Unix systems and WinRM for Windows systems.

  2. Idempotent: Ansible ensures that the tasks are idempotent, meaning they can be run multiple times without changing the system beyond the initial application.

  3. Declarative Language: Ansible uses YAML for its playbooks, making it easy to read and write.

  4. Extensible: You can extend Ansible’s functionality with custom modules and plugins.

  5. Secure: Ansible uses OpenSSH and other secure protocols for communication.

How Ansible Works

Ansible operates by connecting to your nodes and pushing out small programs called “Ansible modules” to them. These modules are executed on the nodes, and Ansible removes them when finished. The control node is where you run the Ansible commands, and the managed nodes are the devices being automated.

Task:

Run basic ping command using ansible.

Solution:

  • Installation of Ansible.

      sudo apt-add-repository ppa:ansible/ansible
      sudo apt update  && sudo apt install ansible
    
  • Edit the Ansible hosts file to include the new nodes:

      sudo nano /etc/ansible/hosts
    

    Add entries like:

      [nodes]
      #using ssh private key
      node1 ansible_host=node1-ip ansible_user=node1-user ansible_ssh_private_key_file=your-key.pem
    
      #using ssh password
      node1 ansible_host=your-node1-ip ansible_user=node1-user ansible_ssh_pass=node1-ssh-password
    
  • Test the connection with a ping command:

      ansible -m ping all
    

This should help you set up Ansible, configure the hosts file, and test the connection.

Thank you for reading😉.