From 70f0de3ac6dea8cb4cc3bd11d2ffb67e0458bd2e Mon Sep 17 00:00:00 2001 From: dspolleke Date: Sun, 11 Apr 2021 19:57:38 +0200 Subject: [PATCH 01/14] fix tags issue 97 --- tasks/extra-packages.yml | 69 +++++++++++++++++++++------------------- tasks/osx.yml | 1 + 2 files changed, 37 insertions(+), 33 deletions(-) diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml index 643cd41..9d283c2 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -1,34 +1,37 @@ --- -- name: Install global Composer packages. - composer: - command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" - arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}" - # Ansible 2.4 supports `global_command` making `working_dir` optional. - working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" - with_items: "{{ composer_packages }}" - -- name: Install global NPM packages. - npm: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - global: true - executable: "{{ item.executable | default(omit) }}" - with_items: "{{ npm_packages }}" - -- name: Install global Pip packages. - pip: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - executable: "{{ item.executable | default(omit) }}" - with_items: "{{ pip_packages }}" - -- name: Install global Ruby gems. - gem: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - user_install: false - executable: "{{ item.executable | default(omit) }}" - with_items: "{{ gem_packages }}" +- name: Ensure extra packages + block: + - name: Install global Composer packages. + composer: + command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" + arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}" + # Ansible 2.4 supports `global_command` making `working_dir` optional. + working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" + loop: "{{ composer_packages }}" + + - name: Install global NPM packages. + npm: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + global: true + executable: "{{ item.executable | default(omit) }}" + loop: "{{ npm_packages }}" + + - name: Install global Pip packages. + pip: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + executable: "{{ item.executable | default(omit) }}" + loop: "{{ pip_packages }}" + + - name: Install global Ruby gems. + gem: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + user_install: false + executable: "{{ item.executable | default(omit) }}" + loop: "{{ gem_packages }}" + tags: ['extra-packages'] diff --git a/tasks/osx.yml b/tasks/osx.yml index ec12cd5..c6c5b45 100644 --- a/tasks/osx.yml +++ b/tasks/osx.yml @@ -3,3 +3,4 @@ - name: Run .osx dotfiles. command: "{{ osx_script }}" changed_when: false + tags: ['osx'] From be8b356174ca6d6c200cb408c00acd99e33023a4 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Sun, 11 Apr 2021 20:16:05 +0200 Subject: [PATCH 02/14] trailing spaces --- tasks/extra-packages.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml index 9d283c2..d55f78a 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -8,7 +8,7 @@ # Ansible 2.4 supports `global_command` making `working_dir` optional. working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" loop: "{{ composer_packages }}" - + - name: Install global NPM packages. npm: name: "{{ item.name | default(item) }}" @@ -17,7 +17,7 @@ global: true executable: "{{ item.executable | default(omit) }}" loop: "{{ npm_packages }}" - + - name: Install global Pip packages. pip: name: "{{ item.name | default(item) }}" @@ -25,7 +25,7 @@ version: "{{ item.version | default(omit) }}" executable: "{{ item.executable | default(omit) }}" loop: "{{ pip_packages }}" - + - name: Install global Ruby gems. gem: name: "{{ item.name | default(item) }}" From 4dc3e75de2268c9e3779e6ab9dc1aca4dbb3ae71 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Sun, 11 Apr 2021 20:44:58 +0200 Subject: [PATCH 03/14] dock util from https://github.com/enlewof \n Fixed default value for variable, \ncreated block (for tags to work), \nFixed some strong language, \N fixed some shell / command preference (ansible-lint) --- default.config.yml | 2 ++ main.yml | 4 ++++ tasks/dock.yml | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 tasks/dock.yml diff --git a/default.config.yml b/default.config.yml index 8293cc7..82effb6 100644 --- a/default.config.yml +++ b/default.config.yml @@ -5,6 +5,8 @@ configure_dotfiles: true configure_terminal: true configure_osx: true +configure_dock: [] + configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/main.yml b/main.yml index b35b077..75521fc 100644 --- a/main.yml +++ b/main.yml @@ -37,6 +37,10 @@ - include_tasks: tasks/extra-packages.yml tags: ['extra-packages'] + - include_tasks: tasks/dock.yml + when: configure_dock + tags: ['dock'] + - name: Run configured post-provision ansible task files. include_tasks: "{{ outer_item }}" loop_control: diff --git a/tasks/dock.yml b/tasks/dock.yml new file mode 100644 index 0000000..51c3a26 --- /dev/null +++ b/tasks/dock.yml @@ -0,0 +1,23 @@ +--- +- name: ensure dock items + block: + - name: Install dockutil + homebrew: + name: dockutil + state: present + notify: + - Clear homebrew cache + + - name: Ensure unwanted dock items removed. + command: dockutil --remove '{{ item }}' + ignore_errors: true + loop: "{{ dockitems_to_remove }}" + + - name: Ensure required dock items exist. + shell: dockutil --find '{{ item.name }}' || dockutil --add '{{ item.path }}' + loop: "{{ dockitems_to_persist }}" + + - name: Ensure correct dock order + command: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' + loop: "{{ dockitems_to_persist }}" + tags: ['dock'] From 299c9b7b69ee9373dc105ef845f8497e8276bee2 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 13:29:34 +0200 Subject: [PATCH 04/14] working dockutil --- ansible.cfg | 2 ++ default.config.yml | 25 +++++++++++++++++++++++-- tasks/adddock.yml | 13 +++++++++++++ tasks/dock.yml | 17 ++++++++++------- tasks/remdock.yml | 14 ++++++++++++++ 5 files changed, 62 insertions(+), 9 deletions(-) create mode 100644 tasks/adddock.yml create mode 100644 tasks/remdock.yml diff --git a/ansible.cfg b/ansible.cfg index 1b00cf9..a6e277c 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,5 @@ [defaults] nocows = True roles_path = ./roles:/etc/ansible/roles +stdout_callback = yaml + diff --git a/default.config.yml b/default.config.yml index 82effb6..29ca56c 100644 --- a/default.config.yml +++ b/default.config.yml @@ -5,8 +5,29 @@ configure_dotfiles: true configure_terminal: true configure_osx: true -configure_dock: [] - +configure_dock: True +dockitems_to_remove: + - Launchpad + - Safari + - Messages + - Mail + - Maps + - Photos + - FaceTime + - Calendar + - Contacts + - Reminders + - Notes + - TV + - Music + - Podcasts + - 'App Store' +remove_spacers: true +dockitems_to_persist: + - name: iTerm + path: "/Applications/iTerm.app/" + - name: "Google Chrome" + path: "/Applications/Google Chrome.app/" configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/tasks/adddock.yml b/tasks/adddock.yml new file mode 100644 index 0000000..40568aa --- /dev/null +++ b/tasks/adddock.yml @@ -0,0 +1,13 @@ +--- +- name: find if dock {{ item }} exists + ansible.builtin.command: + cmd: dockutil --find '{{ item.name }}' + register: dockitem_exists + failed_when: '"No such file or directory" in dockitem_exists.stdout' + changed_when: false + tags: ['dock'] +- name: Ensure dock {{ item }} exists + ansible.builtin.command: + cmd: dockutil --add '{{ item.path }}' + when: dockitem_exists.rc >0 + tags: ['dock'] diff --git a/tasks/dock.yml b/tasks/dock.yml index 51c3a26..627738d 100644 --- a/tasks/dock.yml +++ b/tasks/dock.yml @@ -7,17 +7,20 @@ state: present notify: - Clear homebrew cache - - - name: Ensure unwanted dock items removed. - command: dockutil --remove '{{ item }}' - ignore_errors: true + - name: remove dockitems + ansible.builtin.include_tasks: tasks/remdock.yml loop: "{{ dockitems_to_remove }}" - name: Ensure required dock items exist. - shell: dockutil --find '{{ item.name }}' || dockutil --add '{{ item.path }}' - loop: "{{ dockitems_to_persist }}" + ansible.builtin.include_tasks: tasks/adddock.yml + with_items: "{{ dockitems_to_persist }}" - name: Ensure correct dock order - command: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' + ansible.builtin.command: + cmd: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' + when: + - item.pos is defined + - item.pos length >0 loop: "{{ dockitems_to_persist }}" + tags: ['dock'] diff --git a/tasks/remdock.yml b/tasks/remdock.yml new file mode 100644 index 0000000..777a00d --- /dev/null +++ b/tasks/remdock.yml @@ -0,0 +1,14 @@ +--- +- name: find if dock item exists + ansible.builtin.command: + cmd: dockutil --find '{{ item }}' + register: dockitem_exists + changed_when: false + failed_when: '"No such file or directory" in dockitem_exists.stdout' + tags: ['dock'] +- name: Ensure unwanted dock items removed. + ansible.builtin.command: + cmd: dockutil --remove '{{ item }}' + when: dockitem_exists.rc == 0 + tags: ['dock'] + From 82979a7b302dabe903ab4fd83f39a610a172e716 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 13:49:12 +0200 Subject: [PATCH 05/14] yamllinter --- default.config.yml | 10 +++++----- tasks/dock.yml | 2 +- tasks/remdock.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/default.config.yml b/default.config.yml index 29ca56c..394f00f 100644 --- a/default.config.yml +++ b/default.config.yml @@ -5,7 +5,7 @@ configure_dotfiles: true configure_terminal: true configure_osx: true -configure_dock: True +configure_dock: true dockitems_to_remove: - Launchpad - Safari @@ -24,10 +24,10 @@ dockitems_to_remove: - 'App Store' remove_spacers: true dockitems_to_persist: - - name: iTerm - path: "/Applications/iTerm.app/" - - name: "Google Chrome" - path: "/Applications/Google Chrome.app/" + - name: iTerm + path: "/Applications/iTerm.app/" + - name: "Google Chrome" + path: "/Applications/Google Chrome.app/" configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/tasks/dock.yml b/tasks/dock.yml index 627738d..20cebd0 100644 --- a/tasks/dock.yml +++ b/tasks/dock.yml @@ -16,7 +16,7 @@ with_items: "{{ dockitems_to_persist }}" - name: Ensure correct dock order - ansible.builtin.command: + ansible.builtin.command: cmd: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' when: - item.pos is defined diff --git a/tasks/remdock.yml b/tasks/remdock.yml index 777a00d..c22bd0d 100644 --- a/tasks/remdock.yml +++ b/tasks/remdock.yml @@ -6,9 +6,9 @@ changed_when: false failed_when: '"No such file or directory" in dockitem_exists.stdout' tags: ['dock'] + - name: Ensure unwanted dock items removed. ansible.builtin.command: cmd: dockutil --remove '{{ item }}' when: dockitem_exists.rc == 0 tags: ['dock'] - From eae5de681ff1f6865156ab3b1d5df6ee2c870226 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 15:15:57 +0200 Subject: [PATCH 06/14] fix terminal to run with remote tasks as well --- main.yml | 3 ++- tasks/terminal.yml | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/main.yml b/main.yml index 75521fc..18c2517 100644 --- a/main.yml +++ b/main.yml @@ -27,8 +27,9 @@ - include_tasks: tasks/sudoers.yml when: configure_sudoers - - include_tasks: tasks/terminal.yml + - import_tasks: tasks/terminal.yml when: configure_terminal + tags: ['terminal'] - include_tasks: tasks/osx.yml when: configure_osx diff --git a/tasks/terminal.yml b/tasks/terminal.yml index 3807ab6..528aec4 100644 --- a/tasks/terminal.yml +++ b/tasks/terminal.yml @@ -7,7 +7,14 @@ check_mode: false - name: Ensure custom Terminal profile is added. - command: open files/terminal/JJG-Term.terminal + ansible.builtin.copy: + src: files/terminal/JJG-Term.terminal + dest: /tmp/JJG-Term.terminal + changed_when: false + when: "'JJG-Term' not in terminal_theme.stdout" + +- name: Ensure custom Terminal profile is added. + command: open /tmp/JJG-Term.terminal changed_when: false when: "'JJG-Term' not in terminal_theme.stdout" From 6549a14014711db8e8554178897dca5028114e77 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 17:37:55 +0200 Subject: [PATCH 07/14] requested changes --- default.config.yml | 42 ++++++++++++++++++++++-------------------- main.yml | 2 +- tasks/dock.yml | 42 +++++++++++++++++++----------------------- 3 files changed, 42 insertions(+), 44 deletions(-) diff --git a/default.config.yml b/default.config.yml index 394f00f..1d90117 100644 --- a/default.config.yml +++ b/default.config.yml @@ -5,29 +5,31 @@ configure_dotfiles: true configure_terminal: true configure_osx: true -configure_dock: true -dockitems_to_remove: - - Launchpad - - Safari - - Messages - - Mail - - Maps - - Photos - - FaceTime - - Calendar - - Contacts - - Reminders - - Notes - - TV - - Music - - Podcasts - - 'App Store' -remove_spacers: true +configure_dock: false +dockitems_to_remove: [] +# Example: to remove all / some items added by default on Big Sur uncomment use example below +# dockitems_to_remove: +# - Launchpad +# - Safari +# - Messages +# - Mail +# - Maps +# - Photos +# - FaceTime +# - Calendar +# - Contacts +# - Reminders +# - Notes +# - TV +# - Music +# - Podcasts +# - 'App Store' + dockitems_to_persist: - - name: iTerm - path: "/Applications/iTerm.app/" - name: "Google Chrome" path: "/Applications/Google Chrome.app/" + - name: "Sublime Text" + path: "/Applications/Sublime Text.app/" configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/main.yml b/main.yml index 75521fc..15a253c 100644 --- a/main.yml +++ b/main.yml @@ -37,7 +37,7 @@ - include_tasks: tasks/extra-packages.yml tags: ['extra-packages'] - - include_tasks: tasks/dock.yml + - import_tasks: tasks/dock.yml when: configure_dock tags: ['dock'] diff --git a/tasks/dock.yml b/tasks/dock.yml index 20cebd0..c617e46 100644 --- a/tasks/dock.yml +++ b/tasks/dock.yml @@ -1,26 +1,22 @@ --- -- name: ensure dock items - block: - - name: Install dockutil - homebrew: - name: dockutil - state: present - notify: - - Clear homebrew cache - - name: remove dockitems - ansible.builtin.include_tasks: tasks/remdock.yml - loop: "{{ dockitems_to_remove }}" +- name: Install dockutil + homebrew: + name: dockutil + state: present + notify: + - Clear homebrew cache +- name: remove dockitems + ansible.builtin.include_tasks: tasks/remdock.yml + loop: "{{ dockitems_to_remove }}" - - name: Ensure required dock items exist. - ansible.builtin.include_tasks: tasks/adddock.yml - with_items: "{{ dockitems_to_persist }}" +- name: Ensure required dock items exist. + ansible.builtin.include_tasks: tasks/adddock.yml + with_items: "{{ dockitems_to_persist }}" - - name: Ensure correct dock order - ansible.builtin.command: - cmd: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' - when: - - item.pos is defined - - item.pos length >0 - loop: "{{ dockitems_to_persist }}" - - tags: ['dock'] +- name: Ensure correct dock order + ansible.builtin.command: + cmd: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' + when: + - item.pos is defined + - item.pos length >0 + loop: "{{ dockitems_to_persist }}" From 34cc100e7c5f92af0ecf238b3d9d04f150dda60c Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 17:43:47 +0200 Subject: [PATCH 08/14] fixed it the way GG wants it fixed --- main.yml | 16 ++++++---- tasks/extra-packages.yml | 63 +++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/main.yml b/main.yml index b35b077..6296dc2 100644 --- a/main.yml +++ b/main.yml @@ -22,23 +22,27 @@ tags: ['mas'] tasks: - - include_tasks: tasks/ansible-setup.yml + - import_tasks: tasks/ansible-setup.yml + tags: ['setup'] - - include_tasks: tasks/sudoers.yml + - import_tasks: tasks/sudoers.yml when: configure_sudoers + tags: ['sudoers'] - - include_tasks: tasks/terminal.yml + - import_tasks: tasks/terminal.yml when: configure_terminal + tags: ['terminal'] - - include_tasks: tasks/osx.yml + - import_tasks: tasks/osx.yml when: configure_osx tags: ['osx'] - - include_tasks: tasks/extra-packages.yml + - import_tasks: tasks/extra-packages.yml tags: ['extra-packages'] - name: Run configured post-provision ansible task files. - include_tasks: "{{ outer_item }}" + import_tasks: "{{ outer_item }}" loop_control: loop_var: outer_item with_fileglob: "{{ post_provision_tasks|default(omit) }}" + tags: ['post'] diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml index d55f78a..677148b 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -1,37 +1,34 @@ --- -- name: Ensure extra packages - block: - - name: Install global Composer packages. - composer: - command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" - arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}" - # Ansible 2.4 supports `global_command` making `working_dir` optional. - working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" - loop: "{{ composer_packages }}" +- name: Install global Composer packages. + composer: + command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" + arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}" + # Ansible 2.4 supports `global_command` making `working_dir` optional. + working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" + loop: "{{ composer_packages }}" - - name: Install global NPM packages. - npm: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - global: true - executable: "{{ item.executable | default(omit) }}" - loop: "{{ npm_packages }}" +- name: Install global NPM packages. + npm: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + global: true + executable: "{{ item.executable | default(omit) }}" + loop: "{{ npm_packages }}" - - name: Install global Pip packages. - pip: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - executable: "{{ item.executable | default(omit) }}" - loop: "{{ pip_packages }}" +- name: Install global Pip packages. + pip: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + executable: "{{ item.executable | default(omit) }}" + loop: "{{ pip_packages }}" - - name: Install global Ruby gems. - gem: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - user_install: false - executable: "{{ item.executable | default(omit) }}" - loop: "{{ gem_packages }}" - tags: ['extra-packages'] +- name: Install global Ruby gems. + gem: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + user_install: false + executable: "{{ item.executable | default(omit) }}" + loop: "{{ gem_packages }}" From 5ecb26666df736a124efa736c44f6ceaf5e6f473 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 17:44:54 +0200 Subject: [PATCH 09/14] alien changes ;-) --- tasks/extra-packages.yml | 63 +++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml index d55f78a..677148b 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -1,37 +1,34 @@ --- -- name: Ensure extra packages - block: - - name: Install global Composer packages. - composer: - command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" - arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}" - # Ansible 2.4 supports `global_command` making `working_dir` optional. - working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" - loop: "{{ composer_packages }}" +- name: Install global Composer packages. + composer: + command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" + arguments: "{{ item.name | default(item) }} {{ item.version | default('@stable') }}" + # Ansible 2.4 supports `global_command` making `working_dir` optional. + working_dir: "{{ lookup('env', 'COMPOSER_HOME') | default('~/.composer', true) }}" + loop: "{{ composer_packages }}" - - name: Install global NPM packages. - npm: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - global: true - executable: "{{ item.executable | default(omit) }}" - loop: "{{ npm_packages }}" +- name: Install global NPM packages. + npm: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + global: true + executable: "{{ item.executable | default(omit) }}" + loop: "{{ npm_packages }}" - - name: Install global Pip packages. - pip: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - executable: "{{ item.executable | default(omit) }}" - loop: "{{ pip_packages }}" +- name: Install global Pip packages. + pip: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + executable: "{{ item.executable | default(omit) }}" + loop: "{{ pip_packages }}" - - name: Install global Ruby gems. - gem: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - user_install: false - executable: "{{ item.executable | default(omit) }}" - loop: "{{ gem_packages }}" - tags: ['extra-packages'] +- name: Install global Ruby gems. + gem: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + user_install: false + executable: "{{ item.executable | default(omit) }}" + loop: "{{ gem_packages }}" From 8e9b8de4cfc0dd49c4182c838580acdb31045775 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 18:56:21 +0200 Subject: [PATCH 10/14] conditionals are hard --- default.config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.config.yml b/default.config.yml index 1d90117..e602917 100644 --- a/default.config.yml +++ b/default.config.yml @@ -5,7 +5,7 @@ configure_dotfiles: true configure_terminal: true configure_osx: true -configure_dock: false +configure_dock: [] dockitems_to_remove: [] # Example: to remove all / some items added by default on Big Sur uncomment use example below # dockitems_to_remove: From beac53608e85b3bc1880ebb1f91ce78c59280525 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 19:13:23 +0200 Subject: [PATCH 11/14] imclude_tasks are sometimes useful --- main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.yml b/main.yml index 6296dc2..caf41f8 100644 --- a/main.yml +++ b/main.yml @@ -41,7 +41,7 @@ tags: ['extra-packages'] - name: Run configured post-provision ansible task files. - import_tasks: "{{ outer_item }}" + include_tasks: "{{ outer_item }}" loop_control: loop_var: outer_item with_fileglob: "{{ post_provision_tasks|default(omit) }}" From 7d351f718f64315b7d367ea1ee270a8801dbb69c Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 20:00:00 +0200 Subject: [PATCH 12/14] edited Readme to reflect work allready done. Removed some work obviously already done. I am working on the vim stuff and sublime stuff. Did you allready put the mouse tracking in de .osx file? do you know of any way to configure the mentioned accounts on the cli? --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 710174b..a7126e4 100644 --- a/README.md +++ b/README.md @@ -144,13 +144,11 @@ Finally, there are a few other preferences and settings added on for various app It's my hope that I can get the rest of these things wrapped up into Ansible playbooks soon, but for now, these steps need to be completed manually (assuming you already have Xcode and Ansible installed, and have run this playbook). - 1. Set JJG-Term as the default Terminal theme (it's installed, but not set as default automatically). - 2. Install [Sublime Package Manager](http://sublime.wbond.net/installation). - 3. Install all the apps that aren't yet in this setup (see below). - 4. Remap Caps Lock to Escape (requires macOS Sierra 10.12.1+). - 5. Set trackpad tracking rate. - 6. Set mouse tracking rate. - 7. Configure extra Mail and/or Calendar accounts (e.g. Google, Exchange, etc.). + 1. Install [Sublime Package Manager](http://sublime.wbond.net/installation). + 2. Remap Caps Lock to Escape (requires macOS Sierra 10.12.1+). + 3. Set trackpad tracking rate. + 4. Set mouse tracking rate. + 5. Configure extra Mail and/or Calendar accounts (e.g. Google, Exchange, etc.). ### Configuration to be added: From f9f2d54e8c85d9a2a6789fdf5be8d3e006de7418 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 7 May 2021 10:26:27 -0500 Subject: [PATCH 13/14] PR #106 follow-up: More consistent docs and examples. --- README.md | 4 +++ ansible.cfg | 1 - default.config.yml | 34 ++++++++------------------ main.yml | 10 ++++---- tasks/adddock.yml | 13 ---------- tasks/dock-add.yml | 12 +++++++++ tasks/{remdock.yml => dock-remove.yml} | 0 tasks/dock.yml | 17 +++++++------ tasks/osx.yml | 1 - 9 files changed, 40 insertions(+), 52 deletions(-) delete mode 100644 tasks/adddock.yml create mode 100644 tasks/dock-add.yml rename tasks/{remdock.yml => dock-remove.yml} (100%) diff --git a/README.md b/README.md index a7126e4..a2276e7 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,10 @@ You can override any of the defaults configured in `default.config.yml` by creat pip_packages: - name: mkdocs + + configure_dock: true + dockitems_remove: [] + dockitems_persist: [] Any variable can be overridden in `config.yml`; see the supporting roles' documentation for a complete list of available variables. diff --git a/ansible.cfg b/ansible.cfg index a6e277c..a823e99 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -2,4 +2,3 @@ nocows = True roles_path = ./roles:/etc/ansible/roles stdout_callback = yaml - diff --git a/default.config.yml b/default.config.yml index e602917..b62bdfc 100644 --- a/default.config.yml +++ b/default.config.yml @@ -5,31 +5,17 @@ configure_dotfiles: true configure_terminal: true configure_osx: true -configure_dock: [] -dockitems_to_remove: [] -# Example: to remove all / some items added by default on Big Sur uncomment use example below -# dockitems_to_remove: -# - Launchpad -# - Safari -# - Messages -# - Mail -# - Maps -# - Photos -# - FaceTime -# - Calendar -# - Contacts -# - Reminders -# - Notes -# - TV -# - Music -# - Podcasts -# - 'App Store' +# Set to 'true' to configure the Dock via dockutil. +configure_dock: false +dockitems_remove: [] +# - Launchpad +# - TV +# - Podcasts +# - 'App Store' +dockitems_persist: [] +# - name: "Sublime Text" +# path: "/Applications/Sublime Text.app/" -dockitems_to_persist: - - name: "Google Chrome" - path: "/Applications/Google Chrome.app/" - - name: "Sublime Text" - path: "/Applications/Sublime Text.app/" configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/main.yml b/main.yml index 15a253c..9b6f8da 100644 --- a/main.yml +++ b/main.yml @@ -22,19 +22,19 @@ tags: ['mas'] tasks: - - include_tasks: tasks/ansible-setup.yml + - import_tasks: tasks/ansible-setup.yml - - include_tasks: tasks/sudoers.yml + - import_tasks: tasks/sudoers.yml when: configure_sudoers - - include_tasks: tasks/terminal.yml + - import_tasks: tasks/terminal.yml when: configure_terminal - - include_tasks: tasks/osx.yml + - import_tasks: tasks/osx.yml when: configure_osx tags: ['osx'] - - include_tasks: tasks/extra-packages.yml + - import_tasks: tasks/extra-packages.yml tags: ['extra-packages'] - import_tasks: tasks/dock.yml diff --git a/tasks/adddock.yml b/tasks/adddock.yml deleted file mode 100644 index 40568aa..0000000 --- a/tasks/adddock.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- name: find if dock {{ item }} exists - ansible.builtin.command: - cmd: dockutil --find '{{ item.name }}' - register: dockitem_exists - failed_when: '"No such file or directory" in dockitem_exists.stdout' - changed_when: false - tags: ['dock'] -- name: Ensure dock {{ item }} exists - ansible.builtin.command: - cmd: dockutil --add '{{ item.path }}' - when: dockitem_exists.rc >0 - tags: ['dock'] diff --git a/tasks/dock-add.yml b/tasks/dock-add.yml new file mode 100644 index 0000000..fe9c843 --- /dev/null +++ b/tasks/dock-add.yml @@ -0,0 +1,12 @@ +--- +- name: See if Dock item {{ item }} exists. + ansible.builtin.command: "dockutil --find '{{ item.name }}'" + register: dockitem_exists + failed_when: '"No such file or directory" in dockitem_exists.stdout' + changed_when: false + tags: ['dock'] + +- name: Ensure Dock item {{ item }} exists. + ansible.builtin.command: "dockutil --add '{{ item.path }}'" + when: dockitem_exists.rc >0 + tags: ['dock'] diff --git a/tasks/remdock.yml b/tasks/dock-remove.yml similarity index 100% rename from tasks/remdock.yml rename to tasks/dock-remove.yml diff --git a/tasks/dock.yml b/tasks/dock.yml index c617e46..d1130ee 100644 --- a/tasks/dock.yml +++ b/tasks/dock.yml @@ -1,22 +1,23 @@ --- -- name: Install dockutil +- name: Install dockutil. homebrew: name: dockutil state: present notify: - Clear homebrew cache -- name: remove dockitems - ansible.builtin.include_tasks: tasks/remdock.yml - loop: "{{ dockitems_to_remove }}" + +- name: Remove configured Dock items. + ansible.builtin.include_tasks: tasks/dock-remove.yml + loop: "{{ dockitems_remove }}" - name: Ensure required dock items exist. - ansible.builtin.include_tasks: tasks/adddock.yml - with_items: "{{ dockitems_to_persist }}" + ansible.builtin.include_tasks: tasks/dock-add.yml + loop: "{{ dockitems_persist }}" -- name: Ensure correct dock order +- name: Ensure correct Dock order. ansible.builtin.command: cmd: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' when: - item.pos is defined - item.pos length >0 - loop: "{{ dockitems_to_persist }}" + loop: "{{ dockitems_persist }}" diff --git a/tasks/osx.yml b/tasks/osx.yml index c6c5b45..ec12cd5 100644 --- a/tasks/osx.yml +++ b/tasks/osx.yml @@ -3,4 +3,3 @@ - name: Run .osx dotfiles. command: "{{ osx_script }}" changed_when: false - tags: ['osx'] From bfea2dd85781858cb78980c2442e1b560309938d Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 15:15:57 +0200 Subject: [PATCH 14/14] fix terminal to run with remote tasks as well --- tasks/terminal.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tasks/terminal.yml b/tasks/terminal.yml index 3807ab6..528aec4 100644 --- a/tasks/terminal.yml +++ b/tasks/terminal.yml @@ -7,7 +7,14 @@ check_mode: false - name: Ensure custom Terminal profile is added. - command: open files/terminal/JJG-Term.terminal + ansible.builtin.copy: + src: files/terminal/JJG-Term.terminal + dest: /tmp/JJG-Term.terminal + changed_when: false + when: "'JJG-Term' not in terminal_theme.stdout" + +- name: Ensure custom Terminal profile is added. + command: open /tmp/JJG-Term.terminal changed_when: false when: "'JJG-Term' not in terminal_theme.stdout"