From 47522e83823850ecb86f49b4f689c9c833a70e7a Mon Sep 17 00:00:00 2001 From: Scott Wallace Date: Sun, 20 Jan 2019 17:09:09 +0000 Subject: [PATCH] Re-jig 'desktop' for Ansible --- .ansible/desktop.yaml | 10 ++---- .../files/iterm2/com.googlecode.iterm2.plist | 0 .../files/iterm2/hybrid.itermcolors | 0 .../files/iterm2/shell_integration.bash | 0 .ansible/roles/desktop/meta/main.yaml | 3 ++ .../roles/{linux_desktop => desktop}/notes.md | 0 .../tasks/config.yaml | 0 .../tasks/firefox.yaml | 9 +++-- .../tasks/homebrew.yaml | 0 .ansible/roles/desktop/tasks/main.yaml | 15 ++++++++ .../{mac_desktop => desktop}/tasks/mas.yaml | 0 .../{mac_desktop => desktop}/tasks/prefs.yaml | 35 +++---------------- .../tasks/software.yaml | 0 .../templates/conkyrc.j2 | 0 .../main.yaml => desktop/vars/darwin.yaml} | 0 .../main.yaml => desktop/vars/linux.yaml} | 0 .ansible/roles/linux_desktop/tasks/main.yaml | 4 --- .ansible/roles/mac_desktop/tasks/main.yaml | 4 --- 18 files changed, 32 insertions(+), 48 deletions(-) rename .ansible/roles/{mac_desktop => desktop}/files/iterm2/com.googlecode.iterm2.plist (100%) rename .ansible/roles/{mac_desktop => desktop}/files/iterm2/hybrid.itermcolors (100%) rename .ansible/roles/{mac_desktop => desktop}/files/iterm2/shell_integration.bash (100%) create mode 100644 .ansible/roles/desktop/meta/main.yaml rename .ansible/roles/{linux_desktop => desktop}/notes.md (100%) rename .ansible/roles/{linux_desktop => desktop}/tasks/config.yaml (100%) rename .ansible/roles/{linux_desktop => desktop}/tasks/firefox.yaml (83%) rename .ansible/roles/{mac_desktop => desktop}/tasks/homebrew.yaml (100%) create mode 100644 .ansible/roles/desktop/tasks/main.yaml rename .ansible/roles/{mac_desktop => desktop}/tasks/mas.yaml (100%) rename .ansible/roles/{mac_desktop => desktop}/tasks/prefs.yaml (72%) rename .ansible/roles/{linux_desktop => desktop}/tasks/software.yaml (100%) rename .ansible/roles/{linux_desktop => desktop}/templates/conkyrc.j2 (100%) rename .ansible/roles/{mac_desktop/vars/main.yaml => desktop/vars/darwin.yaml} (100%) rename .ansible/roles/{linux_desktop/vars/main.yaml => desktop/vars/linux.yaml} (100%) delete mode 100644 .ansible/roles/linux_desktop/tasks/main.yaml delete mode 100644 .ansible/roles/mac_desktop/tasks/main.yaml diff --git a/.ansible/desktop.yaml b/.ansible/desktop.yaml index dac80e7..fa0d143 100644 --- a/.ansible/desktop.yaml +++ b/.ansible/desktop.yaml @@ -1,10 +1,6 @@ - name: Desktop installation and configuration hosts: desktop - roles: - - role: linux_desktop - when: ansible_system == 'Linux' - - role: jaredhocutt.gnome_extensions - when: ansible_system == 'Linux' - - role: mac_desktop - when: ansible_system == 'Darwin' + - role: desktop + vars_files: + - "roles/desktop/vars/{{ ansible_system|lower }}.yaml" diff --git a/.ansible/roles/mac_desktop/files/iterm2/com.googlecode.iterm2.plist b/.ansible/roles/desktop/files/iterm2/com.googlecode.iterm2.plist similarity index 100% rename from .ansible/roles/mac_desktop/files/iterm2/com.googlecode.iterm2.plist rename to .ansible/roles/desktop/files/iterm2/com.googlecode.iterm2.plist diff --git a/.ansible/roles/mac_desktop/files/iterm2/hybrid.itermcolors b/.ansible/roles/desktop/files/iterm2/hybrid.itermcolors similarity index 100% rename from .ansible/roles/mac_desktop/files/iterm2/hybrid.itermcolors rename to .ansible/roles/desktop/files/iterm2/hybrid.itermcolors diff --git a/.ansible/roles/mac_desktop/files/iterm2/shell_integration.bash b/.ansible/roles/desktop/files/iterm2/shell_integration.bash similarity index 100% rename from .ansible/roles/mac_desktop/files/iterm2/shell_integration.bash rename to .ansible/roles/desktop/files/iterm2/shell_integration.bash diff --git a/.ansible/roles/desktop/meta/main.yaml b/.ansible/roles/desktop/meta/main.yaml new file mode 100644 index 0000000..a2dd7ca --- /dev/null +++ b/.ansible/roles/desktop/meta/main.yaml @@ -0,0 +1,3 @@ +dependencies: + - role: jaredhocutt.gnome_extensions + when: ansible_system == 'Linux' diff --git a/.ansible/roles/linux_desktop/notes.md b/.ansible/roles/desktop/notes.md similarity index 100% rename from .ansible/roles/linux_desktop/notes.md rename to .ansible/roles/desktop/notes.md diff --git a/.ansible/roles/linux_desktop/tasks/config.yaml b/.ansible/roles/desktop/tasks/config.yaml similarity index 100% rename from .ansible/roles/linux_desktop/tasks/config.yaml rename to .ansible/roles/desktop/tasks/config.yaml diff --git a/.ansible/roles/linux_desktop/tasks/firefox.yaml b/.ansible/roles/desktop/tasks/firefox.yaml similarity index 83% rename from .ansible/roles/linux_desktop/tasks/firefox.yaml rename to .ansible/roles/desktop/tasks/firefox.yaml index 937cbb4..196c9f7 100644 --- a/.ansible/roles/linux_desktop/tasks/firefox.yaml +++ b/.ansible/roles/desktop/tasks/firefox.yaml @@ -2,8 +2,13 @@ tags: - config - firefox - set_fact: - firefox_path: '~/.mozilla/firefox' + block: + - set_fact: + firefox_path: '~/.mozilla/firefox' + when: ansible_system == 'Linux' + - set_fact: + firefox_path: '~/Library/Application Support/Firefox' + when: ansible_system == 'Darwin' - name: 'Firefox: Discover profile path' tags: diff --git a/.ansible/roles/mac_desktop/tasks/homebrew.yaml b/.ansible/roles/desktop/tasks/homebrew.yaml similarity index 100% rename from .ansible/roles/mac_desktop/tasks/homebrew.yaml rename to .ansible/roles/desktop/tasks/homebrew.yaml diff --git a/.ansible/roles/desktop/tasks/main.yaml b/.ansible/roles/desktop/tasks/main.yaml new file mode 100644 index 0000000..d143070 --- /dev/null +++ b/.ansible/roles/desktop/tasks/main.yaml @@ -0,0 +1,15 @@ +- name: Common desktop tasks + import_tasks: firefox.yaml + +- name: Linux desktop tasks + block: + - import_tasks: software.yaml + - import_tasks: config.yaml + when: ansible_system == 'Linux' + +- name: OS X desktop tasks + block: + - import_tasks: homebrew.yaml + - import_tasks: mas.yaml + - import_tasks: prefs.yaml + when: ansible_system == 'Darwin' diff --git a/.ansible/roles/mac_desktop/tasks/mas.yaml b/.ansible/roles/desktop/tasks/mas.yaml similarity index 100% rename from .ansible/roles/mac_desktop/tasks/mas.yaml rename to .ansible/roles/desktop/tasks/mas.yaml diff --git a/.ansible/roles/mac_desktop/tasks/prefs.yaml b/.ansible/roles/desktop/tasks/prefs.yaml similarity index 72% rename from .ansible/roles/mac_desktop/tasks/prefs.yaml rename to .ansible/roles/desktop/tasks/prefs.yaml index cf5ab75..ef4b851 100644 --- a/.ansible/roles/mac_desktop/tasks/prefs.yaml +++ b/.ansible/roles/desktop/tasks/prefs.yaml @@ -1,17 +1,19 @@ -- name: 'iTerm2: Add configuration' +- name: 'Shell: Add iTerm2 configuration' tags: - config - iterm2 + - shell template: src: "iterm2/{{ item }}" dest: '~/.iterm2' mode: '0600' loop: ['com.googlecode.iterm2.plist', 'hybrid.itermcolors'] -- name: 'Iterm2: Shell integration' +- name: 'Shell: iTerm2 Bash integration' tags: - config - iterm2 + - shell copy: src: 'iterm2/shell_integration.bash' dest: '~/.bashrc.d' @@ -38,35 +40,6 @@ dest: '~/.bashrc.d/alias.gnu' mode: '0400' -- name: 'Firefox: Set base path' - tags: - - config - - firefox - - browser - set_fact: - firefox_path: '~/Library/Application Support/Firefox' - -- name: 'Firefox: Find profile path' - tags: - - config - - firefox - - browser - set_fact: - profile_path: "{{ lookup('ini', 'Path section=Profile0 file=' + firefox_path + '/profiles.ini') }}" - -- name: 'Firefox: Add local config' - tags: - - config - - firefox - - browser - copy: - content: | - user_pref("geo.enabled", false); - user_pref("privacy.window.maxInnerWidth", 1400); - user_pref("privacy.window.maxInnerHeight", 900); - dest: "{{ firefox_path }}/{{ profile_path }}/user.js" - mode: '0600' - - name: 'OS X: Preferences' tags: - config diff --git a/.ansible/roles/linux_desktop/tasks/software.yaml b/.ansible/roles/desktop/tasks/software.yaml similarity index 100% rename from .ansible/roles/linux_desktop/tasks/software.yaml rename to .ansible/roles/desktop/tasks/software.yaml diff --git a/.ansible/roles/linux_desktop/templates/conkyrc.j2 b/.ansible/roles/desktop/templates/conkyrc.j2 similarity index 100% rename from .ansible/roles/linux_desktop/templates/conkyrc.j2 rename to .ansible/roles/desktop/templates/conkyrc.j2 diff --git a/.ansible/roles/mac_desktop/vars/main.yaml b/.ansible/roles/desktop/vars/darwin.yaml similarity index 100% rename from .ansible/roles/mac_desktop/vars/main.yaml rename to .ansible/roles/desktop/vars/darwin.yaml diff --git a/.ansible/roles/linux_desktop/vars/main.yaml b/.ansible/roles/desktop/vars/linux.yaml similarity index 100% rename from .ansible/roles/linux_desktop/vars/main.yaml rename to .ansible/roles/desktop/vars/linux.yaml diff --git a/.ansible/roles/linux_desktop/tasks/main.yaml b/.ansible/roles/linux_desktop/tasks/main.yaml deleted file mode 100644 index e43fe9c..0000000 --- a/.ansible/roles/linux_desktop/tasks/main.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Linux desktop tasks - import_tasks: software.yaml -- import_tasks: config.yaml -- import_tasks: firefox.yaml diff --git a/.ansible/roles/mac_desktop/tasks/main.yaml b/.ansible/roles/mac_desktop/tasks/main.yaml deleted file mode 100644 index 3b489a1..0000000 --- a/.ansible/roles/mac_desktop/tasks/main.yaml +++ /dev/null @@ -1,4 +0,0 @@ -- name: Mac desktop tasks - import_tasks: homebrew.yaml -- import_tasks: mas.yaml -- import_tasks: prefs.yaml