Step-by-step process to install HTTPD using ansible-playbook
Step 1: Launch an instances
- Go to Amazon console management and log in with your credentials or AWS, and create a New Account.
- Now launch 2 Instances because Ansible is a master-slave configuration management tool. So We are working from the master node and installing HTTPD in the slave node.
- Now connect master node to git bash terminal by using SSH command.
Step 2: Install Ansible
- Now Install Ansible on your control node (local machine). By using following command
sudo amazon-linux-extras install ansible2
Step 3: Create a playbook
- Now create a playbook with .yml extension
sudo vi <filename.yml>
- Here is the playbook script to install HTTPD in slave node
- name: Install HTTPD using Ansible Playbook
hosts: slave-1 #here ensure that node instance name is correct or not
become: true
tasks:
- name: Install HTTPD package
package:
name: httpd
state: present
- name: Start HTTPD service
service:
name: httpd
state: started
enabled: yes
Step 4: Setting up Host Permission
- Now move to ansible directory path. In that ansible directory there is a file for HOST. Following command navigate to ansible path
cd /etc/ansible/
- Now open that Host file by using following command
sudo vi host
- Inside this host file we giving host details that means our slave node details like Private IP Address, user name and Keyfile details
- Now execute ansible ping command to verify that our slave node connected or not
ansible ping -m all
Step 5: Running the Playbook
- Now run ansible-playbook command to run your playbook, specifying the playbook file and target hosts. By using following command
ansible-playbook <filename.yml>
- Ansible will connect to the target hosts, execute the tasks defined in the playbook, and install HTTPD.
Step 6: Verification
- Our ansible playbook was successfully executed but need to verify that our HTTPD was installed are not.
- Now go Slave Node and copy Public IP Address and browse it.
How To Install HTTPD Using Ansible Playbook ?
Ansible is an open-source automation tool that improves IT orchestration, the design of the board, and application deployment. It works over SSH and requires no agent to be installed on a managed host. It is lightweight, efficient, and easy to set up, making it suitable for automating tasks on a variety of systems and environments.
HTTPD, otherwise called the Apache HTTP Server, is an open-source web server software broadly utilized for serving web content over the HTTP protocol. It is known for its dependability, scalability, and extensibility, making it a famous choice for hosting websites and applications.
Utilizing Ansible’s capabilities to automate the installation of HTTPD on target hosts is the topic of this guide. We can define the desired state of our infrastructure and carry out tasks in a repeatable and consistent manner by utilizing Ansible playbooks. This saves time and exertion, decreases the risk of manual errors, and ensures the consistency of configurations across servers.