Upgrade to Ruby 3.3.5, and improve the mechanisms for it a bit

I move `ruby_version` into an Ansible variable, to make it easier to
update in the future!
This commit is contained in:
Emi Matchu 2024-09-20 12:47:23 -07:00
parent 5bf2ef42a0
commit 9ebc498888
5 changed files with 23 additions and 20 deletions

View file

@ -1 +1 @@
3.3.4 3.3.5

View file

@ -1,5 +1,5 @@
source 'https://rubygems.org' source 'https://rubygems.org'
ruby '3.3.4' ruby '3.3.5'
gem 'rails', '~> 7.1', '>= 7.1.3.4' gem 'rails', '~> 7.1', '>= 7.1.3.4'

View file

@ -6,6 +6,8 @@
vars: vars:
local_app_root: "{{ playbook_dir }}/.." local_app_root: "{{ playbook_dir }}/.."
remote_project_root: "/srv/impress" remote_project_root: "/srv/impress"
ruby_version: "3.3.5"
# deploy:setup should have added us to the "impress-deployers" group, so we # deploy:setup should have added us to the "impress-deployers" group, so we
# should be able to become the "impress" user without a password. # should be able to become the "impress" user without a password.
ansible_become_password: "" ansible_become_password: ""
@ -60,7 +62,7 @@
- name: Configure Bundler to run in deployment mode - name: Configure Bundler to run in deployment mode
command: command:
chdir: "{{ remote_app_root }}" chdir: "{{ remote_app_root }}"
cmd: /opt/ruby-3.3.4/bin/bundle config set --local deployment true cmd: /opt/ruby-{{ ruby_version }}/bin/bundle config set --local deployment true
# This ensures that, while attempting our current deploy, we don't # This ensures that, while attempting our current deploy, we don't
# accidentally delete gems out from under the currently-running version. # accidentally delete gems out from under the currently-running version.
@ -70,7 +72,7 @@
- name: Configure Bundler to *not* clean up old gems when installing - name: Configure Bundler to *not* clean up old gems when installing
command: command:
chdir: "{{ remote_app_root }}" chdir: "{{ remote_app_root }}"
cmd: /opt/ruby-3.3.4/bin/bundle config set --local clean false cmd: /opt/ruby-{{ ruby_version }}/bin/bundle config set --local clean false
# NOTE: Bundler recommends this, and they're pretty smart about it: if the # NOTE: Bundler recommends this, and they're pretty smart about it: if the
# Gemfile changes, this shouldn't disrupt the currently-running version, # Gemfile changes, this shouldn't disrupt the currently-running version,
@ -79,7 +81,7 @@
- name: Configure Bundler to use the bundle folder shared by all app versions - name: Configure Bundler to use the bundle folder shared by all app versions
command: command:
chdir: "{{ remote_app_root }}" chdir: "{{ remote_app_root }}"
cmd: "/opt/ruby-3.3.4/bin/bundle config set --local path {{ remote_project_root}}/shared/bundle" cmd: "/opt/ruby-{{ ruby_version }}/bin/bundle config set --local path {{ remote_project_root}}/shared/bundle"
- name: Run `bundle install` to install dependencies in remote folder - name: Run `bundle install` to install dependencies in remote folder
command: command:
@ -87,7 +89,7 @@
# The `--local` flag instructs Bundler to use the cached dependencies # The `--local` flag instructs Bundler to use the cached dependencies
# in `vendor/cache`, instead of reading from the web, which is much # in `vendor/cache`, instead of reading from the web, which is much
# faster and more reliable! # faster and more reliable!
cmd: /opt/ruby-3.3.4/bin/bundle install --local cmd: /opt/ruby-{{ ruby_version }}/bin/bundle install --local
- name: Update the `current` folder to point to the new version - name: Update the `current` folder to point to the new version
file: file:
@ -111,7 +113,7 @@
- name: Clean up gems no longer used in the current app version - name: Clean up gems no longer used in the current app version
command: command:
chdir: "{{ remote_app_root }}" chdir: "{{ remote_app_root }}"
cmd: /opt/ruby-3.3.4/bin/bundle clean cmd: /opt/ruby-{{ ruby_version }}/bin/bundle clean
when: not skip_set_as_current when: not skip_set_as_current
- name: Find older app versions to clean up - name: Find older app versions to clean up

View file

@ -5,7 +5,7 @@ Description=Dress to Impress webapp
User=impress User=impress
Restart=always Restart=always
WorkingDirectory=/srv/impress/current WorkingDirectory=/srv/impress/current
ExecStart=/opt/ruby-3.3.4/bin/bundle exec falcon host ExecStart=/opt/ruby-{{ ruby_version }}/bin/bundle exec falcon host
Environment="RAILS_ENV=production" Environment="RAILS_ENV=production"
; Set EXECJS_RUNTIME to save us from needing to install Node ; Set EXECJS_RUNTIME to save us from needing to install Node
Environment="EXECJS_RUNTIME=Disabled" Environment="EXECJS_RUNTIME=Disabled"
@ -35,4 +35,4 @@ NoNewPrivileges=true
CapabilityBoundingSet=~CAP_SYS_ADMIN CapabilityBoundingSet=~CAP_SYS_ADMIN
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -6,6 +6,7 @@
vars: vars:
email_address: "emi@matchu.dev" # TODO: Extract this to personal config? email_address: "emi@matchu.dev" # TODO: Extract this to personal config?
impress_hostname: impress.openneo.net impress_hostname: impress.openneo.net
ruby_version: "3.3.5"
vars_files: vars_files:
# mysql_root_password, mysql_user_password, mysql_user_password_2020, # mysql_root_password, mysql_user_password, mysql_user_password_2020,
# dev_ips # dev_ips
@ -170,21 +171,21 @@
git: git:
repo: https://github.com/rbenv/ruby-build.git repo: https://github.com/rbenv/ruby-build.git
dest: /opt/ruby-build dest: /opt/ruby-build
version: d22fa95a6e4c77945304c16ebe0d9513fec98cfb version: v20240917
- name: Check if Ruby 3.3.4 is already installed - name: Check if Ruby {{ ruby_version }} is already installed
stat: stat:
path: /opt/ruby-3.3.4 path: /opt/ruby-{{ ruby_version }}
register: ruby_dir register: ruby_dir
- name: Install Ruby 3.3.4 - name: Install Ruby {{ ruby_version }}
command: "/opt/ruby-build/bin/ruby-build 3.3.4 /opt/ruby-3.3.4" command: "/opt/ruby-build/bin/ruby-build {{ ruby_version }} /opt/ruby-{{ ruby_version }}"
when: not ruby_dir.stat.exists when: not ruby_dir.stat.exists
- name: Add Ruby 3.3.4 to the global PATH, for developer convenience - name: Add Ruby {{ ruby_version }} to the global PATH, for developer convenience
copy: copy:
dest: /etc/profile.d/ruby_path.sh dest: /etc/profile.d/ruby_path.sh
content: PATH="/opt/ruby-3.3.4/bin:$PATH" content: PATH="/opt/ruby-{{ ruby_version }}/bin:$PATH"
- name: Install system dependencies for impress's Ruby gems - name: Install system dependencies for impress's Ruby gems
apt: apt:
@ -248,14 +249,14 @@
become_user: impress become_user: impress
command: command:
chdir: /srv/impress/versions/initial-placeholder chdir: /srv/impress/versions/initial-placeholder
cmd: /opt/ruby-3.3.4/bin/bundle config set --local deployment true cmd: /opt/ruby-{{ ruby_version }}/bin/bundle config set --local deployment true
when: not current_app_version.stat.exists when: not current_app_version.stat.exists
- name: Install the placeholder app's dependencies - name: Install the placeholder app's dependencies
become_user: impress become_user: impress
command: command:
chdir: /srv/impress/versions/initial-placeholder chdir: /srv/impress/versions/initial-placeholder
cmd: /opt/ruby-3.3.4/bin/bundle install cmd: /opt/ruby-{{ ruby_version }}/bin/bundle install
when: not current_app_version.stat.exists when: not current_app_version.stat.exists
- name: Set the placeholder app as the current version - name: Set the placeholder app as the current version
@ -287,8 +288,8 @@
state: directory state: directory
- name: Create service file for impress - name: Create service file for impress
copy: template:
src: files/impress.service src: files/impress.service.j2
dest: /etc/systemd/system/impress.service dest: /etc/systemd/system/impress.service
notify: notify:
- Reload systemctl - Reload systemctl