{"id":28798142,"url":"https://github.com/javadtorabikh/devopsansible","last_synced_at":"2025-08-20T00:15:58.933Z","repository":{"id":290359461,"uuid":"974168664","full_name":"JavadTorabiKh/DevOpsAnsible","owner":"JavadTorabiKh","description":"A hybrid intelligent system for automated web cluster management and backup on VMware ESXi","archived":false,"fork":false,"pushed_at":"2025-06-28T08:06:52.000Z","size":78,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T09:24:27.723Z","etag":null,"topics":["admin-server","ansible","docker","gitlab","server"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JavadTorabiKh.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-04-28T11:06:36.000Z","updated_at":"2025-06-28T08:06:52.000Z","dependencies_parsed_at":"2025-05-13T13:41:35.625Z","dependency_job_id":"e3a991d4-9f2e-48db-b9a8-7bb011b3a8d8","html_url":"https://github.com/JavadTorabiKh/DevOpsAnsible","commit_stats":null,"previous_names":["javadtorabikh/auto-scalingwebcluster","javadtorabikh/devopsansible"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/JavadTorabiKh/DevOpsAnsible","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavadTorabiKh%2FDevOpsAnsible","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavadTorabiKh%2FDevOpsAnsible/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavadTorabiKh%2FDevOpsAnsible/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavadTorabiKh%2FDevOpsAnsible/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JavadTorabiKh","download_url":"https://codeload.github.com/JavadTorabiKh/DevOpsAnsible/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JavadTorabiKh%2FDevOpsAnsible/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271242268,"owners_count":24725008,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-19T02:00:09.176Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["admin-server","ansible","docker","gitlab","server"],"created_at":"2025-06-18T05:02:02.426Z","updated_at":"2025-08-20T00:15:58.857Z","avatar_url":"https://github.com/JavadTorabiKh.png","language":"Python","readme":"# Ansible Infrastructure Automation 🚀\n\nWelcome to the Ansible Infrastructure Automation project! This repository provides a robust framework for managing server infrastructure using Ansible, integrated with a GitLab CI/CD pipeline for automated linting, testing, and deployment. Whether you're setting up Docker, installing base packages, or configuring DNS, this project has you covered with a modular and scalable design.\n\n![Ansible Logo](images.jpeg)\n\n## ✨ Features\n\n- Dynamic Inventory: Uses a Python script (env_inventory.py) to generate server lists from environment variables, eliminating static host files.\n- Modular Roles: Organized roles for Docker and base package installation, with Molecule tests for validation.\n- CI/CD Pipeline: Automated linting, testing, planning, and applying changes via GitLab CI.\n- DNS Management: Dedicated playbook for DNS configuration.\n- Error Handling: Retries and artifact logging for robust pipeline execution.\n\n## 📋 Prerequisites\nTo use this project, ensure the following are set up:\n\n1. Python 3 and pip:\n\n- Install Python 3 and pip: \n```bash\n    dnf install python3-pip  # For Rocky Linux\n    apt install python3-pip  # For Ubuntu\n```\n2. Docker Engine:\n\n- Install Docker CE following the official instructions: https://docs.docker.com/engine/install/\n\n\n3. SSH Key Distribution:\n- Copy the runner's public SSH key to managed servers:\n\n```bash\n    Copy the runner's public SSH key to managed servers:\n    cat ~/.ssh/id_rsa.pub | ssh \u003cuser\u003e@\u003cserver\u003e 'mkdir -p ~/.ssh \u0026\u0026 cat \u003e\u003e ~/.ssh/authorized_keys'\n```\n\n4. GitLab Environment Variables:\n\n- Define server details in GitLab CI/CD Settings → Variables (e.g., SERVER1_DATA, SERVER2_DATA).\n- Format: See ansible/inventory/env_inventory.py for details.\n\n\n\n## 🗂️ Repository Structure\n```plain\nDevOpsAnsible/\n├── .gitlab-ci.yml                  # Enhanced CI/CD pipeline\n├── README.md                       # Updated documentation\n├── CHANGELOG.md                    # Version history\n├── LICENSE                         # MIT/Apache license\n├── .ansible-lint                   # Linting rules\n├── requirements.txt                # Python deps\n├── tests/                          # Test directory\n│   ├── molecule/                   # Molecule tests\n│   └── test-requirements.txt       # Test dependencies\n└── ansible/\n    ├── ansible.cfg                 # Config\n    ├── requirements.yml            # Galaxy roles\n    ├── vault.yml                   # Encrypted secrets\n    ├── inventory/\n    │   ├── production/\n    │   │   ├── hosts              # Prod hosts\n    │   │   └── group_vars/\n    │   │       ├── all.yml        # Common vars\n    │   │       ├── docker.yml     # Docker-specific\n    │   │       └── gitlab.yml     # GitLab-specific\n    │   ├── staging/\n    │   │   ├── hosts\n    │   │   └── group_vars/\n    │   └── env_inventory.py        # Dynamic inventory\n    ├── playbooks/\n    │   ├── site.yml                # Master playbook\n    │   ├── docker.yml              # Docker setup\n    │   ├── gitlab.yml              # GitLab setup\n    │   ├── monitoring.yml          # Enhanced monitoring\n    │   ├── backups.yml             # Backup system\n    │   ├── security.yml            # Security hardening\n    │   └── maintenance.yml         # Maintenance tasks\n    └── roles/\n        ├── common/                 # Enhanced common\n        │   ├── tasks/\n        │   │   ├── main.yml\n        │   │   ├── packages.yml\n        │   │   ├── security.yml\n        │   │   ├── users.yml\n        │   │   └── tuning.yml\n        │   ├── handlers/\n        │   ├── templates/\n        │   └── defaults/\n        ├── docker/                 # Enhanced Docker\n        │   ├── tasks/\n        │   │   ├── main.yml\n        │   │   ├── install.yml\n        │   │   ├── config.yml\n        │   │   ├── compose.yml     # Docker Compose\n        │   │   └── networks.yml    # Network config\n        │   ├── templates/\n        │   │   ├── daemon.json.j2\n        │   │   └── docker-compose.yml.j2\n        │   ├── defaults/\n        │   └── vars/\n        ├── gitlab/                 # Enhanced GitLab\n        │   ├── tasks/\n        │   │   ├── main.yml\n        │   │   ├── install.yml\n        │   │   ├── config.yml\n        │   │   ├── runners.yml     # CI runners\n        │   │   └── backup.yml      # GitLab backup\n        │   ├── templates/\n        │   │   ├── gitlab.rb.j2\n        │   │   └── backup.sh.j2\n        │   ├── defaults/\n        │   └── vars/\n        ├── monitoring/             # Enhanced monitoring\n        │   ├── tasks/\n        │   │   ├── main.yml\n        │   │   ├── node_exporter.yml\n        │   │   ├── cadvisor.yml    # Container monitoring\n        │   │   └── alerts.yml      # Alert rules\n        │   ├── templates/\n        │   └── defaults/\n        ├── backups/                # Enhanced backups\n        │   ├── tasks/\n        │   │   ├── main.yml\n        │   │   ├── setup.yml\n        │   │   ├── gitlab.yml\n        │   │   └── docker.yml\n        │   ├── templates/\n        │   └── defaults/\n        └── security/              # New security role\n            ├── tasks/\n            │   ├── main.yml\n            │   ├── firewall.yml\n            │   ├── ssh_hardening.yml\n            │   └── audits.yml\n            ├── templates/\n            └── defaults/\n```\n\n## 🚀 Getting Started\n\n1. Clone the Repository:\n```bash\n    git clone https://github.com/JavadTorabiKh/DevOpsAnsible.git\n    cd DevOpsAnsible\n```\n\n2. Set Up GitLab CI:\n\n- Configure environment variables in GitLab CI/CD Settings → Variables.\n- Ensure your runner has access to the target servers via SSH.\n\n\n3. Run Locally (Optional):\n\n- Install dependencies:\n```bash\n    pip3 install --user ansible ansible-lint yamllint molecule molecule-docker docker\n    ansible-galaxy install -r ansible/requirements.yml\n```\n\n4. Run the main playbook:\n```bash\n    ansible-playbook ansible/playbooks/main.yml -i ansible/inventory/env_inventory.py\n```\n\n## 🛠️ CI/CD Pipeline\nThe GitLab CI pipeline automates the following stages:\n\n| Stage | Description |\n|---------|---------|\n| lint    | Runs yamllint and ansible-lint to ensure code quality.   |\n| test    | Executes Molecule tests for roles in parallel (e.g., docker, packages_base).   |\n| check_config    |  Simulates and applies DNS configuration changes.   |\n| plan    | Simulates changes for the main playbook (--check --diff).   |\n| apply    | Applies changes manually to target servers.   |\n\n\n## Artifacts\n\n- Logs are stored as artifacts for 1 week to debug failures.\n- Use the GitLab UI to trigger the apply stage manually.\n\n## 🧪 Testing with Molecule\nEach role (docker, packages_base) includes Molecule tests:\n\n- Navigate to ansible/roles/\u003crole\u003e/molecule/default/.\n\n- Run tests:\n```bash\n    cd ansible/roles/docker\n    molecule test\n```\n\n## 🛠️ Customization\n\n- Add New Roles: Create a new directory under ansible/roles/ with tasks/main.yml and defaults/main.yml.\n- Extend Inventory: Update env_inventory.py to support additional server attributes.\n- Modify Pipeline: Adjust .gitlab-ci.yml to add new stages or jobs.\n\n## 📝 Notes\n\n- Ensure environment variables are securely stored in GitLab.\n- Review ansible.cfg for custom Ansible settings (e.g., timeouts, SSH options).\n- For large deployments, consider using a custom Docker image with pre-installed dependencies to reduce pipeline runtime.\n\n## 🤝 Contributing\nContributions are welcome! Please:\n\n1. Fork the repository.\n2. Create a feature branch (git checkout -b feature/awesome-feature).\n3. Commit changes (git commit -m 'Add awesome feature').\n4. Push to the branch (git push origin feature/awesome-feature).\n5. Open a pull request.\n\n## 📧 Contact\nFor questions or support, reach out via [GitLab Issues](/issues) or [email](javadtorabi462@gmail.com).\n\n---\n\nPowered by Ansible and GitLab CI/CD\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavadtorabikh%2Fdevopsansible","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjavadtorabikh%2Fdevopsansible","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjavadtorabikh%2Fdevopsansible/lists"}