Skip to content

Latest commit

 

History

History
57 lines (38 loc) · 947 Bytes

File metadata and controls

57 lines (38 loc) · 947 Bytes

Ansible Use Case: Dynamic Package Installation

Overview

This lab demonstrates how to dynamically install multiple packages using Ansible by defining them in the inventory file. It uses loops and variables to make the playbook reusable and adaptable.


Project Structure

/home/user/workspace/
├── inventory
└── app_install.yaml

Implementation Steps

1. Create Workspace

mkdir -p /home/user/workspace
cd /home/user/workspace/

2. Create Inventory File

vi inventory
[all]
server1 ansible_host=server1 ansible_user=server1_admin ansible_ssh_pass=server1_admin@123!

[all:vars]
package_list=['nginx', 'apache2', 'git']

Defines a variable package_list for dynamic package installation.


3. Create Playbook

vi app_install.yaml
---
- name: Insta