From 6670ffafa9d748056e7fecd3183b2b3e3104b9e8 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sat, 26 Nov 2022 01:51:20 +0100 Subject: [PATCH] set zsh as login shell install various packages --- README.md | 8 ++++---- ansible.cfg | 3 +++ playbooks/setup.yml | 12 +++--------- roles/system/facts/login_shell.fact | 5 +++++ roles/system/tasks/main.yml | 26 ++++++++++++++++++++++++++ 5 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 ansible.cfg create mode 100755 roles/system/facts/login_shell.fact create mode 100644 roles/system/tasks/main.yml diff --git a/README.md b/README.md index 67a2b95..dd6b200 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,11 @@ ## TODO - Git config (git config --global user.email "pim@kunis.nl", git config --global user.name "Pim Kunis", set vim as editor) -- Install keepassxc - Install nextcloud - Install bashrc - Install latest neovim -- Install zsh - Install i3 config -- Install git -- Install make +- Install libreoffice +- Install GIMP +- Install Telegram +- Install Signal diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..2b8bf76 --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +# (pathspec) Colon separated paths in which Ansible will search for Roles. +roles_path=~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:roles diff --git a/playbooks/setup.yml b/playbooks/setup.yml index 0045b2c..4be021f 100644 --- a/playbooks/setup.yml +++ b/playbooks/setup.yml @@ -1,10 +1,4 @@ -- name: prerequisites +- name: Configure system hosts: self - tasks: - - name: update repositories - become: true - apt: - upgrade: yes - state: latest - update_cache: yes - cache_valid_time: 86400 # One day + roles: + - system diff --git a/roles/system/facts/login_shell.fact b/roles/system/facts/login_shell.fact new file mode 100755 index 0000000..f6b1c73 --- /dev/null +++ b/roles/system/facts/login_shell.fact @@ -0,0 +1,5 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' +LOGINSHELL=`getent passwd $USER | cut -d: -f7` +echo \"${LOGINSHELL}\" diff --git a/roles/system/tasks/main.yml b/roles/system/tasks/main.yml new file mode 100644 index 0000000..581d817 --- /dev/null +++ b/roles/system/tasks/main.yml @@ -0,0 +1,26 @@ +- name: Update repositories + become: true + apt: + upgrade: yes + state: latest + update_cache: yes + cache_valid_time: 86400 # One day +- name: Install global packages + become: true + apt: + state: latest + pkg: + - git + - make + - keepassxc + - zsh +- name: Check login shell + setup: + fact_path: "{{ role_path }}/facts" +- name: Print all available facts + ansible.builtin.debug: + var: ansible_facts +- name: Set default shell to zsh + become: true + shell: usermod -s $(which zsh) {{ ansible_user_id }} + when: ansible_facts.ansible_local.login_shell.find('zsh') == -1