Deploying Ansible (2024)

  • Challenge

    Install Ansible on the control host.

    Run the following commands on the control host:

    sudo yum install epel-release

    sudo yum install ansible

  • Challenge

    On each host, run the noted commands below. Make sure you set a password you can remember (you will need it later).

    Assuming you are logged in as cloud_user:

    sudo useradd ansible

    sudo passwd ansible

  • Challenge

    Configure a pre-shared key for Ansible that allows the user to log in from `control` to `workstation` without a password.

    Assuming you are logged into control as cloud_user, run the following commands providing the appropirate passwords when prompted and default options otherwise:

    sudo -i -u ansible (provide cloud_user a sudo password)

    ssh-keygen (accept default options by pressing enter )

    ssh-copy-id workstation (provide ansible user a password)

    logout

  • Challenge

    Configure the Ansible user on the workstation host so that Ansible may sudo without a password.

    1. Log into the workstation host as cloud_user and run the following commands:
      sudo visudo
    • Add text at the end of the file that is opened:
      ansible ALL=(ALL) NOPASSWD: ALL
    • Save file:
      (:wq in vim)
  • Challenge

    Create a simple inventory in `/home/ansible/inventory` consisting of only the `workstation` host.

    1. On the control host as the ansible user run the following commands:

    vim /home/ansible/inventory (note: you may use any text editor with which you are comfortable)

    • Add the text "workstation" to the file and save using (:wq in vim).
  • Challenge

    Write an Ansible playbook in `/home/ansible/git-setup.yml` on the control node that installs `git` on `workstation` then execute the playbook.

    1. On the control host as the ansible user run the following commands:
      vim /home/ansible/git-setup.yml (You may use any text editor with which your are comfortable.)
    • Add the following text to the file:
     --- # install git on target host - hosts: workstation become: yes tasks: - name: install git yum: name: git state: latest
    • Save (:wq in vim) and quit the text editor.

    • Run ansible-playbook -i /home/ansible/inventory /home/ansible/git-setup.yml.

  • Deploying Ansible (2024)

    FAQs

    Is Ansible easy to deploy? ›

    Even more, Ansible doesn't require the installation of any extra agents on the managed nodes so it's simple to start using it. Typically, the only thing a user needs is a terminal to execute Ansible commands and a text editor to define the configuration files.

    Is Ansible better than Terraform? ›

    But when you stack Terraform vs. Ansible head to head, Terraform is often preferred for infrastructure provisioning in cloud environments, while Ansible is celebrated for its configuration management capabilities and as a cross-domain automation solution.

    What are the advantages of Ansible deployment? ›

    The biggest ansible advantages is the designed for multi-tier deployments since starting. Ansible handle IT infrastructure by describing all of your systems interrelate, rather than just managing one system at a time. It uses no agents and no additional custom security infrastructure.

    Is IT hard to learn Ansible? ›

    Simple: As we've seen, Ansible uses a very simple syntax written in YAML known as playbooks—YAML (Yet Another Markup Language) is a human-readable data serialization language. We don't need special coding skills to code and understand playbooks. It is very easy to install and execute tasks in order.

    How NASA is using Ansible? ›

    Deployment and Provisioning: Ansible can automate the deployment of new applications, services, and infrastructure components. NASA can use Ansible Playbooks to define and execute the steps required to set up new systems or software, reducing the manual effort and human error associated with these tasks.

    Is Ansible better than Kubernetes? ›

    In other words, Ansible deploys changes to hosts, while Kubernetes manages containers and keeps them working properly. Ansible is an excellent useful tool for front-end developers, particularly in situations where some programming is required. Kubernetes is best suited to developing larger apps.

    What is Ansible not good for? ›

    Ansible, while powerful for data center automation, has limitations. Its statelessness can complicate complex orchestration tasks, and scalability may become an issue with a large number of managed nodes. Real-time monitoring capabilities are limited, and error handling can be challenging for complex scenarios.

    Can Kubernetes replace Ansible? ›

    All in all, Ansible and Kubernetes are powerful tools in the realm of DevOps and automation, but they serve different purposes. Ansible focuses on configuration management, automation, and server orchestration, while Kubernetes specialises in container orchestration and management of distributed applications.

    What is replacing Ansible? ›

    Puppet Lab

    Puppet is another alternative to Ansible. It allows for the deployment, configuration, and management of servers. Additionally, it provides configuration management, compliance, continuous deployment, and schedulability.

    What is the limitations of Ansible? ›

    Ansible disadvantages include debugging, performance, complex data structures and control flow. Complex data structures. Many network automation tasks require complex data structures. One of the first things I considered when learning Ansible was to use it to perform network discovery.

    Is Ansible necessary for DevOps? ›

    Ansible is popular in the DevOps community for its simplicity, flexibility, and extensive community support. It helps automate repetitive tasks, improve efficiency, and ensure consistency in infrastructure and application configurations, making it a valuable tool for DevOps practitioners.

    Why is Ansible so popular? ›

    Ansible enables users with no special coding skills to do powerful things across multiple IT domains. Its human readable automation can be utilized and shared by every IT team so they can get productive quickly and contribute their expertise.

    Should I learn Python or Ansible? ›

    For most network engineers, Ansible offers an ideal on-ramp before potentially expanding skills into Python. Leverage the strengths of each tool at the right times to boost your network automation journey. 👉 If you want to learn more about Python, check out these Python tutorials.

    Is Ansible no longer free? ›

    Ansible is an open source IT automation engine that automates provisioning, configuration management, application deployment, orchestration, and many other IT processes. It is free to use, and the project benefits from the experience and intelligence of its thousands of contributors.

    Is Ansible still relevant? ›

    In terms of popularity for individual configuration management tools, Ansible is now ahead of the pack, with a survey from TechRepublic showing that Ansible had the most widespread usage across survey respondents, at 41%, followed by Chef and Puppet in a tie at 31%, with Terraform at 31%, and Saltstack at 18%.

    Can you deploy with Ansible? ›

    Deploy apps consistently

    Ansible Automation Platform allows you to write playbooks that describe the desired state of your systems, and then it does the hard work of getting your systems to the desired state. Playbooks make your installations, upgrades, and day-to-day management repeatable and reliable.

    What is the disadvantage of Ansible? ›

    Ansible, while powerful for data center automation, has limitations. Its statelessness can complicate complex orchestration tasks, and scalability may become an issue with a large number of managed nodes. Real-time monitoring capabilities are limited, and error handling can be challenging for complex scenarios.

    Which is easy Terraform or Ansible? ›

    Terraform is a tool designed to help with the provisioning and deprovisioning of cloud infrastructure using an infrastructure as code approach. It is highly specialized for this purpose. On the other hand, Ansible is a more general tool that can be used for automation across various domains.

    Is Ansible better than Jenkins? ›

    In summary, Jenkins is generally considered to be a better tool for testing software projects, while Ansible is better suited for automating the deployment, configuration, and management of infrastructure and applications. Both these tools can be used together as part of a larger testing and deployment pipeline.

    Top Articles
    Latest Posts
    Article information

    Author: Sen. Ignacio Ratke

    Last Updated:

    Views: 6260

    Rating: 4.6 / 5 (76 voted)

    Reviews: 83% of readers found this page helpful

    Author information

    Name: Sen. Ignacio Ratke

    Birthday: 1999-05-27

    Address: Apt. 171 8116 Bailey Via, Roberthaven, GA 58289

    Phone: +2585395768220

    Job: Lead Liaison

    Hobby: Lockpicking, LARPing, Lego building, Lapidary, Macrame, Book restoration, Bodybuilding

    Introduction: My name is Sen. Ignacio Ratke, I am a adventurous, zealous, outstanding, agreeable, precious, excited, gifted person who loves writing and wants to share my knowledge and understanding with you.