๐ฆ ANSAI Self-Healing - GitHub Packaging Guide¶
Overview¶
This guide covers packaging ANSAI Self-Healing components for distribution on GitHub, following ansai workflows and everything-as-code principles.
Repository Structure¶
The ANSAI repository includes self-healing components as an integrated module:
ansai/
โโโ orchestrators/
โ โโโ ansible/
โ โโโ roles/
โ โ โโโ universal_self_heal/
โ โ โโโ js_error_monitoring/
โ โ โโโ css_error_monitoring/
โ โ โโโ healthchecks_monitoring/
โ โโโ playbooks/
โ โ โโโ deploy-self-healing.yml
โ โ โโโ deploy-js-monitoring.yml
โ โ โโโ deploy-css-monitoring.yml
โ โ โโโ deploy-healthchecks.yml
โ โ โโโ deploy-complete-monitoring.yml
โ โโโ inventory/
โ โ โโโ hosts.yml.example
โ โโโ tests/
โ โโโ test-service-healing.sh
โ โโโ test-js-monitoring.sh
โ โโโ test-css-monitoring.sh
โ โโโ test-healthchecks.sh
โ โโโ run-all-tests.sh
โโโ docs/
โ โโโ self-healing/
โ โโโ index.md
โ โโโ UNIVERSAL_SELF_HEALING.md
โ โโโ JS_ERROR_MONITORING.md
โ โโโ CSS_ERROR_MONITORING.md
โ โโโ HEALTHCHECKS_SETUP.md
โ โโโ COMPLETE_MONITORING_STACK.md
โ โโโ TESTING_GUIDE.md
โ โโโ GITHUB_PACKAGING.md
โโโ .github/
โ โโโ workflows/
โ โโโ test-self-healing.yml
โ โโโ release-package.yml
โโโ README.md
โโโ LICENSE
โโโ CONTRIBUTING.md
Pre-Packaging Checklist¶
1. Code Quality¶
- All roles follow Ansible best practices
- Variables are well-documented
- No hardcoded credentials
- Example configurations provided
- Scripts are POSIX-compliant where possible
2. Documentation¶
- README.md is comprehensive
- Each role has defaults/main.yml documented
- Deployment guides are complete
- Architecture diagrams included
- Troubleshooting sections present
3. Testing¶
- All test scripts pass
- Integration tests successful
- Clean deployment tested
- Upgrade path tested
- Rollback tested
4. Security¶
- No secrets in repository
- Example files use placeholders
- SSH keys excluded
- .gitignore properly configured
- Sensitive paths documented
5. Licensing¶
- LICENSE file present (MIT recommended)
- Copyright notices in files
- Third-party licenses acknowledged
- CONTRIBUTING.md guidelines
Packaging Steps¶
Step 1: Final Code Review¶
cd ~/ansai
# Check for sensitive data
git grep -i "password\|secret\|token\|api_key" orchestrators/ansible/
# Verify .gitignore
cat .gitignore
# Check for large files
find . -type f -size +10M
Step 2: Update Version Information¶
Update version in key files:
README.md:
docs/self-healing/index.md:
Step 3: Tag Release¶
cd ~/ansai
# Create annotated tag
git tag -a v1.0.0 -m "Release v1.0.0 - ANSAI Self-Healing Infrastructure
Features:
- Universal service self-healing with email alerts
- JavaScript error monitoring (static + runtime)
- CSS error monitoring and validation
- External monitoring via Healthchecks.io
- Comprehensive testing suite
- Production-ready documentation
Tested on:
- Red Hat Enterprise Linux 9
- Fedora 42
- Rocky Linux 9"
# Push tag to GitHub
git push origin v1.0.0
Step 4: Create GitHub Release¶
-
Go to
https://github.com/YOUR_USERNAME/ansai/releases/new -
Select tag:
v1.0.0 -
Release title:
ANSAI Self-Healing Infrastructure v1.0.0 -
Release notes:
# ๐ก๏ธ ANSAI Self-Healing Infrastructure v1.0.0
## Production-Ready Self-Healing System
The first stable release of ANSAI's self-healing infrastructure brings automated monitoring, remediation, and alerting to your Ansible-managed systems.
## ๐ฏ Key Features
### Universal Service Healing
- Automatic service restart with intelligent retry logic
- Port conflict detection and resolution
- Configuration validation before restart
- Database health checks and repair
- Detailed email alerts explaining fixes
### JavaScript Error Monitoring
- Static template syntax validation
- Runtime error capture from browsers
- Automatic aggregation and alerting
- Integration with any Flask/Python web app
### CSS Error Monitoring
- Missing CSS file detection
- Syntax validation
- Runtime loading failure detection
- Proactive alerts before user impact
### External Monitoring
- Healthchecks.io integration
- Dead man's switch for server failures
- Heartbeat reporting for all services
- Multiple notification channels
## ๐ฆ Installation
```bash
git clone https://github.com/YOUR_USERNAME/ansai.git
cd ansai/orchestrators/ansible
ansible-playbook playbooks/deploy-complete-monitoring.yml
๐งช Testing¶
Comprehensive test suite included:
๐ Documentation¶
๐ง System Requirements¶
- Ansible 2.9+
- Target system with systemd
- Python 3.6+
- SMTP server for email alerts
- SSH access to target hosts
๐ Known Issues¶
None! This is a production-ready release.
๐ What's Next¶
Roadmap for v2.0: - System admin self-healing (disk, memory, updates) - Automatic certificate renewal - Database optimization automation - Network health monitoring - Security audit automation
๐ค Contributing¶
Contributions welcome! See CONTRIBUTING.md
๐ License¶
MIT License - See LICENSE
Built with ANSAI Everything-as-Code Philosophy ๐
Infrastructure that heals itself
5. Attach release artifacts:
- `ansai-self-healing-v1.0.0.tar.gz` (optional, GitHub creates automatically from tag)
### Step 5: Update ansai.dev
```bash
cd ~/ansai
# Build and deploy documentation
mkdocs build
mkdocs gh-deploy
# Or manually deploy to ansai.dev
rsync -avz site/ [email protected]:/var/www/ansai.dev/
GitHub Actions Workflows¶
Automated Testing Workflow¶
File: .github/workflows/test-self-healing.yml
name: Test Self-Healing Components
on:
push:
branches: [ main, develop ]
paths:
- 'orchestrators/ansible/roles/**'
- 'orchestrators/ansible/playbooks/**'
- 'orchestrators/ansible/tests/**'
pull_request:
branches: [ main ]
jobs:
syntax-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Ansible
run: |
pip install ansible ansible-lint
- name: Ansible Syntax Check
run: |
cd orchestrators/ansible
ansible-playbook playbooks/*.yml --syntax-check
- name: Ansible Lint
run: |
cd orchestrators/ansible
ansible-lint playbooks/*.yml
shellcheck:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: './orchestrators/ansible/tests'
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install MkDocs
run: |
pip install mkdocs-material mkdocs-git-revision-date-localized-plugin
- name: Build Documentation
run: mkdocs build --strict
- name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main'
run: mkdocs gh-deploy --force
Automated Release Workflow¶
File: .github/workflows/release-package.yml
name: Create Release Package
on:
push:
tags:
- 'v*'
jobs:
create-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Release Archive
run: |
tar -czf ansai-self-healing-${{ github.ref_name }}.tar.gz \
orchestrators/ansible/roles \
orchestrators/ansible/playbooks \
orchestrators/ansible/tests \
orchestrators/ansible/inventory/hosts.yml.example \
docs/self-healing \
LICENSE \
README.md
- name: Generate Release Notes
id: release_notes
run: |
echo "## Release Notes" > RELEASE_NOTES.md
git log $(git describe --tags --abbrev=0 HEAD^)..HEAD --pretty=format:"- %s (%h)" >> RELEASE_NOTES.md
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
body_path: RELEASE_NOTES.md
files: |
ansai-self-healing-${{ github.ref_name }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Distribution Methods¶
1. GitHub Repository (Recommended)¶
URL: https://github.com/YOUR_USERNAME/ansai
Install:
git clone https://github.com/YOUR_USERNAME/ansai.git
cd ansai/orchestrators/ansible
ansible-playbook playbooks/deploy-complete-monitoring.yml
Update:
cd ansai
git pull origin main
cd orchestrators/ansible
ansible-playbook playbooks/deploy-complete-monitoring.yml
2. Ansible Galaxy (Future)¶
Namespace: ansai.self_healing
Install:
Playbook:
3. Direct Download¶
Release tarball:
curl -LO https://github.com/YOUR_USERNAME/ansai/archive/v1.0.0.tar.gz
tar -xzf v1.0.0.tar.gz
cd ansai-1.0.0/orchestrators/ansible
Version Management¶
Semantic Versioning¶
ANSAI Self-Healing follows semantic versioning:
- MAJOR (1.x.x): Breaking changes
- MINOR (x.1.x): New features, backward compatible
- PATCH (x.x.1): Bug fixes, backward compatible
Version Branches¶
main: Stable releases onlydevelop: Active developmentfeature/*: New featuresfix/*: Bug fixesrelease/*: Release candidates
Changelog¶
Maintain CHANGELOG.md:
# Changelog
## [1.0.0] - 2025-11-18
### Added
- Universal service self-healing with email alerts
- JavaScript error monitoring (static + runtime)
- CSS error monitoring and validation
- External monitoring via Healthchecks.io
- Comprehensive testing suite
- Full documentation on ansai.dev
### Changed
- N/A (initial release)
### Fixed
- N/A (initial release)
Post-Release Tasks¶
- Announce release:
- Update ansai.dev homepage
- Post on social media
-
Update README badges
-
Monitor feedback:
- Watch GitHub issues
- Respond to questions
-
Track adoption metrics
-
Plan next release:
- Review feature requests
- Prioritize roadmap
- Schedule development
Support Channels¶
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: Questions and community support
- Documentation: https://ansai.dev/self-healing/
- Email: [email protected] (if applicable)
Following ANSAI Everything-as-Code Philosophy ๐
Package once, deploy everywhere