Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/saghosh8/ansible-ci-cd-automation

For an Ansible automation project that focuses on end-to-end CI/CD pipeline automation, your repository should be structured in a clear, organized manner to ensure maintainability, readability, and ease of use.
https://github.com/saghosh8/ansible-ci-cd-automation

ansible ansible-project automation cicd jenkinsfile

Last synced: 3 months ago
JSON representation

For an Ansible automation project that focuses on end-to-end CI/CD pipeline automation, your repository should be structured in a clear, organized manner to ensure maintainability, readability, and ease of use.

Awesome Lists containing this project

README

        

# Ansible CI/CD Pipeline Automation

## Description
This project automates the setup of a CI/CD pipeline for deploying applications to web servers using Jenkins and Ansible. It supports rolling updates and version rollbacks in case of failed deployments.

Here's an enhanced **Project Structure** section for your **README.md** file:

---

## Project Structure

```plaintext
/ansible-ci-cd-pipeline

├── Jenkinsfile # Jenkins pipeline configuration
├── ansible.cfg # Ansible configuration file
├── playbooks/
│ ├── deploy.yml # Ansible playbook for application deployment
│ ├── rollback.yml # Ansible playbook for version rollback
│ └── update.yml # Ansible playbook for rolling updates
├── inventory/
│ ├── production # Inventory file for production servers
│ └── staging # Inventory file for staging servers
├── roles/
│ ├── setup/
│ │ ├── tasks/
│ │ │ └── main.yml # Tasks to set up the environment (install dependencies, configure services)
│ │ ├── handlers/
│ │ │ └── main.yml # Handlers to restart services after deployment
│ │ ├── templates/
│ │ │ └── apache.conf.j2 # Template for Apache configuration (if applicable)
│ │ └── vars/
│ │ └── main.yml # Variables for environment setup
│ ├── deploy/
│ │ ├── tasks/
│ │ │ └── main.yml # Tasks for application deployment (copy files, restart services)
│ │ └── vars/
│ │ └── main.yml # Variables related to application deployment
│ ├── rollback/
│ │ ├── tasks/
│ │ │ └── main.yml # Tasks for version rollback (restore previous version, restart services)
│ │ └── vars/
│ │ └── main.yml # Variables related to version rollback
│ └── update/
│ ├── tasks/
│ │ └── main.yml # Tasks for rolling updates (deploy updates incrementally)
├── vars/
│ └── global.yml # Global variables used across playbooks and roles
├── README.md # Documentation and instructions for the project
└── .gitignore # Ignore unnecessary files (logs, environment files, etc.)
```

### **File Descriptions**

- **Jenkinsfile**: Defines the Jenkins pipeline that automates the CI/CD process, including setup, deployment, and rollback.
- **ansible.cfg**: Ansible configuration file that defines default settings like inventory paths and connection configurations.
- **playbooks/**: Directory containing the main Ansible playbooks:
- `deploy.yml`: Handles the deployment of the application.
- `rollback.yml`: Executes a version rollback if needed.
- `update.yml`: Performs rolling updates of the application.
- **inventory/**: Directory that holds inventory files for different environments (production, staging).
- **roles/**: Directory containing reusable roles for various actions like setup, deployment, and rollback.
- `setup/`: Configures the environment, installs packages, and ensures services are running.
- `deploy/`: Handles the tasks required for deploying the application.
- `rollback/`: Restores the previous version in case of a failed deployment.
- `update/`: Handles rolling updates across servers for minimal downtime.
- **vars/**: Contains global variables used across multiple playbooks and roles.
- **README.md**: Project documentation with setup instructions, usage examples, and project structure.
- **.gitignore**: Specifies which files and directories to ignore in Git, such as logs, retry files, and temporary files.

---
## Key Features
- Automates application deployment across multiple environments.
- Supports rolling updates and version rollbacks using Ansible.
- Easily configurable Jenkins pipeline with Ansible playbooks.

## Requirements
- Jenkins
- Ansible
- Git
- Web servers (e.g., Apache)

## Setup Instructions
1. Clone this repository:
`git clone https://github.com/yourusername/ansible-ci-cd-pipeline.git`

2. Configure your inventory files (`inventory/staging`, `inventory/production`) with the necessary hosts.

3. Set up the necessary credentials for Jenkins to access the servers.

4. Run the Jenkins pipeline, and it will automatically trigger Ansible playbooks for deployment and updates.

## Playbooks
- `playbooks/deploy.yml`: Deploys the application to web servers.
- `playbooks/rollback.yml`: Rolls back the application to a previous version.
- `playbooks/update.yml`: Performs a rolling update across web servers.