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 20, 2024
1 parent 4e327ff commit 5a67bcf
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 12 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
27 changes: 25 additions & 2 deletions ansible/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,42 @@
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: "{{ arch_packages }}"
become: true
tags: packages
when: ansible_distribution == arch_distro

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

- 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
10 changes: 10 additions & 0 deletions ubuntu_packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
alacritty
build-essential
byobu
universal-ctags
fd-find
fzf
npm
ripgrep
unzip
zsh
6 changes: 5 additions & 1 deletion zsh/zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ fi
[[ ! -f $ZDOTDIR/.p10k.zsh ]] || source $ZDOTDIR/.p10k.zsh

# Shell integrations
eval "$(fzf --zsh)"
if [ -f ~/.fzf.zsh ]; then
source ~/.fzf.zsh
else
eval "$(fzf --zsh)"
fi

0 comments on commit 5a67bcf

Please sign in to comment.