Ansible Playbook Development and Execution Workflow

Workstation Configuration

  1. Enable Windows Subsystem for Linux (WSL)
  2. Install Linux Distribution (Ubuntu)
  3. Install Ansible Inside WSL
  4. Install ansible-Lint Inside WSL
  5. Install VS Code and Ansible Extension
  6. Connect VS Code to WSL

Top 4 Tools Required

  1. Ansible-Playbook (Syntax Check)
  2. Ansible-Lint
  3. Yamllint
  4. Ansible-Playbook --Check (Dry Run)

1. Ansible-Playbook (Syntax Check)

ansible-playbook playbook.yml --syntax-check

Purpose:

  • Validates YAML Structure
  • Catches Parsing Errors
  • Ensures Playbook can Load

2. Ansible-Lint

ansible-lint playbook.yml
ansible-lint .
ansible-lint playbook1.yml playbook2.yml
ansible-lint -v playbook.yml
ansible-lint -q playbook.yml

Execution Location:

  • WSL (Linux environment)
  • Ansible Control Node
  • Linux VM

Purpose:

  • Enforces Best Practices
  • Detects Non-Idempotent Tasks
  • Flags Deprecated Modules
  • Identifies Risky Patterns

3. Yamllint

yamllint playbook.yml
yamllint .
yamllint -q playbook.yml

Purpose:

  • Checks Indentation
  • Ensures Formatting Consistency
  • Detects YAML-Specific Issues

4. Ansible-Playbook (Dry Run)

ansible-playbook playbook.yml --check

Purpose:

  • Simulates Execution
  • Identifies Logical Issues
  • Detects Missing Dependencies

Workflow

1. Authenticate to GitHub

The user authenticates to GitHub using personal or corporate credentials.

In Enterprise Environments, Personal Accounts are Commonly Used Because:

  • Avoids shared or generic accounts
  • Enables user-level access control
  • Allows easy revocation of access
  • Improves auditing and accountability

Access is Controlled Through:

  • Repository permissions
  • Organization membership
  • Team-based access control

2. Clone Repository

git clone <repository-url>

The repository is cloned locally or opened in VS Code.

3. Create New Playbook Version

The user copies an existing validated playbook and saves it under a new name to preserve the original and create a working version.

4. Modify Playbook

Updates Include:

  • Network configuration
  • Domain join configuration
  • OU placement
  • Server roles and features
  • Security hardening
  • Monitoring and agent installation

5. Validate Playbook

ansible-playbook playbook.yml --syntax-check
yamllint playbook.yml
ansible-lint playbook.yml
ansible-playbook playbook.yml --check

Ensures:

  • Valid Syntax
  • Proper Formatting
  • Best Practices Compliance
  • Correct Task Sequencing

6. Commit and Push Changes

git add .
git commit -m "Updated playbook"
git push origin <branch>

This updates the GitHub repository (source of truth).

7. Authenticate to Ansible Tower

The User Logs into Ansible Tower via the Web Interface.

8. Project Sync

The User Navigates to the Project and Initiates a Sync.

Operational Behavior:

Git Pull → Updates local project copy on Tower

This ensures the Latest Playbooks are Available.

9. Select and Launch Job Template

The Job Template defines:

  • Project
  • Playbook
  • Inventory
  • Credentials
  • Variables

The User Clicks Launch to Start Execution.

10. Execute Playbook

Tower → Execution Node
Execution Node → ansible-playbook

The Playbook is Executed against Target Systems.

11. Monitor Job Execution

The User Monitors:

  • Task Execution Output
  • stdout Logs
  • Success / Failure Status
  • Host-Level Results

12. Post-Execution Verification

The User Verifies:

  • Server Accessibility
  • Successful Domain Join
  • Correct OU Placement
  • Installed Roles and Features
  • Active Security and Monitoring Tools

Key Operational Principles

  • Use Git (Clone, Commit, Push)
  • Never overwrite Validated Playbooks
  • Always Validate Before Push
  • Use Project Sync to Update Tower
  • Use Job Templates for consistency
  • Maintain Proper Task Sequencing

Summary

Clone Modify Validate Commit Push Sync Launch Monitor Verify

Final Monitoring Statement (Refined)

After launching the Job Template, the User Monitors execution within Ansible Tower through the Web Interface. The platform provides Real-Time Visibility into Task Execution, detailed Logs (stdout), and Final Job Status, allowing the User to Confirm Success or Identify Failures.

0 comments

Leave a comment

Please note, comments need to be approved before they are published.