Make inventory_path and playbook_path mandatory when enabled is true#3
Make inventory_path and playbook_path mandatory when enabled is true#3
Conversation
…abled is true Co-authored-by: alvagante <283804+alvagante@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This pull request modifies the Ansible integration validation logic to make inventory_path and playbook_path parameters mandatory only when the integration is enabled (enabled = true). Previously, these parameters were always required regardless of the enabled state, which caused unnecessary failures when the integration was disabled.
Changes:
- Modified parameter validation in
manifests/integrations/ansible.ppto conditionally requireinventory_pathandplaybook_pathonly when$enabledis true - Updated error messages to clarify that paths are required specifically when enabled is true
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Validate required parameters when integration is enabled | ||
| if $enabled { | ||
| unless $inventory_path { | ||
| fail('pabawi::integrations::ansible: inventory_path is required when enabled is true') | ||
| } | ||
| unless $playbook_path { | ||
| fail('pabawi::integrations::ansible: playbook_path is required when enabled is true') | ||
| } | ||
| } |
There was a problem hiding this comment.
The validation logic is correct for when enabled is true, but there's a related issue elsewhere in the file: when enabled is false and inventory_path is undef, the code at line 78-80 will fail if inventory_source is provided (dirname will be called on undef), and line 119 will write an empty ANSIBLE_INVENTORY_PATH to .env. Consider either: (1) also validating inventory_path and playbook_path are not set when enabled is false if inventory_source or playbook_source are provided, or (2) wrapping the git clone blocks (lines 78-93 and 96-111) with an additional enabled check to prevent cloning when the integration is disabled.
When
enabled = true, the Ansible integration silently acceptedundefforinventory_pathandplaybook_path, writing empty values to.envand skipping cloning without any error.Changes
manifests/integrations/ansible.pp: Added a conditional validation block — when$enabledistrue, both$inventory_pathand$playbook_pathmust be set; fails fast with a clear message if either is missing. When$enabledisfalse, no paths are required.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.