linux
change
commit dd58ffddd7233631b5801958b0c3838259844c51
author Alpha Chen <alpha.chen@brilliant.org>
date
parent a43f7d9f
diff --git a/ansible.cfg b/ansible.cfg
index b723a25..9853599 100644
--- a/ansible.cfg
+++ b/ansible.cfg
@@ -1,5 +1,5 @@
 [defaults]
-inventory = hosts.yml
+inventory = hosts.yml,hosts.local
 
 # [privilege_escalation]
 # become_ask_pass = True
diff --git a/dev/defaults.yml b/dev/defaults.yml
index 22cb7da..c29d26b 100644
--- a/dev/defaults.yml
+++ b/dev/defaults.yml
@@ -1,4 +1,4 @@
-- hosts: all
+- hosts: os_MacOSX
   tasks:
 
   - name: set OS X defaults
@@ -9,13 +9,14 @@
       value: "{{ item.value }}"
     notify: restart OS X system services
     vars:
-      mailmate_allowed_image_urls:
-        - https://((i|images|d)\.gr-assets\.com
-        - www\.goodreads\.com
-        - massdrop-s3\.imgix\.net
-        - .*\.cloudfront\.net
-        - s3\.amazonaws\.com
-        - files\.convertkitcdn\.com/assets/pictures)/.*
+      mailmate:
+        allowed_image_regexps:
+          - https://((i|images|d)\.gr-assets\.com
+          - www\.goodreads\.com
+          - massdrop-s3\.imgix\.net
+          - .*\.cloudfront\.net
+          - s3\.amazonaws\.com
+          - files\.convertkitcdn\.com/assets/pictures)/.*
     with_items:
 
     # NSGlobalDomain defaults
@@ -251,7 +252,7 @@
       - domain: com.freron.MailMate
         key: MmAllowedImageURLRegexp
         type: string
-        value: "{{ mailmate_allowed_image_urls | join('|') }}"
+        value: "{{ mailmate.allowed_image_regexps | join('|') }}"
 
       - domain: com.freron.MailMate
         key: MmSendMessageDelayEnabled
@@ -271,3 +272,5 @@
       - Finder
       - Dock
       - SystemUIServer
+
+# vim: ft=yaml.ansible
diff --git a/dev/dotfiles.yml b/dev/dotfiles.yml
index 05d1de2..0e03eb2 100644
--- a/dev/dotfiles.yml
+++ b/dev/dotfiles.yml
@@ -1,13 +1,17 @@
-- hosts: all
+- name: Sync dotfiles
+  hosts: dev
   tasks:
 
-  - name: List dotfiles
-    shell: ls -A ~/.dotfiles | grep '^\.'
-    register: ls_dotfiles
+    - name: List dotfiles # noqa: risky-shell-pipe
+      ansible.builtin.shell: ls -A ~/.dotfiles | grep '^\.'
+      register: ls_dotfiles
+      changed_when: false
 
-  - name: Symlink dotfiles
-    file:
-      src: ~/.dotfiles/{{ item }}
-      dest: ~/{{ item }}
-      state: link
-    loop:  "{{ ls_dotfiles.stdout_lines | difference(['.git', '.gitmodules']) }}"
+    - name: Symlink dotfiles
+      ansible.builtin.file:
+        src: ~/.dotfiles/{{ item }}
+        dest: ~/{{ item }}
+        state: link
+      loop: "{{ ls_dotfiles.stdout_lines | difference(['.git', '.gitmodules', '.DS_Store']) }}"
+
+# vim: ft=yaml.ansible
diff --git a/dev/homebrew.yml b/dev/homebrew.yml
index a87ac2d..09c4cc7 100644
--- a/dev/homebrew.yml
+++ b/dev/homebrew.yml
@@ -1,5 +1,5 @@
-- name: Homebrew
-  hosts: all
+- name: Install homebrew formulae
+  hosts: os_MacOSX
   tasks:
 
   - name: Install Homebrew formulae
@@ -61,6 +61,8 @@
   - name: Heed docker-compose caveats
     block:
       - name: Create Docker CLI plugins config dir
-        ansible.buitin.file:
+        ansible.builtin.file:
           dest: ~/.docker/cli-plugins
           state: directory
+
+# vim: ft=yaml.ansible
diff --git a/dev/main.yml b/dev/main.yml
index 6804cfb..c4bf637 100644
--- a/dev/main.yml
+++ b/dev/main.yml
@@ -1,44 +1,50 @@
-- hosts: all
+- name: Main playbook
+  hosts: dev
   tasks:
 
-  - group_by: key=os_{{ ansible_distribution }}
-    tags: always
-
-  - ansible.builtin.git:
-      repo: git@git.kejadlen.dev:alpha/dotfiles.git
-      dest: ~/.dotfiles.git
-      bare: true
-
-  # macOS things
-
-  # Not needed anymore since I've switched to kitty
-  #
-  # - name: Import terminal profile
-  #   ansible.builtin.command: open ~/.macos/Alpha.terminal
-  #
-  # - name: Set terminal profile to be the default
-  #   osx_defaults:
-  #     domain: com.apple.Terminal
-  #     key: "{{ item }} Window Settings"
-  #     type: string
-  #     value: Alpha
-  #   with_items:
-  #     - Default
-  #     - Startup
-
-- import_playbook: homebrew.yml
-
-- import_playbook: defaults.yml
-- import_playbook: dock.yml
-- import_playbook: macos.yml
-
-- hosts: all
+    - name: Group by OS
+      ansible.builtin.group_by:
+        key: os_{{ ansible_distribution }}
+
+    - name: Check out dotfiles
+      ansible.builtin.git:
+        repo: git@git.kejadlen.dev:alpha/dotfiles.git
+        dest: ~/.dotfiles
+        version: main
+        accept_newhostkey: true
+      # repo can have local changes
+      ignore_errors: true # noqa: ignore-errors
+
+- name: Import dotfiles playbook
+  import_playbook: dotfiles.yml
+
+# First since this installs tooling used later
+- name: Import homebrew playbook
+  import_playbook: homebrew.yml
+
+- name: Import defaults playbook
+  import_playbook: defaults.yml
+
+- name: Import dock playbook
+  import_playbook: dock.yml
+
+- name: Import macos playbook
+  import_playbook: macos.yml
+
+- name: Misc macOS things
+  hosts: os_MacOSX
   tasks:
+
     # https://tratt.net/laurie/blog/2024/faster_shell_startup_with_shell_switching.html
+    # I'm not sure why this doesn't work on my Linux box, but whatever
     - name: Set default shell to sh
-      user:
+      ansible.builtin.user:
         name: alpha
         shell: /bin/sh --login
-    - ansible.builtin.command: "luarocks install fennel"
+
+    - name: Install Fennel
+      ansible.builtin.command: "luarocks install fennel"
+      args:
+        creates: /opt/homebrew/bin/fennel
 
 # vim: ft=yaml.ansible
diff --git a/hosts.yml b/hosts.yml
index e2e8d5e..342d40e 100644
--- a/hosts.yml
+++ b/hosts.yml
@@ -8,3 +8,6 @@ all:
       ansible_python_interpreter: /usr/bin/python3
     on-fire-within:
     lotus-land-story:
+dev:
+  hosts:
+    localhost: