Skip to content

Commit

Permalink
feat: add Ubuntu support
Browse files Browse the repository at this point in the history
  • Loading branch information
vicnett committed Nov 18, 2024
1 parent 4e327ff commit 087daba
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ EOF

# Install the packages Ansible will want to install later. There's no need to
# excessively download packages from the Manjaro repo every build...
COPY manjaro_packages .
COPY arch_packages .
RUN <<-EOF
sudo pacman -Syu --noconfirm
sudo pacman -S --needed --noconfirm - < manjaro_packages
sudo pacman -S --needed --noconfirm - < arch_packages
EOF

FROM install AS copy
Expand Down
32 changes: 30 additions & 2 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,47 @@
connection: local

vars:
arch_distro: "Archlinux"
ubuntu_distro: "Ubuntu"
supported_distros: [ "{{ arch_distro }}", "{{ ubuntu_distro }}" ]
base_dir: '{{ playbook_dir | dirname }}'
gitignore_path: '{{ base_dir }}/git/gitignore'
git_aliases_path: '{{ base_dir }}/aliases/git'
arch_packages: "{{ lookup('file', base_dir ~ '/arch_packages').splitlines() }}"
ubuntu_packages: "{{ lookup('file', base_dir ~ '/ubuntu_packages').splitlines() }}"

tasks:
- name: Install packages
- ansible.builtin.debug:
msg: "supported_distros: {{ supported_distros }}"
- name: Stop if OS is unsupported
fail:
msg: "{{ ansible_distribution }} not supported"
when: ansible_distribution not in supported_distros

- name: Install packages (Arch)
ansible.builtin.package:
name: "{{ packages }}"
state: present
vars:
packages: "{{ lookup('file', base_dir ~ '/manjaro_packages').splitlines() }}"
packages: "{{ arch_packages }}"
become: true
tags: packages
when: ansible_distribution == arch_distro

- name: Install packages (Ubuntu)
ansible.builtin.package:
name: "{{ packages }}"
state: present
vars:
packages: "{{ ubuntu_packages }}"
become: true
tags: packages
when: ansible_distribution == ubuntu_distro

- name: Install Neovim (Ubuntu)
ansible.builtin.get_url:
url: https://github.com/neovim/neovim/releases/latest/download/nvim.appimage
dest:

- name: Change shell to zsh
become: yes
Expand Down
File renamed without changes.
28 changes: 21 additions & 7 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,32 @@ DOTFILES_DIR="$HOME/.dotfiles"
ANSIBLE_PATH="$HOME/.local/bin"
PLAYBOOK_PATH="$DOTFILES_DIR/ansible/playbook.yml"

sudo pacman -S --needed --noconfirm git python-pipx
pipx install --include-deps ansible
# Detect distro
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$NAME
fi

if [ ! -d $DOTFILES_DIR ]
if [ "$OS" = "Manjaro Linux" ] || [ "$OS" = "Arch Linux" ]; then
sudo pacman -S --needed --noconfirm git python-pipx
elif [ "$OS" = "Ubuntu" ]; then
sudo apt --assume-yes install git pipx
else
echo "Distribution $OS not supported"
exit 1
fi

pipx install --include-deps ansible
if [ ! -d "$DOTFILES_DIR" ]
then
git clone --recurse-submodules https://github.com/vicnett/dotfiles.git $DOTFILES_DIR
git clone --recurse-submodules https://github.com/vicnett/dotfiles.git "$DOTFILES_DIR"
fi

if [ -f $PLAYBOOK_PATH ]
if [ -f "$PLAYBOOK_PATH" ]
then
$ANSIBLE_PATH/ansible-playbook $PLAYBOOK_PATH
"$ANSIBLE_PATH/ansible-playbook" "$PLAYBOOK_PATH"
else
echo Ansible playbook not found at $PLAYBOOK_PATH
echo "Ansible playbook not found at $PLAYBOOK_PATH"
exit 1
fi
11 changes: 11 additions & 0 deletions ubuntu_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
alacritty
build-essential
byobu
universal-ctags
fd-find
fzf
neovim
npm
ripgrep
unzip
zsh

0 comments on commit 087daba

Please sign in to comment.