feat: add checks for community.general collection and ensure default shell is set to bash
Some checks failed
Nix Format Check / check-format (push) Failing after 39s

This commit is contained in:
Menno van Leeuwen 2025-03-10 15:05:52 +01:00
parent 1aa25a743a
commit 0f0d67d419
Signed by: vleeuwenmenno
SSH Key Fingerprint: SHA256:OJFmjANpakwD3F2Rsws4GLtbdz1TJ5tkQF0RZmF0TRE
7 changed files with 57 additions and 10 deletions

View File

@ -3,9 +3,18 @@
gather_facts: true
pre_tasks:
- name: Install required collections
ansible.builtin.command: ansible-galaxy collection install -r requirements.yml
- name: Check if community.general collection is installed
ansible.builtin.command: ansible-galaxy collection list community.general
register: collection_check
changed_when: false
ignore_errors: true
delegate_to: localhost
- name: Install required collections
ansible.builtin.command: ansible-galaxy collection install -r "{{ playbook_dir }}/requirements.yml"
delegate_to: localhost
when: collection_check.rc != 0 or "community.general" not in collection_check.stdout
changed_when: collection_check.rc != 0 or "community.general" not in collection_check.stdout
run_once: true
tasks:

View File

@ -1,4 +1,4 @@
- name: Include symlinks tasks
- name: Include global symlinks tasks
ansible.builtin.import_tasks: tasks/global/symlinks.yml
- name: Gather package facts

View File

@ -11,7 +11,6 @@
follow: false
loop:
- { src: "$DOTFILES_PATH/config/home-manager", dest: "~/.config/home-manager" }
- { src: "$DOTFILES_PATH/vscode/settings.json", dest: "~/.config/Code/User/settings.json" }
- { src: "$DOTFILES_PATH/config/ssh/config", dest: "~/.ssh/config" }
- { src: "$DOTFILES_PATH/config/ssh/config.d", dest: "~/.ssh/config.d" }
- { src: "$DOTFILES_PATH/config/starship.toml", dest: "~/.config/starship.toml" }

View File

@ -0,0 +1,13 @@
- name: Set user home directory
ansible.builtin.set_fact:
user_home: "{{ ansible_env.HOME if ansible_user_id == 'root' else lookup('env', 'HOME') }}"
- name: Create workstation symlinks
ansible.builtin.file:
src: "{{ item.src | replace('~', user_home) | replace('$DOTFILES_PATH', lookup('env', 'DOTFILES_PATH')) }}"
dest: "{{ item.dest | replace('~', user_home) }}"
state: link
force: true
follow: false
loop:
- { src: "$DOTFILES_PATH/vscode/settings.json", dest: "~/.config/Code/User/settings.json" }

View File

@ -1,3 +1,6 @@
- name: Include workstation symlinks tasks
ansible.builtin.import_tasks: tasks/workstations/symlinks.yml
- name: Include GNOME Extensions tasks
ansible.builtin.import_tasks: tasks/workstations/gnome-extensions.yml

View File

@ -23,11 +23,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1741048562,
"narHash": "sha256-W4YZ3fvWZiFYYyd900kh8P8wU6DHSiwaH0j4+fai1Sk=",
"lastModified": 1741445498,
"narHash": "sha256-F5Em0iv/CxkN5mZ9hRn3vPknpoWdcdCyR0e4WklHwiE=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "6af28b834daca767a7ef99f8a7defa957d0ade6f",
"rev": "52e3095f6d812b91b22fb7ad0bfc1ab416453634",
"type": "github"
},
"original": {
@ -39,11 +39,11 @@
},
"nixpkgs-unstable": {
"locked": {
"lastModified": 1741173522,
"narHash": "sha256-k7VSqvv0r1r53nUI/IfPHCppkUAddeXn843YlAC5DR0=",
"lastModified": 1741379970,
"narHash": "sha256-Wh7esNh7G24qYleLvgOSY/7HlDUzWaL/n4qzlBePpiw=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "d69ab0d71b22fa1ce3dbeff666e6deb4917db049",
"rev": "36fd87baa9083f34f7f5027900b62ee6d09b1f2f",
"type": "github"
},
"original": {

View File

@ -338,6 +338,28 @@ check_compatibility() {
esac
}
# Ensure bash is set as the default shell for the user
ensure_shell() {
local shell
shell=$(getent passwd "$USER" | cut -d: -f7)
if [ "$shell" != "/bin/bash" ]; then
log_info "Setting default shell to bash..."
chsh -s /bin/bash || die "Failed to set default shell to bash"
log_success "Default shell set to bash."
fi
# Ensure shell is set for root user
if [ "$USER" != "root" ]; then
local root_shell
root_shell=$(getent passwd root | cut -d: -f7)
if [ "$root_shell" != "/bin/bash" ]; then
log_info "Setting default shell for root to bash..."
sudo chsh -s /bin/bash root || die "Failed to set default shell for root to bash"
log_success "Default shell for root set to bash."
fi
fi
}
main() {
check_compatibility
@ -378,6 +400,7 @@ main() {
setup_symlinks
setup_ansible
ensure_shell
# Get hostname
local hostname