Thursday, December 26, 2024
Google search engine
HomeGuest BlogsHow To Run Ansible?

How To Run Ansible?

Did you know that there are over 2.8 million applications available in the play store (as of September 2019)? With the rise in the number of applications being deployed or a number of software being built and the continuous rise in demand of companies and individuals for high availability of services, it is difficult to make a stable, reliable, and mobile environment for application deployment, configuration management, cloud provisioning and many other IT needs. Obviously what better way is there to do it?

Ansible is an open-source orchestration tool that changed the way we plan, deploy and maintain the infrastructure. using Ansible one can turn tough, mundane tasks into repeatable playbooks and roll out enterprise-wide protocols with the push of a button.

Key Terminologies:

It is important to understand these terminologies before diving into the topic deeply.

  • Ansible Server: The node where Ansible is installed. This is the node from which orchestration is done.
  • Playbook: It is a set icon commands written in YAML that describes what should be done and where it should be done.
  • Tasks: A task is a single procedure that should be done.
  • Role: This is a way of encapsulating tasks and files related to them so that they can be later used in the playbook.
  • Inventory: It is a file containing the details about the client nodes.
  • Handler: A handler is a task that is called when a notifier(similar to a trigger in other technologies) is present in the playbook.
  • Module: A unit of code or binary that Ansible runs on managed nodes.
  • Ansible nodes/hosts: The independent systems that are managed by the Ansible server are called nodes or hosts.

 

Architecture of Ansible

 

How To Run Ansible:

ansible-playbook [-h] [--version] [-v] [-k]
                     [--private-key PRIVATE_KEY_FILE] [-u REMOTE_USER]
                     [-c CONNECTION] [-T TIMEOUT]
                     [--ssh-common-args SSH_COMMON_ARGS]
                     [--sftp-extra-args SFTP_EXTRA_ARGS]
                     [--scp-extra-args SCP_EXTRA_ARGS]
                     [--ssh-extra-args SSH_EXTRA_ARGS] [--force-handlers]
                     [--flush-cache] [-b] [--become-method BECOME_METHOD]
                     [--become-user BECOME_USER] [-K] [-t TAGS]
                     [--skip-tags SKIP_TAGS] [-C] [--syntax-check] [-D]
                     [-i INVENTORY] [--list-hosts] [-l SUBSET]
                     [-e EXTRA_VARS] [--vault-id VAULT_IDS]
                     [--ask-vault-pass | --vault-password-file VAULT_PASSWORD_FILES]
                     [-f FORKS] [-M MODULE_PATH] [--list-tasks]
                     [--list-tags] [--step] [--start-at-task START_AT_TASK]
                     playbook [playbook ...]

To run a basic playbook,

Example Command: ansible-playbook -i <INVENTORY_path>, -u <ANSIBLE_USER> -k first_playbook.yml

As shown in the above command, while running a playbook (first_playbook.yml), the user must mention the inventory list or the full path of the inventory file (list of hosts where the playbook should run), and the user who has access to connect to the mentioned hosts (ANSIBLE_USER). -K, will prompt the user for the password to connect.

There are other parameters that can be set like, -C for describing the type of connection to be made, –list-hosts for listing the matching hosts from the inventory, -e for passing extra variables to the playbook… etc. The command synopsis can be looked into for all the available parameters.

Advantages of Ansible:

  • Agentless – no installation is required on the client nodes. The main node, where Ansible is installed, is used for orchestrating the client nodes.
  • Efficient – Since there is no requirement for the installation of software on the client node it is much faster and leaves room for application resources on the client node.
  • Flexible and Powerful lets you modify the orchestrations as one needs, and so lets you model highly complex IT workflows.
  • Open Source –Ansible is readily available on their website for downloading the open for contributions on GitHub.

Configuration Management:

It is a process of maintaining a system in a desired and consistent state with adhering to its requirements. It is also a process of maintaining the system’s consistent performance over its lifetime.

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments