From d51770a4b48e11b33dde3cae58b40db11eec8646 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Tue, 11 Oct 2022 20:21:38 -0400 Subject: [PATCH] Start of zsh role, per-user section not yet implemented. --- .../environments/laptop/host_vars/odolinux | 1 - ansible/playbook.yaml | 1 + ansible/roles/users/defaults/main.yaml | 1 - ansible/roles/zsh/handlers/main.yml | 4 +++ ansible/roles/zsh/meta/main.yaml | 2 ++ ansible/roles/zsh/tasks/freebsd.yaml | 17 ++++++++++ ansible/roles/zsh/tasks/linux.yaml | 8 +++++ ansible/roles/zsh/tasks/main.yaml | 5 +++ ansible/roles/zsh/tasks/peruser.yaml | 33 +++++++++++++++++++ 9 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 ansible/roles/zsh/handlers/main.yml create mode 100644 ansible/roles/zsh/meta/main.yaml create mode 100644 ansible/roles/zsh/tasks/freebsd.yaml create mode 100644 ansible/roles/zsh/tasks/linux.yaml create mode 100644 ansible/roles/zsh/tasks/main.yaml create mode 100644 ansible/roles/zsh/tasks/peruser.yaml diff --git a/ansible/environments/laptop/host_vars/odolinux b/ansible/environments/laptop/host_vars/odolinux index 9342780..a700b99 100644 --- a/ansible/environments/laptop/host_vars/odolinux +++ b/ansible/environments/laptop/host_vars/odolinux @@ -1,7 +1,6 @@ os_flavor: "linux" users: talexander: - per_user: true initialize: true uid: 11235 gid: 1000 diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml index 2eee7bd..82a5e13 100644 --- a/ansible/playbook.yaml +++ b/ansible/playbook.yaml @@ -5,3 +5,4 @@ - sudo - users - zrepl + - zsh diff --git a/ansible/roles/users/defaults/main.yaml b/ansible/roles/users/defaults/main.yaml index 89bfa9d..f1f8090 100644 --- a/ansible/roles/users/defaults/main.yaml +++ b/ansible/roles/users/defaults/main.yaml @@ -1,6 +1,5 @@ users: talexander: - per_user: true initialize: true uid: 11235 gid: 11235 diff --git a/ansible/roles/zsh/handlers/main.yml b/ansible/roles/zsh/handlers/main.yml new file mode 100644 index 0000000..0fb3dee --- /dev/null +++ b/ansible/roles/zsh/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart zrepl + service: + name: zrepl + state: restarted diff --git a/ansible/roles/zsh/meta/main.yaml b/ansible/roles/zsh/meta/main.yaml new file mode 100644 index 0000000..655446a --- /dev/null +++ b/ansible/roles/zsh/meta/main.yaml @@ -0,0 +1,2 @@ +dependencies: + - users diff --git a/ansible/roles/zsh/tasks/freebsd.yaml b/ansible/roles/zsh/tasks/freebsd.yaml new file mode 100644 index 0000000..abb4c5c --- /dev/null +++ b/ansible/roles/zsh/tasks/freebsd.yaml @@ -0,0 +1,17 @@ +- name: Install packages + package: + name: + - zsh + - sqlite3 + - git + - py39-jmespath # Needed on machine running ansible for json_query + state: present + +- include_tasks: + file: tasks/peruser.yaml + apply: + become: yes + become_user: "{{ initialize_user }}" + loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}" + loop_control: + loop_var: initialize_user diff --git a/ansible/roles/zsh/tasks/linux.yaml b/ansible/roles/zsh/tasks/linux.yaml new file mode 100644 index 0000000..86fe213 --- /dev/null +++ b/ansible/roles/zsh/tasks/linux.yaml @@ -0,0 +1,8 @@ +- name: Install packages + package: + name: + - zsh + - sqlite + - git + - python-jmespath # Needed on machine running ansible for json_query + state: present diff --git a/ansible/roles/zsh/tasks/main.yaml b/ansible/roles/zsh/tasks/main.yaml new file mode 100644 index 0000000..d320bc8 --- /dev/null +++ b/ansible/roles/zsh/tasks/main.yaml @@ -0,0 +1,5 @@ +- include: tasks/freebsd.yaml + when: 'os_flavor == "freebsd"' + +- include: tasks/linux.yaml + when: 'os_flavor == "linux"' diff --git a/ansible/roles/zsh/tasks/peruser.yaml b/ansible/roles/zsh/tasks/peruser.yaml new file mode 100644 index 0000000..1a4e4e8 --- /dev/null +++ b/ansible/roles/zsh/tasks/peruser.yaml @@ -0,0 +1,33 @@ +- include_role: + name: per_user +# - name: clone zsh-histdb repo +# git: +# repo: "https://github.com/larkery/zsh-histdb.git" +# dest: "{{ account_homedir.stdout }}/.ansible_deploy/zsh-histdb" +# version: "6c7159be9de8586ac2f19d179d562cf5d10a2bab" +# diff: false + +# - name: Create zshrc additional imports directory +# file: +# name: "{{ account_homedir.stdout }}/.ansible_deploy/zshrc" +# state: directory +# mode: 0700 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" + +# - name: Configure zshrc additional imports +# copy: +# src: "files/zshrc_{{ item }}" +# dest: "{{ account_homedir.stdout }}/.ansible_deploy/zshrc/{{ item }}.zsh" +# mode: 0600 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# with_items: "{{ additional_zshrc_files }}" + +# - name: Configure zshrc +# copy: +# src: files/zshrc +# dest: "{{ account_homedir.stdout }}/.zshrc" +# mode: 0600 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}"