From e3aaee336c310a807d5d5e29eab2ef1458743377 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Mon, 10 Jun 2024 16:23:13 +0200 Subject: [PATCH] Update to macos install --- group_vars/all.yml | 6 +++++- macos.yml | 3 ++- roles/07_user/tasks/main.yml | 21 ++++--------------- roles/07_user/tasks/rbw.yml | 17 +++++++++++++++ roles/08_tweaks/tasks/main.yml | 6 ++++++ roles/macos_03_user/tasks/main.yml | 12 +++++++++++ .../tasks/main.yml | 11 +++++----- scripts/setup_dotfiles.sh | 2 +- scripts/setup_gpg.sh | 13 +++++++++++- 9 files changed, 65 insertions(+), 26 deletions(-) create mode 100644 roles/07_user/tasks/rbw.yml create mode 100644 roles/macos_03_user/tasks/main.yml rename roles/{macos_03_tweaks => macos_04_tweaks}/tasks/main.yml (89%) diff --git a/group_vars/all.yml b/group_vars/all.yml index 5195bb4..00d8f1c 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -100,7 +100,7 @@ gnome_extensions: - freon@UshakovVasilii_Github.yahoo.com macos: - hostname: "maximum" + hostname: "maximus" dock_apps: - /System/Applications/Calendar.app - /Applications/Todoist.app @@ -114,6 +114,7 @@ macos: - /Applications/WhatsApp.app - /Applications/Spotify.app homebrew_packages: + - defaultbrowser - mas - tree - iterm2 @@ -139,11 +140,14 @@ macos: - the_silver_searcher - jq - vim + - rbw - wget - direnv - antidote - gnupg - sqlite + - pinentry-mac + - gh mas_remove: # GarageBand - 682658836 diff --git a/macos.yml b/macos.yml index 21b3a4b..521261a 100644 --- a/macos.yml +++ b/macos.yml @@ -4,5 +4,6 @@ roles: - { role: macos_01_hostname } - { role: macos_02_packages } - - { role: macos_03_tweaks } + - { role: macos_03_user } + - { role: macos_04_tweaks } diff --git a/roles/07_user/tasks/main.yml b/roles/07_user/tasks/main.yml index c553f94..327d685 100644 --- a/roles/07_user/tasks/main.yml +++ b/roles/07_user/tasks/main.yml @@ -26,24 +26,11 @@ validate: /usr/sbin/visudo -cf %s become: true -- name: Configure rbw - ansible.builtin.file: - path: ~/.config/rbw - state: directory - mode: '0755' - become: true - become_user: "{{ user.name }}" - -- name: Copy rbw-config.json - ansible.builtin.copy: - src: rbw-config.json - dest: ~/.config/rbw/config.json - mode: '0644' - become: true - become_user: "{{ user.name }}" - - name: Configure pinentry for gnome3 ansible.builtin.lineinfile: path: ~/.gnupg/gpg-agent.conf line: "pinentry-program /usr/bin/pinentry-gnome3" - create: yes \ No newline at end of file + create: yes + +- name: Install Bitwarden CLI settings + ansible.builtin.import_tasks: rbw.yml \ No newline at end of file diff --git a/roles/07_user/tasks/rbw.yml b/roles/07_user/tasks/rbw.yml new file mode 100644 index 0000000..ad78683 --- /dev/null +++ b/roles/07_user/tasks/rbw.yml @@ -0,0 +1,17 @@ +--- + +- name: Configure rbw + ansible.builtin.file: + path: "{{ '~/Library/Application Support/rbw' if ansible_facts['os_family'] == 'Darwin' else '~/.config/rbw' }}" + state: directory + mode: '0755' + become: true + become_user: "{{ user.name }}" + +- name: Copy rbw-config.json + ansible.builtin.copy: + src: rbw-config.json + dest: "{{ '~/Library/Application Support/rbw' if ansible_facts['os_family'] == 'Darwin' else '~/.config/rbw' }}/config.json" + mode: '0644' + become: true + become_user: "{{ user.name }}" \ No newline at end of file diff --git a/roles/08_tweaks/tasks/main.yml b/roles/08_tweaks/tasks/main.yml index ba569bb..95d8a86 100644 --- a/roles/08_tweaks/tasks/main.yml +++ b/roles/08_tweaks/tasks/main.yml @@ -25,3 +25,9 @@ - name: Setup a wallpaper ansible.builtin.import_tasks: wallpaper.yml + +- name: Configure gpg-agent pinentry + ansible.builtin.lineinfile: + path: ~/.gnupg/gpg-agent.conf + line: "pinentry-program /usr/bin/pinentry-gnome3" + create: yes \ No newline at end of file diff --git a/roles/macos_03_user/tasks/main.yml b/roles/macos_03_user/tasks/main.yml new file mode 100644 index 0000000..5b25a00 --- /dev/null +++ b/roles/macos_03_user/tasks/main.yml @@ -0,0 +1,12 @@ +--- + +- name: Install Bitwarden CLI settings + ansible.builtin.include_role: + name: 07_user + tasks_from: rbw + +- name: Configure gpg-agent pinentry + ansible.builtin.lineinfile: + path: ~/.gnupg/gpg-agent.conf + line: "pinentry-program /usr/local/bin/pinentry-mac" + create: yes \ No newline at end of file diff --git a/roles/macos_03_tweaks/tasks/main.yml b/roles/macos_04_tweaks/tasks/main.yml similarity index 89% rename from roles/macos_03_tweaks/tasks/main.yml rename to roles/macos_04_tweaks/tasks/main.yml index 4ec112f..f0fb109 100644 --- a/roles/macos_03_tweaks/tasks/main.yml +++ b/roles/macos_04_tweaks/tasks/main.yml @@ -23,9 +23,6 @@ value: false state: present -- name: Setup dock apps - community.general.osx_defaults: - - name: Remove all apps from dock community.general.osx_defaults: domain: com.apple.dock @@ -40,7 +37,7 @@ key: persistent-apps type: array array_add: true - value: ['{{ item }}'] + value: ['tile-datafile-data_CFURLString{{ item }}_CFURLStringType0'] state: present with_items: "{{ macos.dock_apps }}" @@ -122,4 +119,8 @@ - name: Restart SystemUIServer ansible.builtin.shell: killall SystemUIServer - changed_when: false \ No newline at end of file + changed_when: false + +- name: Set Firefox as default browser + ansible.builtin.shell: defaultbrowser firefox + \ No newline at end of file diff --git a/scripts/setup_dotfiles.sh b/scripts/setup_dotfiles.sh index 8eb14ad..2f7dcbe 100755 --- a/scripts/setup_dotfiles.sh +++ b/scripts/setup_dotfiles.sh @@ -9,7 +9,7 @@ echo "--- Symlinking dotfiles" stow git ruby sqlite tmux vim zsh haskell emacs ssh echo "--- Install Vim plugins" -vim --clean '+source ~/.vimrc' +PluginInstall +qall +vim -es -u ~/.vimrc +PluginInstall +qall echo "--- All done!" echo "That's all. Please logout of this terminal and login again to apply all changes." \ No newline at end of file diff --git a/scripts/setup_gpg.sh b/scripts/setup_gpg.sh index 10edd80..7b5acfc 100755 --- a/scripts/setup_gpg.sh +++ b/scripts/setup_gpg.sh @@ -1,7 +1,18 @@ #!/usr/bin/env -S bash -i +copy_to_clipboard() { + if [[ "$OSTYPE" == "darwin"* ]]; then + pbcopy + elif [[ "$OSTYPE" == "linux-gnu"* ]]; then + xclip -selection clipboard + else + echo "Unsupported operating system" + exit 1 + fi +} + echo "--- Grabbing GPG Passpharse from Bitwarden to clipboard" -rbw get "GPG Passphrase" | xclip -selection clipboard +rbw get "GPG Passphrase" | copy_to_clipboard echo "--- Importing private/public key" rbw get "GPG Private/Pub Key (Ariejan)" | gpg --import