Skip to content

Commit

Permalink
Ubuntu 24.04 support (#19)
Browse files Browse the repository at this point in the history
* Fixing inspec

* meta update

* Disabling thefuck for now

* Fixes found during testing

* fixing a test

* Fixing test data
  • Loading branch information
ahrenstein authored Jul 14, 2024
1 parent 945e164 commit ff31046
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 134 deletions.
4 changes: 1 addition & 3 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ transport:
username: ubuntu

platforms:
- name: ubuntu-18.04
- name: ubuntu-20.04
- name: ubuntu-22.04
driver:
image_id: ami-0515e1913cfc2801d # A private custom AMI that enables ssh-rsa keys for sshd in Vagrant.
- name: ubuntu-24.04

suites:
- name: standard
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ Ansible Role - ubuntu-base: Changelog
=====================================
A list of all the changes made to this repo, and the role it contains

Version 1.4.0
-------------

1. Added Ubuntu 24.04 support
2. Removed Ubuntu 18.04 support

Version 1.3.2
-------------

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ gem "kitchen-ec2"
gem "aws-sdk-ec2"
gem "kitchen-ansible"
gem "kitchen-inspec"
gem "inspec"
gem "inspec", "< 6.0"
gem "inspec-bin"
5 changes: 5 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Ansible Role - ubuntu-base: TODO
=====================================
A list of all the tasks to do for this repo

1. Restore `thefuck` for Ubuntu 24.04+ once the maintainer fixes the package.
8 changes: 5 additions & 3 deletions files/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ export EDITOR=vim
# New sessions start in ~/
cd ~/

# Make sure Vagrant uses virtualbox by default
export VAGRANT_DEFAULT_PROVIDER=virtualbox

# Enable thefuck
eval "$(thefuck --alias)"
#TODO remove this if statement when the package works on 24.04+
version=$(lsb_release -rs | grep -v "No")
if (( $(echo "$version < 24.04" | bc -l) )); then
eval "$(thefuck --alias)"
fi

# Help keep repos clean by deleting branches that no longer exist upstream
git_prune()
Expand Down
4 changes: 2 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ galaxy_info:
description: "Various tweaks and basic prerequisites for Ubuntu systems along with a fancy bash prompt"
company: "Route 1337 LLC"
license: "license (MIT)"
min_ansible_version: "2.4"
min_ansible_version: "2.8"
platforms:
- name: Ubuntu
versions:
- bionic
- focal
- jammy
- noble
galaxy_tags:
- base
- system
Expand Down
2 changes: 1 addition & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
- import_tasks: ntp.yml
when: ansible_distribution == 'Ubuntu'
- import_tasks: thefuck.yml
when: ansible_distribution == 'Ubuntu'
when: ansible_distribution == 'Ubuntu' and ansible_distribution_version < "24.04" #TODO fix this when the package is fixed
- import_tasks: systemd.yml
when: ansible_distribution == 'Ubuntu'
2 changes: 2 additions & 0 deletions tasks/ntp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
apt:
name: ntp
state: present
when: ansible_distribution_version < "24.04"

- name: Set localtime symlink to correct TZ
set_fact:
Expand All @@ -33,3 +34,4 @@
name: ntp
state: started
enabled: yes
when: ansible_distribution_version < "24.04"
3 changes: 1 addition & 2 deletions tasks/prereqs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,14 @@
- zsh
- locate

- name: (Ubuntu 20.04+) Add packages
- name: Add packages
apt:
name: "{{ packages }}"
state: present
vars:
packages:
- fzf
- ripgrep
when: ansible_distribution_version >= "20.04"

- name: Make sure the /opt directory exists
file:
Expand Down
9 changes: 8 additions & 1 deletion tasks/thefuck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@

# Install thefuck, its prerequisites and our custom rules for it

- name: Install thefuck
- name: Install thefuck via pip
pip:
name: thefuck
state: present
executable: pip3
when: ansible_distribution_version < "24.04"

- name: Install thefuck
apt:
name: thefuck
state: present
when: ansible_distribution_version >= "24.04"

- name: Create root's custom thefuck rules directory
file:
Expand Down
4 changes: 2 additions & 2 deletions tests/host_vars/systemd/localhost.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ ubuntu_base:
- 8.8.8.8
- 1.1.1.1
search_domain: "company.internal"
tzsymlink: "EST"
localtime: "/usr/share/zoneinfo/America/New_York"
tzsymlink: "UTC"
localtime: "/usr/share/zoneinfo/UTC"
58 changes: 0 additions & 58 deletions tests/smoke/repo-role/standard/thefuck_test.rb

This file was deleted.

6 changes: 3 additions & 3 deletions tests/smoke/repo-role/systemd/ntp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Verify the localtime is set correctly
# This is done via ls since each version of Ubuntu seems changes the final destination of the link
describe command('ls -lh /etc/localtime') do
its('stdout') { should match /\/usr\/share\/zoneinfo\/America\/New_York/ }
its('stdout') { should match /\/usr\/share\/zoneinfo\/UTC/ }
end

# Verify the timezone file is correct
Expand All @@ -38,12 +38,12 @@
it { should be_owned_by 'root' }
it { should be_grouped_into 'root' }
it { should be_mode 0644 }
its(:content) { should match /EST/ }
its(:content) { should match /UTC/ }
end

# Verify the time zone we want is active
describe command('date +%Z') do
its('stdout') { should match /EST/ }
its('stdout') { should match /UTC/ }
end

# Verify the ntp service is running and enabled
Expand Down
58 changes: 0 additions & 58 deletions tests/smoke/repo-role/systemd/thefuck_test.rb

This file was deleted.

0 comments on commit ff31046

Please sign in to comment.