Skip to content

Install task (https://taskfile.dev/) with Ansible - #165

Merged
bubacoder merged 1 commit into
mainfrom
feature/go-task
Jul 28, 2025
Merged

Install task (https://taskfile.dev/) with Ansible#165
bubacoder merged 1 commit into
mainfrom
feature/go-task

Conversation

@bubacoder

@bubacoder bubacoder commented Jul 28, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added automated installation of the go-task utility for Debian-based systems.
  • Chores

    • Updated task imports and privilege escalation settings for improved task organization and execution order in system setup.

@coderabbitai

coderabbitai Bot commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A new Ansible variable for the go-task version was introduced in the Debian group variables. A dedicated Ansible task file was added to automate the installation of go-task on Debian systems, including architecture detection and cleanup. The main Debian base task sequence was updated to import this new go-task installer and adjust import paths for other tasks.

Changes

Cohort / File(s) Change Summary
Debian Group Variables
ansible/inventory/group_vars/debian/vars.yaml
Added go_task_version variable set to "v3.44.1" with a reference comment to the go-task GitHub releases.
Go-task Installation Task
ansible/roles/debian_base/tasks/60-go-task.yaml
New task file to check for, download, install, and clean up the go-task utility, with architecture handling.
Debian Base Main Tasks
ansible/roles/debian_base/tasks/main.yaml
Updated import paths for Crowdsec and user configuration tasks; added import for new go-task installation task.

Sequence Diagram(s)

sequenceDiagram
    participant Ansible
    participant DebianHost

    Ansible->>DebianHost: Check if go-task is installed
    alt go-task not installed
        Ansible->>DebianHost: Create /tmp/go-task directory
        Ansible->>DebianHost: Detect system architecture
        Ansible->>DebianHost: Download go-task .deb package
        Ansible->>DebianHost: Install go-task package via apt
        Ansible->>DebianHost: Remove /tmp/go-task directory
    else go-task already installed
        Note right of DebianHost: Skip installation steps
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0100670 and 0d6c61c.

📒 Files selected for processing (3)
  • ansible/inventory/group_vars/debian/vars.yaml (1 hunks)
  • ansible/roles/debian_base/tasks/60-go-task.yaml (1 hunks)
  • ansible/roles/debian_base/tasks/main.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: bubacoder
PR: bubacoder/infra#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.
ansible/roles/debian_base/tasks/main.yaml (1)

Learnt from: bubacoder
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.

⏰ 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). (4)
  • GitHub Check: build-test-push (ubuntu, ubuntu:24.04)
  • GitHub Check: build-test-push (debian, debian:bookworm-slim)
  • GitHub Check: build
  • GitHub Check: check
🔇 Additional comments (8)
ansible/inventory/group_vars/debian/vars.yaml (1)

14-16: Avoid double-installing go-task (apt vs Homebrew).

go_task_version drives an apt-based install, while dev_brew_packages already lists go-task.
On hosts where Linuxbrew is enabled (linuxbrew_use_installer: true) the same binary can be installed twice, potentially yielding different versions and an unpredictable $PATH order.

Consider one of:

# Option A – keep only the native .deb installation
dev_brew_packages: "{{ dev_brew_packages | difference(['go-task']) }}"

# Option B – drop the .deb task when Homebrew is used
install_go_task_with_apt: "{{ not linuxbrew_use_installer }}"

and wrap the task import with when: install_go_task_with_apt.

[ suggest_essential_refactor ][ request_verification ]

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

16-18: Confirm renamed task file actually exists.

The import was changed to 50-crowdsec.yaml. Please ensure the file was renamed accordingly (case-sensitive on Linux) or the play will fail at runtime.

[ request_verification ]


19-22: Import guard missing for architectures we don’t package.

60-go-task.yaml is always imported, yet inside it task_arch may stay undefined if the host architecture isn’t one of armv7l|x86_64|aarch64.
Consider guarding the import:

- name: Install go-task
  when: ansible_architecture in ['armv7l', 'x86_64', 'aarch64']
  ansible.builtin.import_tasks: 60-go-task.yaml
  become: true

or have the task file assert a supported architecture early.

[ suggest_essential_refactor ]


24-26: Check that 70-user.yaml was really moved.

Similar to the previous comment: verify that the new path is committed; otherwise admin-user configuration will be skipped.

[ request_verification ]

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

1-7: Good idempotency check.

Using task --version with changed_when: false cleanly skips the whole block when task is already present. Nice touch.

[ approve_code_changes ]


15-29: task_arch may remain undefined – add a fallback or assert.

If the host architecture is anything other than armv7l, x86_64, or aarch64 (e.g. armv6l, ppc64le), later steps will fail with an undefined variable error.

+- name: Fail on unsupported architecture
+  ansible.builtin.fail:
+    msg: "Unsupported architecture {{ ansible_architecture }} for go-task"
+  when:
+    - task_version_check.rc != 0
+    - task_arch is not defined

[ raise_critical_issue ]


30-35: Download URL hard-codes .deb naming convention.

Upstream sometimes changes file naming (e.g. adding _static). Consider deriving the filename from the GitHub API or using releases/latest/download/task_linux_{{ task_arch }}.deb to avoid pinning the exact pattern per version.

[ suggest_optional_refactor ]


37-47: Temporary directory cleanup races with parallel runs.

Removing /tmp/go-task unconditionally can interfere with parallel playbook runs on the same host.
Prefer ansible.builtin.tempfile to create a unique directory and pass the path through set_fact, then remove that specific path.

[ suggest_optional_refactor ]

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/go-task

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@bubacoder
bubacoder merged commit 850ce14 into main Jul 28, 2025
6 checks passed
@bubacoder
bubacoder deleted the feature/go-task branch July 28, 2025 12:31
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