Skip to content

lj020326/ansible-datacenter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

849 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Datacenter Wiki

This repository provides a site.yml playbook to configure a multi-OS datacenter (Ubuntu/CentOS/Debian and Windows).

Table of Contents

CI Status

CI

Note: The badge above tracks the main branch. To track a feature branch, update the URL to .../verify_all_green.yml/badge.svg?branch=<your-branch-name>.


Linux OS Platform Molecule Tests

What is Molecule?

Molecule is a testing framework designed to aid in the development and testing of Ansible roles. It allows you to automatically spin up instances (containers or VMs), run your playbooks against them, and verify that the system state is correct.

In this repo, Molecule is used to:

  • Define multi-platform test scenarios in molecule.yml.
  • Perform isolated testing of key orchestration roles like bootstrap_linux.
  • Utilize systemd-enabled Docker images for realistic service testing.

For execution details, see the Molecule README.


Ansible Developer Environment

To bootstrap a local development environment, use the provided installer script. This prepares your system to run playbooks and execute Molecule tests.

Automated Setup

The installer performs the following:

  1. Creates $HOME/repos/ansible.
  2. Clones the ansible-developer repository.
  3. Synchronizes your bash environment with pre-configured scripts.
# Install from public GitHub
INSTALL_REMOTE_SCRIPT="https://raw.githubusercontent.com/lj020326/ansible-developer/main/install.sh"
bash -c "$(curl -fsSL ${INSTALL_REMOTE_SCRIPT})"

Summary

  • Automation Architectures: Collection of roles, playbooks, and modules.
  • Image Build Systems: Integration with Packer and vSphere.
  • Lifecycle Management: From OS hardening to application deployment and maintenance.

Priority Roles

All Roles by Category

Bootstrap & Foundation Roles

Networking & Security

Utility


Prerequisites

  1. Clone the repository:

    git clone https://github.com/lj020326/ansible-datacenter.git
  2. Install requirements:

    ansible-galaxy collection install -r ./collections/requirements.yml
    ansible-galaxy install -r ./roles/requirements.yml
  3. Configure Ansible Vault: This repository uses a vars/vault.yml file to store sensitive credentials and configuration data.

    Variable Convention

    To maintain clarity and prevent accidental exposure of plain-text variables, all variables stored within the vault MUST be prefixed with vault__.

    Required Vault Content

    Your vars/vault.yml should include, but is not limited to, the following categories of data:

    • Infrastructure Credentials: SSH passwords for Linux, Administrator passwords for Windows, and iDRAC/IPMI credentials.
    • Hypervisor Access: vCenter/ESXi passwords and associated license keys.
    • Network Secrets: RNDC keys for DNS updates and OMAPI keys for DHCP failover.
    • Cloud & API Integration: Cloudflare API keys and Google App passwords for SMTP relay.
    • Service Authentication: MySQL root passwords, LDAP admin credentials, and Docker Registry authentication.
    • Security Keys: Private RSA keys for admin access and JWT/OAuth secrets for application stacks (e.g., Gitea, Authelia).

    Creation Command

    # Create and encrypt the private variables file
    ansible-vault create vars/vault.yml

    Refer to vars/README.md for a comprehensive list of required variables and an example schema.

  4. Configure Inventory: Add host(s) to inventory hosts.yml and ping the host(s)

    ansible -i inventory/hosts.yml all -m ping -b -vvvv

Running Ansible Site Plays

Detailed instructions on how to run and test the ansible-datacenter site plays can be found in the documentation link below:


Jenkins Ansible Jobs

The orchestration and execution of the datacenter site playbook tags can be managed via Jenkins pipelines. Detailed instructions on job configuration, parameter initialization, and command-line wrappers for Jenkins-led execution can be found in the documentation link below:


Image Build Workflow

Image Build & Deployment Workflow

The infrastructure utilizes a standardized pipeline to move from code to a running virtual machine or container. This process is divided into two primary phases: Template Generation and Instance Deployment.

1. Image Template Generation (The "Baking" Phase)

This phase creates a gold image or container base that is hardened and pre-configured.

  • Orchestration: Packer initiates the build based on a specific spec, determining if the target is a Virtual Machine or a Container.
  • Base OS Installation: For VMs, the pipeline performs a clean OS installation of Ubuntu, Debian, or CentOS.
  • Ansible Provisioning: Once the base OS is ready, Ansible applies core roles (like bootstrap_linux) to harden the security profile and install baseline software.
  • Jenkins Automation: The buildVmTemplate function from the pipeline-automation-lib automates this entire process, handling the Packer execution and subsequent cleanup.

2. Instance Deployment (The "Running" Phase)

Once a template is verified and stored in the vSphere library or Docker registry, it is ready for deployment.

  • Playbook Execution: The standard site.yml playbook is utilized for deployment.
  • Targeting: Deployment is triggered using the deploy-vm tag, which instructs Ansible to clone the previously built template into a functional VM instance.
  • Post-Deployment: Following the initial clone, the pipeline continues with application-specific deployment and ongoing maintenance roles as defined in the automation lifecycle.

Documentation Source Reference

  • : README.md - Outlines the role of bootstrap_linux and general architecture.
  • : image-templates.md - Provides the Mermaid workflow diagram and repository links.
  • : buildVmTemplate.groovy - Details the Jenkins function used to invoke Packer and build templates.
  • : site.yml - Contains the primary orchestration logic and deployment tags.

The workflow to build a machine image (docker image or virtual machine template) leverages the Ansible bootstrap_linux role to set up the machine image before archival and distribution to the respective platform image manager (docker registry or VMware template library). It is custom to have this image build process performed regularly/periodically in order to enable an efficient provisioning process for creating container or virtual machine instances utilizing the most secure, modern versions and configuration:


Contributing & Support

  • Reporting Issues: Please use the GitHub Issues tab to report bugs or request features.
  • Pull Requests: Contributions are welcome. Please ensure all Molecule tests pass before submitting.
  • Contact: Connect with Lee James Johnson on LinkedIn.

Documentation Links

Releases

No releases published

Packages

 
 
 

Contributors