Skip to content

Refactor Debian Ansible role, add option to enable tool groups - #262

Merged
bubacoder merged 1 commit into
mainfrom
feature/debian-tools
Jan 22, 2026
Merged

Refactor Debian Ansible role, add option to enable tool groups#262
bubacoder merged 1 commit into
mainfrom
feature/debian-tools

Conversation

@bubacoder

@bubacoder bubacoder commented Jan 14, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • New dedicated developer tools installer with grouped package sets (common, dev, cloud, terraform, kubernetes) and conditional Homebrew/Cask installs.
  • Refactor

    • Namespaced inventory and package configuration for clearer tooling selection.
    • Playbooks reorganized to separate developer tools setup from Samba client setup and use the new tools role.
  • Chore

    • Updated CLI example and local setup documentation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Namespace many Ansible variables to debian_base_/debian_tools_/mac_base_*; replace role debian_developer with debian_tools; move and expand apt/Homebrew package lists; update playbooks, inventory, roles, and local docs to use new names and add aggregated Homebrew install groups for debian_tools.

Changes

Cohort / File(s) Summary
Script Usage Updates
ansible/apply-adhoc.sh
Example usage text updated: debian_developerdebian_tools.
Inventory — Debian vars
ansible/inventory/group_vars/debian/vars.yaml
Many vars renamed to debian_base_*; added debian_base_install_storage_packages, debian_base_apt_storage_packages; introduced debian_tools_apt_packages, debian_tools_brew_install_groups, and per-group debian_tools_brew_packages_* (common, dev, aws, azure, terraform, kubernetes).
Inventory — mac & top-level
ansible/inventory/group_vars/mac/vars.yaml, ansible/inventory/inventory.yaml
Brew vars renamed to mac_base_brew_*; enabled/added debian_tools_brew_install_groups flags on hive/nest/local-debian entries.
Playbooks
ansible/playbooks/cloud.yaml, ansible/playbooks/homelab.yaml
Replaced debian_developer with debian_tools; homelab split into a developer-tools play (nest,hive) and a separate Samba-client play (nest).
Role — debian_base tasks
ansible/roles/debian_base/tasks/* (10-apt.yaml, 40-network.yaml, 50-crowdsec.yaml, 60-go-task.yaml, 70-user.yaml, main.yaml)
Replaced variable references and when-conditions to debian_base_* equivalents (apt lists, hosts file flag, crowdsec api/key, go-task version, ssh key, install bouncer flag).
Role — debian_developer (removals)
ansible/roles/debian_developer/tasks/* (20-homebrew.yaml, main.yaml)
Removed Homebrew/Cask installation tasks and conditional import workflow that used dev_brew_* and dev_apt_packages.
Role — debian_tools (new)
ansible/roles/debian_tools/tasks/* (10-apt.yaml, 20-homebrew.yaml, main.yaml)
New role: apt task uses debian_tools_apt_packages; Homebrew task aggregates enabled debian_tools_brew_packages_* groups into debian_tools_brew_packages, debugs the list, then installs bottles and casks conditionally.
Role — mac_base Homebrew var rename
ansible/roles/mac_base/tasks/10-homebrew.yaml
Replaced brew_* variables with mac_base_brew_*; no control-flow changes.
Local dev & docs updates
.devcontainer/Dockerfile, Taskfile.yaml, docs/setup.md
Local host vars and docs updated to reference debian_base_* keys and debian_tools role; Taskfile comment updated.

Sequence Diagram(s)

sequenceDiagram
    rect rgba(30,144,255,0.5)
    Ansible Controller->>Inventory: read group_vars (debian/mac) & debian_tools_brew_install_groups
    end
    rect rgba(34,139,34,0.5)
    Ansible Controller->>Hosts: run playbooks (plays -> debian_tools, debian_base, debian_samba_client)
    end
    rect rgba(255,140,0,0.5)
    Hosts->>Apt: install packages from debian_base_apt_* / debian_tools_apt_packages
    Hosts->>Homebrew: aggregate enabled debian_tools_brew_packages_* → install bottles & casks if non-empty
    end
    rect rgba(199,21,133,0.5)
    Hosts->>LocalConfig: configure admin user, SSH, crowdsec, go-task using debian_base_* vars
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes: renaming the debian_developer role to debian_tools and adding configurable brew installation groups with flags.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/debian-tools

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@ansible/inventory/group_vars/debian/vars.yaml`:
- Around line 44-55: The debian_tools_apt_packages entry for "yq" is misleading:
the apt package is the Python kislyuk/yq, not mikefarah/yq; either update the
comment next to the "yq" list item to reference the correct kislyuk/yq project,
or remove the apt "yq" entry and instead add guidance to install mikefarah/yq
via Homebrew/snap/direct binary (or add a separate non-apt install step) if the
Go mikefarah/yq is required; locate the "debian_tools_apt_packages" list and
update the "yq" line accordingly.

In `@ansible/roles/debian_base/tasks/70-user.yaml`:
- Around line 11-15: The task "Set password for admin user '{{
debian_base_admin_user }}'" uses the undefined variable
debian_base_password_salt causing runtime failure; define
debian_base_password_salt alongside debian_base_admin_password in your
inventory/group vars (e.g., add debian_base_password_salt: "<your-salt>" in
ansible/inventory/group_vars/debian/vars.yaml or an encrypted vault) so the
password_hash filter has a salt, or alternatively update the task to use a
default salt via debian_base_password_salt|default('your-default-salt') if you
prefer an inline fallback.
🧹 Nitpick comments (5)
ansible/inventory/group_vars/mac/vars.yaml (1)

29-33: Consider migrating from tfsec to trivy.

The tfsec project has been consolidated into Trivy as part of Aqua Security's portfolio. While tfsec remains functional, trivy provides continued support and is the focus of ongoing development.

ansible/roles/debian_tools/tasks/20-homebrew.yaml (1)

23-31: Consider using state: present for idempotency.

Using state: latest will upgrade packages on every run if newer versions are available upstream, which may cause unintended changes and slower playbook execution. Consider state: present if you prefer idempotent runs, or keep latest if automatic upgrades are intentional.

Also applies to: 33-42

ansible/roles/debian_base/tasks/60-go-task.yaml (1)

15-28: Consider handling unsupported architectures.

The architecture detection sets debian_base_task_arch only for armv7l, x86_64, and aarch64. On other architectures, the variable remains undefined, which would cause the download task to fail with an unclear error. Consider adding a fallback or explicit failure with a descriptive message.

Example: Add explicit failure for unsupported architectures
- name: Fail on unsupported architecture
  ansible.builtin.fail:
    msg: "Unsupported architecture: {{ ansible_architecture }}. Supported: armv7l, x86_64, aarch64"
  when:
    - debian_base_task_version_check.rc != 0
    - ansible_architecture not in ['armv7l', 'x86_64', 'aarch64']
ansible/roles/debian_base/tasks/50-crowdsec.yaml (1)

34-40: Consider adding no_log: true to prevent API key exposure in logs.

The task writes a sensitive API key to the configuration file. Without no_log: true, the key value could be exposed in Ansible output logs.

🔒 Proposed fix
 - name: Set crowdsec api_key for iptables bouncer
   ansible.builtin.lineinfile:
     path: /etc/crowdsec/bouncers/crowdsec-firewall-bouncer.yaml
     regexp: "^api_key:"
     line: "api_key: {{ debian_base_crowdsec_local_api_key }}"
   when: debian_base_crowdsec_local_api_key|default('') != ''
   notify: Restart service crowdsec-firewall-bouncer
+  no_log: true
ansible/inventory/group_vars/debian/vars.yaml (1)

3-5: Consider moving sensitive/personal data to secret.yaml.

The admin email address is hardcoded here. While not strictly sensitive, you may want to keep all personal identifiers in one place for easier management.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2772c88 and 8510653.

📒 Files selected for processing (18)
  • ansible/apply-adhoc.sh
  • ansible/inventory/group_vars/debian/vars.yaml
  • ansible/inventory/group_vars/mac/vars.yaml
  • ansible/inventory/inventory.yaml
  • ansible/playbooks/cloud.yaml
  • ansible/playbooks/homelab.yaml
  • ansible/roles/debian_base/tasks/10-apt.yaml
  • ansible/roles/debian_base/tasks/40-network.yaml
  • ansible/roles/debian_base/tasks/50-crowdsec.yaml
  • ansible/roles/debian_base/tasks/60-go-task.yaml
  • ansible/roles/debian_base/tasks/70-user.yaml
  • ansible/roles/debian_base/tasks/main.yaml
  • ansible/roles/debian_developer/tasks/20-homebrew.yaml
  • ansible/roles/debian_developer/tasks/main.yaml
  • ansible/roles/debian_tools/tasks/10-apt.yaml
  • ansible/roles/debian_tools/tasks/20-homebrew.yaml
  • ansible/roles/debian_tools/tasks/main.yaml
  • ansible/roles/mac_base/tasks/10-homebrew.yaml
💤 Files with no reviewable changes (2)
  • ansible/roles/debian_developer/tasks/20-homebrew.yaml
  • ansible/roles/debian_developer/tasks/main.yaml
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

YAML files must pass YAML linting and validation

Files:

  • ansible/roles/debian_tools/tasks/10-apt.yaml
  • ansible/roles/debian_tools/tasks/20-homebrew.yaml
  • ansible/roles/debian_base/tasks/main.yaml
  • ansible/roles/debian_base/tasks/40-network.yaml
  • ansible/roles/debian_base/tasks/50-crowdsec.yaml
  • ansible/roles/debian_tools/tasks/main.yaml
  • ansible/playbooks/cloud.yaml
  • ansible/roles/debian_base/tasks/10-apt.yaml
  • ansible/inventory/group_vars/mac/vars.yaml
  • ansible/playbooks/homelab.yaml
  • ansible/roles/mac_base/tasks/10-homebrew.yaml
  • ansible/roles/debian_base/tasks/70-user.yaml
  • ansible/roles/debian_base/tasks/60-go-task.yaml
  • ansible/inventory/inventory.yaml
  • ansible/inventory/group_vars/debian/vars.yaml
ansible/**/*.{yaml,yml}

📄 CodeRabbit inference engine (AGENTS.md)

Ansible playbooks and roles must pass Ansible linting

Files:

  • ansible/roles/debian_tools/tasks/10-apt.yaml
  • ansible/roles/debian_tools/tasks/20-homebrew.yaml
  • ansible/roles/debian_base/tasks/main.yaml
  • ansible/roles/debian_base/tasks/40-network.yaml
  • ansible/roles/debian_base/tasks/50-crowdsec.yaml
  • ansible/roles/debian_tools/tasks/main.yaml
  • ansible/playbooks/cloud.yaml
  • ansible/roles/debian_base/tasks/10-apt.yaml
  • ansible/inventory/group_vars/mac/vars.yaml
  • ansible/playbooks/homelab.yaml
  • ansible/roles/mac_base/tasks/10-homebrew.yaml
  • ansible/roles/debian_base/tasks/70-user.yaml
  • ansible/roles/debian_base/tasks/60-go-task.yaml
  • ansible/inventory/inventory.yaml
  • ansible/inventory/group_vars/debian/vars.yaml
**/*.sh

📄 CodeRabbit inference engine (AGENTS.md)

Shell scripts must pass ShellCheck validation

Files:

  • ansible/apply-adhoc.sh
🧠 Learnings (2)
📚 Learning: 2025-01-25T11:16:21.899Z
Learnt from: bubacoder
Repo: bubacoder/infra PR: 89
File: ansible/bootstrap-ansible.sh:23-24
Timestamp: 2025-01-25T11:16:21.899Z
Learning: In the bootstrap-ansible.sh script, the `--ignore-installed` flag is only needed for pip installations on Ubuntu to fix PyYAML conflicts. The Debian installation works fine without this flag.

Applied to files:

  • ansible/roles/debian_base/tasks/10-apt.yaml
  • ansible/inventory/inventory.yaml
  • ansible/inventory/group_vars/debian/vars.yaml
📚 Learning: 2025-11-26T20:10:59.672Z
Learnt from: CR
Repo: bubacoder/infra PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T20:10:59.672Z
Learning: Use Ansible for infrastructure configuration management

Applied to files:

  • ansible/roles/debian_base/tasks/70-user.yaml
  • ansible/inventory/inventory.yaml
🧬 Code graph analysis (2)
ansible/roles/debian_tools/tasks/20-homebrew.yaml (1)
ansible/bootstrap-ansible.sh (3)
  • install_ansible_on_macos (67-74)
  • install_ansible_on_ubuntu (15-26)
  • install_ansible_on_debian (28-65)
ansible/roles/debian_tools/tasks/main.yaml (1)
ansible/bootstrap-ansible.sh (3)
  • install_ansible_on_macos (67-74)
  • install_ansible_on_ubuntu (15-26)
  • install_ansible_on_debian (28-65)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: check
🔇 Additional comments (27)
ansible/roles/mac_base/tasks/10-homebrew.yaml (2)

30-32: LGTM! Variable references align with the new naming convention.

The variable names correctly match the definitions in vars.yaml. The concatenation of tool lists is clear and maintainable.

Note: state: latest can cause non-idempotent behavior (tasks may report changes even when packages are already up-to-date). This is pre-existing behavior, but consider using state: present if idempotency is important for your workflow.


34-38: LGTM! Cask packages variable correctly renamed.

The reference to mac_base_brew_cask_packages aligns with the new namespace convention.

ansible/inventory/group_vars/mac/vars.yaml (4)

3-17: LGTM! Well-organized base tools list with consistent naming.

The mac_base_brew_base_tools variable follows the new namespace convention. The inline documentation URLs are a nice touch for maintainability.


19-26: LGTM! Cloud tools properly namespaced.

The categorization by cloud provider (AWS, Azure, Generic) with inline comments is clear and maintainable.


36-43: LGTM! Kubernetes tools properly namespaced.

Good selection of K8s ecosystem tools with helpful documentation links.


45-48: LGTM! Cask packages properly namespaced.

The mac_base_brew_cask_packages variable aligns with the new naming convention.

ansible/apply-adhoc.sh (1)

7-7: LGTM!

The usage example is correctly updated to reflect the role rename from debian_developer to debian_tools.

ansible/roles/debian_tools/tasks/20-homebrew.yaml (1)

3-14: LGTM!

The dynamic package list construction using set_fact with conditional ternary operators is clean. The defensive defaults (| default(false) for flags, | default([]) for lists) ensure graceful handling when variables are undefined.

ansible/roles/debian_tools/tasks/10-apt.yaml (1)

2-6: LGTM!

The variable rename to debian_tools_apt_packages aligns with the consistent namespace convention introduced in this PR.

Consider adding a | default([]) fallback if this task should be a no-op when the variable is undefined, rather than failing.

ansible/roles/debian_base/tasks/60-go-task.yaml (1)

30-35: LGTM!

The variable rename to debian_base_go_task_version with an inline default follows the namespace convention and provides a safe fallback.

ansible/roles/debian_base/tasks/main.yaml (1)

14-17: Variable rename is correct; task structure is already compliant with ansible-lint conventions.

The rename to debian_base_install_crowdsec_bouncer aligns with the namespace convention. The task structure is correct: namewhenmodulebecome follows ansible-lint's key-order rule and matches Ansible conventions. No changes needed.

ansible/playbooks/cloud.yaml (1)

7-10: LGTM!

The role rename from debian_developer to debian_tools is consistent with the PR's refactoring objectives. The role ordering is appropriate—markosamuli.linuxbrew is positioned before debian_tools, which is correct since debian_tools may depend on Homebrew for package installation.

ansible/roles/debian_base/tasks/50-crowdsec.yaml (1)

26-32: LGTM!

The variable renames to debian_base_crowdsec_local_api_url and debian_base_crowdsec_local_api_key are consistent with the new naming convention. The conditional logic correctly ensures the bouncer service is only enabled when both the API URL and key are configured.

Also applies to: 42-49

ansible/roles/debian_base/tasks/10-apt.yaml (1)

32-41: LGTM!

The variable renames to debian_base_apt_packages, debian_base_apt_storage_packages, and debian_base_install_storage_packages are consistent with the new naming convention. The boolean filter chain | default(false) | ansible.builtin.bool correctly handles undefined variables.

ansible/roles/debian_tools/tasks/main.yaml (1)

1-10: LGTM!

The task structure is well-organized:

  • import_tasks (static) for apt packages ensures they're always processed
  • include_tasks (dynamic) for Homebrew with a conditional gate is appropriate for optional functionality

The when condition correctly triggers Homebrew installation if either debian_tools_brew_install_groups or debian_tools_brew_cask_packages is defined, providing flexibility for different configurations.

ansible/roles/debian_base/tasks/40-network.yaml (1)

8-11: LGTM!

The variable rename to debian_base_configure_hosts_file is consistent with the new naming convention. The boolean filter chain correctly handles undefined variables with a safe default of false.

ansible/inventory/inventory.yaml (3)

24-25: LGTM!

The debian_tools_brew_install_groups configuration for hive correctly overrides the default (false) for the kubernetes group only. This aligns with the group definitions in vars.yaml.


28-33: LGTM!

The variable renaming to debian_base_ prefix is consistent with the refactoring across the codebase. The crowdsec configuration and storage packages flag follow the new naming convention.


35-42: LGTM!

The full brew install groups configuration for nest enables all tool categories. This structure matches the defaults defined in vars.yaml and provides clear per-host customization.

ansible/playbooks/homelab.yaml (1)

17-29: LGTM!

The refactoring cleanly separates concerns:

  • markosamuli.linuxbrew installs Homebrew first
  • debian_tools installs the configured tool packages
  • debian_samba_client is now a separate play targeting only nest

This modular structure improves maintainability and allows different hosts to opt into different tool groups via inventory configuration.

ansible/roles/debian_base/tasks/70-user.yaml (3)

2-9: LGTM!

User creation task correctly uses the new debian_base_ prefixed variables. The task structure and parameters are appropriate.


17-31: LGTM!

SSH key configuration block correctly uses the new variable names. The ansible.builtin.bool filter usage on line 18 is the modern fully-qualified form.


33-48: LGTM!

Git global config task correctly uses the renamed variables. The become_user properly switches to the admin user for setting user-scoped git configuration.

ansible/inventory/group_vars/debian/vars.yaml (4)

20-33: LGTM!

The base apt packages list is well-organized with sections and helpful URL comments. Good documentation practice.


35-42: LGTM!

Storage packages are properly gated behind debian_base_install_storage_packages flag, making them opt-in. The package selection is appropriate for storage management tasks.


57-66: LGTM!

The brew install groups structure provides a clean opt-in pattern. All groups default to false, allowing per-host customization in the inventory. This is a flexible and maintainable approach.


68-102: LGTM!

Package group definitions are well-organized by category with helpful URL comments. The note about kubectl being managed by asdf (line 98) is a good clarification to prevent duplicate installations.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread ansible/inventory/group_vars/debian/vars.yaml
Comment thread ansible/roles/debian_base/tasks/70-user.yaml Outdated
@bubacoder
bubacoder force-pushed the feature/debian-tools branch 4 times, most recently from 03cfbc4 to 123536f Compare January 21, 2026 17:53
@bubacoder
bubacoder force-pushed the feature/debian-tools branch from 123536f to d5cfe3e Compare January 21, 2026 20:22
@bubacoder
bubacoder merged commit e4b37db into main Jan 22, 2026
7 of 10 checks passed
@bubacoder
bubacoder deleted the feature/debian-tools branch January 22, 2026 16:41
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.

1 participant