Skip to content

hamid-m331/Ansible

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Ansible Automation Playbooks

This repository is a collection of Ansible Playbooks and Roles designed to automate common tasks across various IT infrastructure components, including Linux servers, cloud environments, and potentially network devices.

Ansible is an open-source automation platform that simplifies configuration management, application deployment, and task automation without needing agents on the target machines (agentless).


✨ Features and Use Cases

This repository aims to cover several common automation scenarios (Playbooks will be structured accordingly):

  • Configuration Management: Ensuring consistency across all managed hosts (e.g., standardizing SSH settings, managing user accounts, and deploying configuration files).
  • Application Deployment: Automating the installation and deployment of applications (e.g., web servers like Nginx/Apache, database systems, or custom application code).
  • System Provisioning: Automating the setup of new virtual machines or servers (installing required packages, setting up firewall rules, and configuring basic OS settings).
  • Network Automation (Optional): If network playbooks are included, they would handle tasks like configuration backups, compliance checks, or interface configuration on devices like Cisco, Juniper, or Fortinet.

📂 Repository Structure

Ansible projects follow a standard directory layout. A typical structure for this repository might look like this:

Ansible/
├── inventory/
│   ├── production     # Inventory file for production hosts
│   └── staging        # Inventory file for staging/testing hosts
├── playbooks/
│   ├── site.yml       # Main entry point playbook
│   ├── web_deployment.yml
│   └── system_hardening.yml
├── roles/
│   ├── webserver/     # Role for configuring web servers
│   │   ├── tasks/
│   │   └── handlers/
│   └── security/      # Role for applying security baseline
│       ├── tasks/
│       └── vars/
├── group_vars/
│   ├── webservers.yml # Variables specific to the 'webservers' group
│   └── all.yml        # Variables applicable to all hosts
└── README.md

Key Components

  • inventory/: Defines the list of managed nodes (servers, devices) and groups them logically.
  • playbooks/: Contains the main YAML files (.yml) that orchestrate tasks against the hosts defined in the inventory.
  • roles/: Reusable and standardized units of automation, allowing for modular and clean Playbooks.
  • group_vars/: Stores variables specific to host groups (e.g., common ports, version numbers, credentials).

🛠 Getting Started

Prerequisites

  1. Ansible Control Node: A machine (usually Linux) with Ansible installed.
    pip install ansible
  2. Managed Hosts: Remote machines accessible via SSH, with Python installed (for Linux servers).

How to Run a Playbook

  1. Define Inventory: Ensure your target hosts are correctly listed in the inventory/ file (e.g., production or staging).
  2. Execute: Run a playbook using the ansible-playbook command, specifying the path to your playbook and the inventory file.

Example: Running the main deployment playbook against the production inventory:

ansible-playbook -i inventory/production playbooks/site.yml

Running Ad-Hoc Commands

For quick checks or single tasks across your inventory:

# Ping all hosts defined in the inventory
ansible all -i inventory/production -m ping

# Check the uptime of web servers
ansible webservers -i inventory/production -m command -a "uptime"

🤝 Contribution

Feel free to fork this repository, add new roles, improve existing playbooks, or report issues. Contributions help keep this automation collection robust and up-to-date.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors