Ansible Install Package
The Application development team wanted to test some applications on app servers in the Datacenter. They shared some prerequisites with the DevOps team, and packages need to be installed on app servers. Since we are already using Ansible for automating such tasks, please perform this task using Ansible as per the details mentioned below:
Create an inventory file /home/thor/playbook/inventory on jump host and add all app servers in it.
Create an Ansible playbook /home/thor/playbook/playbook.yml to install httpd package on all app servers using the Ansible yum module.
Make sure the user thor should be able to run the playbook on jump host.
For validation, try to run the playbook using the command ansible-playbook -i inventory playbook.yml
Execution
Navigate to /home/thor/playbook/ on the jump host and create an inventory file with the details of your app servers. A sample of the file is shown below;
hostname ansible_host=ip-address ansible_ssh_pass=password ansible_user=username
hostname ansible_host=ip-address ansible_ssh_pass=password ansible_user=username
hostname ansible_host=ip-address ansible_ssh_pass=password ansible_user=username
- Create an ansible playbook.yml at /home/thor/playbook/ with the following content provided in this link ---> https://github.com/mightygull/Ansible-Playbooks/blob/main/install_packages.yml
This playbook specifies that it should run on the hosts listed in the inventory file. It uses the yum module to install the httpd package.
Run the playbook using the required command specified in the task details
ansible-playbook -i inventory playbook.yml
Subscribe to my newsletter
Read articles from Samson Oladipo directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Samson Oladipo
Samson Oladipo
DevOps enthusiast sharing real-world insights. ๐ #Automation #CI/CD #InfrastructureAsCode