Skip to content

Conversation

@morey-tech
Copy link
Owner

Summary

This PR adds complete Ansible module support for managing HAProxy frontends and frontend servers (bind addresses/ports) in pfSense.

This implementation is based on the original work from @cosmosified in the upstream PR #1, with all requested changes from the code review incorporated.

Changes

New Ansible Modules

  • pfsense_haproxy_frontend - Manage HAProxy frontend configurations
  • pfsense_haproxy_frontend_server - Manage HAProxy frontend bind addresses and ports

Module Utils

  • haproxy_frontend.py - Core module utilities for frontend management
  • haproxy_frontend_server.py - Core module utilities for frontend server management

Metadata Updates

  • Added Chris Morton to galaxy.yml authors list
  • Added macOS .DS_Store entry to .gitignore

Implementation Details

Module Design

  • Follows existing backend module patterns for consistency
  • Primary identifiers (name, frontend) are required=True
  • All configuration fields are required=False for flexible deletion operations
  • Supports state: present/absent for idempotent management
  • Full check mode support included

Documentation

  • Comprehensive parameter documentation for all options
  • Usage examples for common operations (create, delete)
  • Proper return value documentation

Version

  • Set version_added: 0.2.0 for both new modules (next minor release)

Code Review Changes Addressed

All feedback from PR #1 has been implemented:

  • ✅ Copyright year updated to 2025
  • ✅ Version set to 0.2.0 as requested
  • ✅ Required field logic corrected (only primary keys required)
  • ✅ Author attribution properly formatted

Testing

The modules follow the established patterns from pfsense_haproxy_backend and pfsense_haproxy_backend_server, ensuring consistency with existing functionality.

Suggested test scenarios:

  • Create frontend with full configuration
  • Delete frontend using only name + state=absent
  • Add frontend server binding (address:port)
  • Remove frontend server binding with minimal parameters
  • Verify check mode operation

Related

@morey-tech morey-tech marked this pull request as draft December 16, 2025 22:20
- Add haproxy_frontend module for managing pfSense HAProxy frontends
- Add haproxy_frontend_server module for managing frontend servers
- Add Chris Morton to authors in galaxy.yml
- Add macOS .DS_Store to .gitignore
Add complete Ansible module implementation for HAProxy frontends and
frontend servers with corrected required field logic.

Module Utils Changes:
- Update copyright year to 2025 in haproxy_frontend.py
- Update copyright year to 2025 in haproxy_frontend_server.py
- Change required=True to required=False for non-primary-key fields
  (status, desc, extaddr, extaddr_port, extaddr_ssl)
- Only primary identifiers remain required (name, frontend)

New Ansible Modules:
- Add pfsense_haproxy_frontend module for managing HAProxy frontends
- Add pfsense_haproxy_frontend_server module for managing bind addresses
- Set version_added to 0.2.0 for new release
- Include comprehensive documentation and examples
- Follow existing backend module patterns for consistency

This allows deletion operations with minimal parameters (just state=absent
plus identifier) and maintains consistency with the existing backend
module architecture.

Addresses feedback from: pfsensible#1
@morey-tech morey-tech force-pushed the feature/add_haproxy_frontend branch from 660510d to f8f34d1 Compare December 17, 2025 00:27
- Fix PEP8 formatting errors in haproxy_frontend.py and haproxy_frontend_server.py
- Remove unused import and debug print statement in haproxy_frontend_server.py
- Install pfsensible.core dependency in workspace collection root for ansible-test
- Add shellcheck to devcontainer dependencies
- Add sanity test ignore file for devcontainer script shebang

All sanity tests now pass with zero warnings or errors.
Unit tests were failing due to missing community.internal_test_tools
collection. Added symlink in postCreate.sh to make the collection
accessible to ansible-test in the workspace directory structure.
Add pre-commit framework to run automated tests before commits:
- pycodestyle for Python style checking
- ansible-test sanity for module validation
- ansible-test units for unit tests

Pre-commit hooks are automatically installed during devcontainer setup
and provide fast local feedback matching CI checks.
Add dedicated pr-checks job that runs on pull requests:
- Matches pre-commit hooks (pycodestyle, sanity, units)
- Provides fast feedback (~5 min vs ~15 min full matrix)
- Rich test summaries with pass/fail status
- Can be configured as required status check

Updated build job:
- Skip on PRs (pr-checks handles PR validation)
- Upgrade to latest actions (v4, v5)
- Add test summaries for better visibility
- Separate sanity and units into distinct steps

Both jobs now provide consistent formatting and detailed
GitHub Actions summaries showing test results.
@morey-tech morey-tech marked this pull request as ready for review December 17, 2025 02:10
@morey-tech morey-tech merged commit 1d4dba6 into main Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants