How To Install Automation With Ansible
Last updated
Last updated
Ansible is an open-source tool for software setup, configuration management, and application deployment. It can automate the process of server configuration and management, as well as application deployment and updates. Ansible uses a simple, human-readable language called YAML to describe tasks, and can work with a wide variety of systems and technologies. It is popularly used in IT operations, cloud provisioning, and software development.
The main function of Ansible is to automate the process of configuration management and application deployment. It allows you to define and manage server and application configurations in a simple, human-readable language called YAML. Ansible uses this configuration information to ensure that all servers in the network are configured in a consistent and predictable manner, and can also automate the application deployment and update process.
Automated configuration management: Ansible can help ensure that all servers in a network are configured in a consistent and predictable manner, reducing the risk of errors and downtime.
Application deployment: Ansible can automate the application deployment and update process, making it easy to deploy new features and bug fixes.
Automated provisioning: Ansible can be used to provision new servers and infrastructure, such as virtual machines or cloud instances, in a repeatable and consistent manner.
Ad-hoc command execution: Ansible makes it possible to execute commands on multiple systems at once, making it easy to perform tasks such as starting or stopping services, or checking system status.
Multi-node orchestration: Ansible allows to orchestrate tasks on multiple nodes, it can also handle a large number of systems at once, suitable for large-scale implementations.
Agentless: Ansible does not require any agent installed on the target machine, using SSH or WinRM to communicate with the target machine, which makes it lightweight and easy to set up.
sudo is a command in the Linux command-line. If you have root access, then sudo will execute commands as superuser. The sudo user and the commands they can use are found in the /etc/sudoers configuration file
This time we always use the user 'rizwan29' who has received permission from the sudo group
Install the ssh package for all machines
Ssh-keygen functions to generate private keys and public keys that will be used for authentication when communication occurs between two hosts. The ssh-keygen function is really needed by system admins when accessing the server, with ssh-keygen the system admin doesn't need to bother typing in passwords anymore.
After installing Ansible on the Control node, the /etc/host
s file will be created automatically. In this file we can add managed nodes / nodes that will be configured. We can also create our own inventory file in the home directory.
After a ping request is sent to the remote host, the module will return a value indicating whether the ping was successful. By default, the ping module will return the string "pong" if successful, and an excpetion (rejection) along with an error message (msg) if it fails.
After carrying out a ping test on the managed node, we will test whether the managed node can receive commands from the control node by checking the available memory on the managed node.
In this tutorial, we will install on managed nodes using the Playbook file. We will install the Apache2 Web Server, and check system-uptime (server startup time) on node 2. For this we create a Playbood file on the Controller (Router).