Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions roles/internal/mise/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# File: roles/mise/tasks/main.yml
---
- name: Ensure curl is installed
apt:
name: curl
state: present
update_cache: yes

- name: Create apt keyrings directory
file:
path: /etc/apt/keyrings
state: directory
mode: '0755'

- name: Download mise GPG key
get_url:
url: https://mise.jdx.dev/gpg-key.pub
dest: /etc/apt/keyrings/mise-archive-keyring.asc
mode: '0644'

- name: Add mise apt repository
apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.asc] https://mise.jdx.dev/deb stable main"
filename: mise
state: present

- name: Install mise
apt:
name: mise
state: present
update_cache: yes
Comment on lines +27 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The remove_mise role does not uninstall the mise apt package, leaving orphaned packages on systems that switch away from using mise.
Severity: LOW

Suggested Fix

Add a task to the internal/remove_mise role to uninstall the mise apt package using apt: name: mise state: absent. Also, consider adding a task to remove the mise apt repository to ensure a complete cleanup.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: roles/internal/mise/tasks/main.yml#L27-L31

Potential issue: When a host is configured to use `mise` and then later switched to a
different `ruby_manager`, the `internal/remove_mise` role is executed. However, this
role only removes user-specific configuration files and does not remove the system-wide
`mise` apt package or its associated apt repository. This results in orphaned packages
and repositories remaining on the system, which could lead to unexpected behavior or
conflicts in the future.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ianheggie-oaf is this something we care about?

Comment on lines +27 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The bundle_path for mise is hardcoded to an old path, but the new apt installation places the binary at /usr/bin/mise, which will cause command failures.
Severity: HIGH

Suggested Fix

Update the mise value for ruby_manager_bundle_path in group_vars/all.yml to use the correct path for the apt-installed binary: /usr/bin/mise exec -- bundle.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: roles/internal/mise/tasks/main.yml#L27-L31

Potential issue: The pull request changes the installation method for `mise` to use
`apt`, which places the binary at `/usr/bin/mise`. However, the `bundle_path` variable
in `group_vars/all.yml` is hardcoded to `/home/deploy/.local/bin/mise exec -- bundle`.
Since the old path will no longer exist, any service configured to use `mise` will fail
when attempting to execute bundle or foreman commands, as the `bundle_path` will be
invalid.


- name: Install ruby versions via mise
become: yes
become_user: deploy
command: mise install ruby@{{ item }}
args:
creates: "/home/deploy/.local/share/mise/installs/ruby/{{ item }}"
loop: "{{ ruby_versions }}"

- name: Install bundler for each ruby version
become: yes
become_user: deploy
command: mise exec ruby@{{ item }} -- gem install bundler --no-document
args:
creates: "/home/deploy/.local/share/mise/installs/ruby/{{ item }}/bin/bundle"
loop: "{{ ruby_versions }}"
Comment on lines +39 to +47

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The role will fail if ruby_manager is set to mise but the ruby_versions variable is not defined for a host, as it lacks a default value.
Severity: HIGH

Suggested Fix

Provide a default empty list for the loop variable to prevent the run from failing when no versions are defined. Change the loop from with_items: "{{ ruby_versions }}" to with_items: "{{ ruby_versions | default([]) }}".

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.

Location: roles/internal/mise/tasks/main.yml#L39-L47

Potential issue: The `internal/mise` role iterates over the `ruby_versions` variable to
install specified Ruby versions. However, this variable is not defined globally and
lacks a default value within the role. If a host is configured with `ruby_manager ==
'mise'` but does not have `ruby_versions` defined in its group variables, the Ansible
run will fail with an "undefined variable" error when it attempts to loop over the
non-existent variable.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ianheggie-oaf again, something we care about?

30 changes: 23 additions & 7 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
- rds
when: "(show_rds_debug | default(false) | bool) and (db_name is defined)"

- hosts: ec2
become: true
name: "RDS_planningalerts facts"
tasks:
- name: Get information about the planningalerts RDS instance
rds:
aws_access_key: "{{ aws_access_key }}"
Expand Down Expand Up @@ -185,12 +189,15 @@
rbenv_users:
- deploy
when: "ruby_manager != 'rbenv'"

- name: Remove rvm
tags:
- rvm
import_role:
name: internal/remove_rvm
tags:
- rvm
when: "ruby_manager != 'rvm'"


- name: Remove mise
import_role:
name: internal/remove_mise
Expand All @@ -206,6 +213,8 @@
tasks:
# NOTE: rbenv uses the latest bin/ruby-build so there will usually be changes if you are checking
- name: Install rbenv
tags:
- rbenv
import_role:
name: external/zzet.rbenv
vars:
Expand All @@ -217,7 +226,10 @@
rbenv_users:
- deploy
when: "ruby_manager == 'rbenv'"

- name: Install rvm
tags:
- rvm
import_role:
name: external/rvm.ruby
vars:
Expand All @@ -235,13 +247,17 @@
- name: Add deploy user to rvm group
import_role:
name: internal/rvm.group
tags:
- rvm
when: "ruby_manager == 'rvm'"

# - role: install_mise
# - name: Install mise
# import_role:
# name: internal/mise
# when: "ruby_manager == 'mise'"
- name: "Install mise"
import_role:
name: internal/mise
tags:
- ruby
- mise
when: "ruby_manager == 'mise'"

- hosts: mysql
name: "Vagrant MySQL Server to mimic AWS RDS"
Expand Down
Loading