From e04c4e0d4db1cacca427e202ca0a4e0d06d86789 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 29 May 2023 19:26:30 -0400 Subject: [PATCH 1/2] Install nvm and yarn for javascript/typescript development. --- ansible/playbook.yaml | 87 ++++++++++--------- ansible/roles/javascript/tasks/common.yaml | 15 ++++ ansible/roles/javascript/tasks/freebsd.yaml | 5 ++ ansible/roles/javascript/tasks/linux.yaml | 30 +++++++ ansible/roles/javascript/tasks/main.yaml | 2 + ansible/roles/javascript/tasks/peruser.yaml | 29 +++++++ .../javascript/tasks/peruser_freebsd.yaml | 0 .../roles/javascript/tasks/peruser_linux.yaml | 0 8 files changed, 125 insertions(+), 43 deletions(-) create mode 100644 ansible/roles/javascript/tasks/common.yaml create mode 100644 ansible/roles/javascript/tasks/freebsd.yaml create mode 100644 ansible/roles/javascript/tasks/linux.yaml create mode 100644 ansible/roles/javascript/tasks/main.yaml create mode 100644 ansible/roles/javascript/tasks/peruser.yaml create mode 100644 ansible/roles/javascript/tasks/peruser_freebsd.yaml create mode 100644 ansible/roles/javascript/tasks/peruser_linux.yaml diff --git a/ansible/playbook.yaml b/ansible/playbook.yaml index bbc3329..af31198 100644 --- a/ansible/playbook.yaml +++ b/ansible/playbook.yaml @@ -5,49 +5,50 @@ - sudo - doas - users - - package_manager - - zfs - - zrepl - - zsh - - network - - sshd - - base - - firewall - - cpu - - ntp - - nvme - - hosts - - build - - sound - - graphics - - gpg - - fonts - - alacritty - - sway - - emacs - - firefox - - devfs - - ssh_client - - sshfs - - jail - - fuse - - autofs - - exfat - - bhyve - - bluetooth - - media - - kubernetes - - google_cloud_sdk - - ansible - - wireguard - - portshaker - - poudriere - - android - - latex - - pyenv - - webcam - - docker - - vscode + # - package_manager + # - zfs + # - zrepl + # - zsh + # - network + # - sshd + # - base + # - firewall + # - cpu + # - ntp + # - nvme + # - hosts + # - build + # - sound + # - graphics + # - gpg + # - fonts + # - alacritty + # - sway + # - emacs + # - firefox + # - devfs + # - ssh_client + # - sshfs + # - jail + # - fuse + # - autofs + # - exfat + # - bhyve + # - bluetooth + # - media + # - kubernetes + # - google_cloud_sdk + # - ansible + # - wireguard + # - portshaker + # - poudriere + # - android + # - latex + # - pyenv + # - webcam + # - docker + # - vscode + - javascript - hosts: nat_dhcp:homeserver_nat_dhcp:mrmanager_nat_dhcp vars: diff --git a/ansible/roles/javascript/tasks/common.yaml b/ansible/roles/javascript/tasks/common.yaml new file mode 100644 index 0000000..fef1101 --- /dev/null +++ b/ansible/roles/javascript/tasks/common.yaml @@ -0,0 +1,15 @@ +- import_tasks: tasks/freebsd.yaml + when: 'os_flavor == "freebsd"' + +- import_tasks: tasks/linux.yaml + when: 'os_flavor == "linux"' + +- include_tasks: + file: tasks/peruser.yaml + apply: + become: yes + become_user: "{{ initialize_user }}" + when: users is defined + loop: "{{ users | dict2items | community.general.json_query('[?value.initialize==`true`].key') }}" + loop_control: + loop_var: initialize_user diff --git a/ansible/roles/javascript/tasks/freebsd.yaml b/ansible/roles/javascript/tasks/freebsd.yaml new file mode 100644 index 0000000..b417174 --- /dev/null +++ b/ansible/roles/javascript/tasks/freebsd.yaml @@ -0,0 +1,5 @@ +# - name: Install packages +# package: +# name: +# - foo +# state: present diff --git a/ansible/roles/javascript/tasks/linux.yaml b/ansible/roles/javascript/tasks/linux.yaml new file mode 100644 index 0000000..6d06bb8 --- /dev/null +++ b/ansible/roles/javascript/tasks/linux.yaml @@ -0,0 +1,30 @@ +# - name: Build aur packages +# register: buildaur +# become_user: "{{ build_user.name }}" +# command: "aurutils-sync --no-view {{ item }}" +# args: +# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" +# loop: +# - foo + +# - name: Update cache +# when: buildaur.changed +# pacman: +# name: [] +# state: present +# update_cache: true + +- name: Install packages + package: + name: + - nvm + - yarn + state: present +# +# - name: Enable services +# systemd: +# enabled: yes +# name: "{{ item }}" +# daemon_reload: yes +# loop: +# - foo.service diff --git a/ansible/roles/javascript/tasks/main.yaml b/ansible/roles/javascript/tasks/main.yaml new file mode 100644 index 0000000..6805b9d --- /dev/null +++ b/ansible/roles/javascript/tasks/main.yaml @@ -0,0 +1,2 @@ +- import_tasks: tasks/common.yaml + # when: foo is defined diff --git a/ansible/roles/javascript/tasks/peruser.yaml b/ansible/roles/javascript/tasks/peruser.yaml new file mode 100644 index 0000000..111e886 --- /dev/null +++ b/ansible/roles/javascript/tasks/peruser.yaml @@ -0,0 +1,29 @@ +- include_role: + name: per_user + +# - name: Create directories +# file: +# name: "{{ account_homedir.stdout }}/{{ item }}" +# state: directory +# mode: 0700 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# loop: +# - ".config/foo" + +# - name: Copy files +# copy: +# src: "files/{{ item.src }}" +# dest: "{{ account_homedir.stdout }}/{{ item.dest }}" +# mode: 0600 +# owner: "{{ account_name.stdout }}" +# group: "{{ group_name.stdout }}" +# loop: +# - src: foo.conf +# dest: .config/foo/foo.conf + +- import_tasks: tasks/peruser_freebsd.yaml + when: 'os_flavor == "freebsd"' + +- import_tasks: tasks/peruser_linux.yaml + when: 'os_flavor == "linux"' diff --git a/ansible/roles/javascript/tasks/peruser_freebsd.yaml b/ansible/roles/javascript/tasks/peruser_freebsd.yaml new file mode 100644 index 0000000..e69de29 diff --git a/ansible/roles/javascript/tasks/peruser_linux.yaml b/ansible/roles/javascript/tasks/peruser_linux.yaml new file mode 100644 index 0000000..e69de29 From 48bc37f4507c39ce4e3bdce31ca2b7b0ef3198ea Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Mon, 29 May 2023 19:32:17 -0400 Subject: [PATCH 2/2] Integrate nvm with zsh. --- ansible/roles/javascript/files/zshrc_nvm | 1 + ansible/roles/javascript/tasks/linux.yaml | 24 ------------------- .../roles/javascript/tasks/peruser_linux.yaml | 9 +++++++ 3 files changed, 10 insertions(+), 24 deletions(-) create mode 100644 ansible/roles/javascript/files/zshrc_nvm diff --git a/ansible/roles/javascript/files/zshrc_nvm b/ansible/roles/javascript/files/zshrc_nvm new file mode 100644 index 0000000..b761aa2 --- /dev/null +++ b/ansible/roles/javascript/files/zshrc_nvm @@ -0,0 +1 @@ +source /usr/share/nvm/init-nvm.sh diff --git a/ansible/roles/javascript/tasks/linux.yaml b/ansible/roles/javascript/tasks/linux.yaml index 6d06bb8..fcb79fe 100644 --- a/ansible/roles/javascript/tasks/linux.yaml +++ b/ansible/roles/javascript/tasks/linux.yaml @@ -1,30 +1,6 @@ -# - name: Build aur packages -# register: buildaur -# become_user: "{{ build_user.name }}" -# command: "aurutils-sync --no-view {{ item }}" -# args: -# creates: "/var/cache/pacman/custom/{{ item }}-*.pkg.tar.*" -# loop: -# - foo - -# - name: Update cache -# when: buildaur.changed -# pacman: -# name: [] -# state: present -# update_cache: true - - name: Install packages package: name: - nvm - yarn state: present -# -# - name: Enable services -# systemd: -# enabled: yes -# name: "{{ item }}" -# daemon_reload: yes -# loop: -# - foo.service diff --git a/ansible/roles/javascript/tasks/peruser_linux.yaml b/ansible/roles/javascript/tasks/peruser_linux.yaml index e69de29..25e7ab2 100644 --- a/ansible/roles/javascript/tasks/peruser_linux.yaml +++ b/ansible/roles/javascript/tasks/peruser_linux.yaml @@ -0,0 +1,9 @@ +- name: Configure zshrc additional imports + copy: + src: "files/zshrc_{{ item }}" + dest: "{{ account_homedir.stdout }}/.config/ansible_deploy/zshrc/{{ item }}.zsh" + mode: 0600 + owner: "{{ account_name.stdout }}" + group: "{{ group_name.stdout }}" + loop: + - nvm