Skip to content

Added new packages and cleaned up the var files for Ansible#34

Open
Defilan wants to merge 1 commit intomainfrom
CPM/adding_ghostty_skaffold
Open

Added new packages and cleaned up the var files for Ansible#34
Defilan wants to merge 1 commit intomainfrom
CPM/adding_ghostty_skaffold

Conversation

@Defilan
Copy link
Owner

@Defilan Defilan commented Aug 21, 2025

🚀 Refactor Ansible Package Organization for Better Maintainability

Summary

This PR refactors the Ansible vars file to eliminate package duplication and improve maintainability by introducing a hierarchical package organization system.

�� Changes Made

Package Structure Refactor

  • Eliminated Duplication: Removed ~60 lines of duplicated package definitions between developer and home configurations
  • Introduced Shared Packages: Created shared_packages section containing all packages common to both developer and home configs
  • Configuration-Specific Additions: config_packages now only contains unique additions for each configuration

Package Organization

  • Shared Packages (Developer + Home):
    • Homebrew taps: aws/tap, hashicorp/tap, twilio/brew
    • Development tools: neovim, tmux, git-extras, go, kubectl, terraform, node, redis, etc.
    • Core applications: arc, iterm2, visual-studio-code, 1password, docker, postman, etc.
  • Developer Config: Clean development environment (shared packages only)
  • Home Config: Full productivity setup (shared packages + entertainment/communication apps)
  • Lightweight Config: Minimal essentials only

Tasks File Improvements

  • Robust Config Handling: Added proper error handling and validation for config variables
  • Automatic Package Merging: Uses Ansible's combine filter to merge shared and config-specific packages
  • Better Error Messages: Clear validation messages when invalid configs are provided
  • Debug Output: Shows which configuration is being used

Documentation Updates

  • Comprehensive README: Updated with complete package lists organized by configuration
  • Alphabetical Ordering: All package lists now in alphabetical order for easier maintenance
  • Clear Configuration Descriptions: Users can now make informed decisions about which config to choose

🎯 Benefits

  1. Maintainability: Add new development tools to shared_packages once, available in both dev and home configs
  2. Consistency: Ensures both configurations always have the same base packages
  3. Reduced File Size: Eliminated significant duplication while maintaining functionality
  4. Better UX: Clear configuration choices with transparent package lists
  5. Professional Structure: Alphabetical ordering and clean organization

🧪 Testing

  • ✅ All three configurations work correctly
  • ✅ Package merging functions as expected
  • ✅ Error handling works for invalid configs
  • ✅ Install script integration maintained

📝 Configuration Options

  • Lightweight: Essentials only (1password, arc, istat-menus, iterm2, rectangle)
  • Developer: Clean development environment (all shared packages)
  • Home: Full productivity setup (shared packages + discord, gimp, krisp, microsoft-office, nordvpn, signal)

This refactor makes the dotfiles much more maintainable while preserving all existing functionality and improving the user experience.

@sonarqubecloud
Copy link

@Defilan Defilan requested a review from Copilot August 21, 2025 07:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the Ansible vars structure to eliminate package duplication and improve maintainability by introducing shared packages common across configurations. It centralizes approximately 60 lines of duplicated package definitions into a shared section while maintaining configuration-specific customizations.

  • Introduced shared_packages containing common packages for all configurations
  • Streamlined config_packages to only contain configuration-specific additions
  • Enhanced task validation and error handling with proper config validation and package merging

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
defilan-osconfig/roles/defilan-osconfig/vars/main.yml Restructured package organization with shared packages and streamlined config-specific packages
defilan-osconfig/roles/defilan-osconfig/tasks/main.yml Added config validation, package merging logic, and improved error handling
README.md Updated documentation with comprehensive package lists organized by configuration type

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

- iterm2
- visual-studio-code
- 1password
- rectangle
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 'lightweight' configuration overrides shared packages by redefining the same packages (1password, arc, istat-menus, iterm2, rectangle). This defeats the purpose of the shared_packages refactor. Consider removing these duplicated packages from the lightweight config since they're already in shared_packages.

Copilot uses AI. Check for mistakes.
- name: Set config variable with default
set_fact:
config: "{{ lookup('env', 'config') }}"
config: "{{ config | default('home') }}"
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line overwrites any existing 'config' variable with the default value if it's undefined. However, if 'config' is already defined (e.g., from environment or playbook vars), the 'default' filter won't apply and this task becomes redundant. Consider using 'when: config is not defined' condition or checking if the variable exists first.

Suggested change
config: "{{ config | default('home') }}"
config: "{{ config | default('home') }}"
when: config is not defined

Copilot uses AI. Check for mistakes.
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