From 01c1e0d2a17f05fa29a0040baa3bb5e5f0165c63 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Wed, 7 Apr 2021 13:26:28 +0200 Subject: [PATCH 01/24] dingen --- ansible.cfg | 2 ++ default.config.yml | 10 +++--- inventory | 3 +- main.yml | 8 +++++ requirements.yml | 2 ++ tasks/extra-packages.yml | 70 +++++++++++++++++++++------------------- tasks/terminal.yml | 13 ++++++-- 7 files changed, 66 insertions(+), 42 deletions(-) diff --git a/ansible.cfg b/ansible.cfg index 1b00cf9..4079992 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,5 @@ [defaults] nocows = True roles_path = ./roles:/etc/ansible/roles +inventory = inventory +become = true diff --git a/default.config.yml b/default.config.yml index 38ff438..c19b001 100644 --- a/default.config.yml +++ b/default.config.yml @@ -2,7 +2,7 @@ downloads: ~/.ansible-downloads/ configure_dotfiles: true -configure_terminal: true +configure_terminal: false configure_osx: true configure_sudoers: false @@ -12,7 +12,7 @@ sudoers_custom_config: '' # # Allow users in admin group to use sudo with no password. # %admin ALL=(ALL) NOPASSWD: ALL -dotfiles_repo: https://github.com/geerlingguy/dotfiles.git +dotfiles_repo: https://github.com/dspolleke/dotfiles.git dotfiles_repo_accept_hostkey: true dotfiles_repo_local_destination: ~/Development/GitHub/dotfiles dotfiles_files: @@ -83,15 +83,15 @@ composer_packages: [] # - name: drush # state: present # present/absent, default: present # version: "^8.1" # default: N/A -gem_packages: [] -# - name: bundler +gem_packages: + - name: showoff # state: present # present/absent/latest, default: present # version: "~> 1.15.1" # default: N/A npm_packages: [] # - name: webpack # state: present # present/absent/latest, default: present # version: "^2.6" # default: N/A -pip_packages: [] +#pip_packages: [] # - name: mkdocs # state: present # present/absent/latest, default: present # version: "0.16.3" # default: N/A diff --git a/inventory b/inventory index 5b72010..f296d73 100644 --- a/inventory +++ b/inventory @@ -1,2 +1,3 @@ [all] -127.0.0.1 ansible_connection=local +#127.0.0.1 ansible_connection=local +192.168.2.49 diff --git a/main.yml b/main.yml index b35b077..57648c7 100644 --- a/main.yml +++ b/main.yml @@ -36,6 +36,14 @@ - include_tasks: tasks/extra-packages.yml 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 }}" - name: Run configured post-provision ansible task files. include_tasks: "{{ outer_item }}" diff --git a/requirements.yml b/requirements.yml index 859e695..c8046ca 100644 --- a/requirements.yml +++ b/requirements.yml @@ -3,3 +3,5 @@ roles: - name: geerlingguy.dotfiles - name: geerlingguy.homebrew - name: geerlingguy.mas +collections: + - name: community.general diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml index 643cd41..94928e9 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -1,34 +1,38 @@ --- -- 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 are installed + 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. + ansible.builtin.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. + ansible.builtin.pip: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + executable: "{{ pip_executable | default(omit) }}" + loop: "{{ pip_packages }}" + + - name: Install global Ruby gems. + ansible.builtin.gem: + name: "{{ item.name | default(item) }}" + state: "{{ item.state | default('present') }}" + version: "{{ item.version | default(omit) }}" + user_install: false + install_dir: "{{ gem_dir }}" + executable: "{{ gem_executable | default(omit) }}" + loop: "{{ gem_packages }}" + tags: ['extra-packages'] diff --git a/tasks/terminal.yml b/tasks/terminal.yml index 3807ab6..5ffa752 100644 --- a/tasks/terminal.yml +++ b/tasks/terminal.yml @@ -6,9 +6,16 @@ changed_when: false check_mode: false -- name: Ensure custom Terminal profile is added. - command: open files/terminal/JJG-Term.terminal - changed_when: false +- name: ensure JJG-Term + block: + - name: transfer the file + copy: + src: files/terminal/JJG-Term.terminal + dest: /tmp/JJG-Term.terminal + + - name: Ensure custom Terminal profile is added. + command: open /tmp/JJG-Term.terminal + changed_when: false when: "'JJG-Term' not in terminal_theme.stdout" # TODO: This doesn't work in Yosemite. Consider a different solution? From ecaea525e06cea84609a027d2e2032ec85aa6b43 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Wed, 7 Apr 2021 13:27:34 +0200 Subject: [PATCH 02/24] bootstrap --- bootstrap.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100644 index 0000000..4c2b67f --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,31 @@ +#!/bin/bash +alias python=python3 +pyenv install --list | grep -Ev '[abc-]' | tail -1 +python -V 2>&1 | awk '/Python/{ split($2, a, "."); print a[1]"."a[2] }' + +if curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; +then +python get-pip.py +fi + +export PATH="$HOME/Library/Python/${pyver}/bin/:$PATH" +python -m pip install --user ansible + +xcode-select --install > /dev/null 2>&1 +if [ "$?" == '0' ]; then + sleep 1 + osascript < Date: Wed, 7 Apr 2021 19:18:39 +0200 Subject: [PATCH 03/24] dock --- default.config.yml | 1 + tasks/dock.yml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 tasks/dock.yml diff --git a/default.config.yml b/default.config.yml index c19b001..a3972e3 100644 --- a/default.config.yml +++ b/default.config.yml @@ -4,6 +4,7 @@ downloads: ~/.ansible-downloads/ configure_dotfiles: true configure_terminal: false configure_osx: true +configure_dock: [] configure_sudoers: false sudoers_custom_config: '' diff --git a/tasks/dock.yml b/tasks/dock.yml new file mode 100644 index 0000000..bfcd4c7 --- /dev/null +++ b/tasks/dock.yml @@ -0,0 +1,20 @@ +--- +- name: Install dockutil + homebrew: + name: dockutil + state: present + notify: + - Clear homebrew cache + +- name: Remove all crap from Dock + shell: dockutil --remove '{{ item }}' + ignore_errors: true + with_items: "{{ dockitems_to_remove }}" + +- name: Check if items in dock exist + shell: dockutil --find '{{ item.name }}' || dockutil --add '{{ item.path }}' + with_items: "{{ dockitems_to_persist }}" + +- name: Fix order + shell: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' + with_items: "{{ dockitems_to_persist }}" From eae5de681ff1f6865156ab3b1d5df6ee2c870226 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 15:15:57 +0200 Subject: [PATCH 04/24] 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 bfea2dd85781858cb78980c2442e1b560309938d Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 15:15:57 +0200 Subject: [PATCH 05/24] 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" From 87dd16f677077090d4e6df6caf5b52c6849773ec Mon Sep 17 00:00:00 2001 From: dspolleke Date: Sun, 11 Apr 2021 19:57:38 +0200 Subject: [PATCH 06/24] fix tags issue 97 --- tasks/extra-packages.yml | 8 ++++---- tasks/osx.yml | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tasks/extra-packages.yml b/tasks/extra-packages.yml index 94928e9..066fcb2 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -1,6 +1,6 @@ --- - name: Ensure extra packages are installed - block: + block: - name: Install global Composer packages. composer: command: "{{ (item.state | default('present') == 'absent') | ternary('remove', 'require') }}" @@ -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. ansible.builtin.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. ansible.builtin.pip: name: "{{ item.name | default(item) }}" @@ -25,7 +25,7 @@ version: "{{ item.version | default(omit) }}" executable: "{{ pip_executable | default(omit) }}" loop: "{{ pip_packages }}" - + - name: Install global Ruby gems. ansible.builtin.gem: name: "{{ item.name | default(item) }}" 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 5f77296043464e56233f9d34c0ec8990e636f8e3 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 17:43:47 +0200 Subject: [PATCH 07/24] fixed it the way GG wants it fixed --- main.yml | 16 ++++++---- tasks/extra-packages.yml | 64 +++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/main.yml b/main.yml index 57648c7..d02eb5e 100644 --- a/main.yml +++ b/main.yml @@ -22,19 +22,22 @@ 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: Install global Ruby gems. gem: @@ -46,7 +49,8 @@ loop: "{{ gem_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 066fcb2..677148b 100644 --- a/tasks/extra-packages.yml +++ b/tasks/extra-packages.yml @@ -1,38 +1,34 @@ --- -- name: Ensure extra packages are installed - 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. - ansible.builtin.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. - ansible.builtin.pip: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - executable: "{{ pip_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. - ansible.builtin.gem: - name: "{{ item.name | default(item) }}" - state: "{{ item.state | default('present') }}" - version: "{{ item.version | default(omit) }}" - user_install: false - install_dir: "{{ gem_dir }}" - executable: "{{ gem_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 e50edb3d969ffea3c356549946e4bf0779785e79 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 19:13:23 +0200 Subject: [PATCH 08/24] imclude_tasks are sometimes useful --- main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.yml b/main.yml index d02eb5e..5895c76 100644 --- a/main.yml +++ b/main.yml @@ -49,7 +49,7 @@ loop: "{{ gem_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 874d83e3b84c66384fd7efcd977c84b2b3f40c0e Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 20:00:00 +0200 Subject: [PATCH 09/24] 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 baae72b63e818341cee017dd3a2fa349c810fa18 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Sun, 11 Apr 2021 20:44:58 +0200 Subject: [PATCH 10/24] 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 ++++ 2 files changed, 6 insertions(+) diff --git a/default.config.yml b/default.config.yml index d80faaa..d4ce800 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,6 +6,8 @@ configure_terminal: false configure_osx: true configure_dock: [] +configure_dock: [] + configure_sudoers: false sudoers_custom_config: '' # Example: diff --git a/main.yml b/main.yml index 5895c76..c00d8db 100644 --- a/main.yml +++ b/main.yml @@ -48,6 +48,10 @@ executable: "{{ item.executable | default(omit) }}" loop: "{{ gem_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: From 2574bb295283fa1f64a9ef4a721cf46f4353fb54 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 13:29:34 +0200 Subject: [PATCH 11/24] working dockutil --- ansible.cfg | 1 + default.config.yml | 25 +++++++++++++++++++++++-- tasks/adddock.yml | 13 +++++++++++++ tasks/dock.yml | 38 ++++++++++++++++++++++---------------- tasks/remdock.yml | 14 ++++++++++++++ 5 files changed, 73 insertions(+), 18 deletions(-) create mode 100644 tasks/adddock.yml create mode 100644 tasks/remdock.yml diff --git a/ansible.cfg b/ansible.cfg index 4079992..532d633 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -3,3 +3,4 @@ nocows = True roles_path = ./roles:/etc/ansible/roles inventory = inventory become = true +stdout_callback = yaml diff --git a/default.config.yml b/default.config.yml index d4ce800..151b395 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,8 +6,29 @@ configure_terminal: false configure_osx: true configure_dock: [] -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 bfcd4c7..20cebd0 100644 --- a/tasks/dock.yml +++ b/tasks/dock.yml @@ -1,20 +1,26 @@ --- -- name: Install dockutil - homebrew: - name: dockutil - state: present - notify: - - Clear homebrew cache +- 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: Remove all crap from Dock - shell: dockutil --remove '{{ item }}' - ignore_errors: true - with_items: "{{ dockitems_to_remove }}" + - name: Ensure required dock items exist. + ansible.builtin.include_tasks: tasks/adddock.yml + with_items: "{{ dockitems_to_persist }}" -- name: Check if items in dock exist - shell: dockutil --find '{{ item.name }}' || dockutil --add '{{ item.path }}' - 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 }}" -- name: Fix order - shell: dockutil --move '{{ item.name }}' --position '{{ item.pos }}' - with_items: "{{ 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 63659ca41ebcbe1ba82f3dd42f39d21c58933cb1 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 13:49:12 +0200 Subject: [PATCH 12/24] yamllinter --- default.config.yml | 10 +++++----- tasks/remdock.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/default.config.yml b/default.config.yml index 151b395..f5430f9 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,7 +6,7 @@ configure_terminal: false configure_osx: true configure_dock: [] -configure_dock: True +configure_dock: true dockitems_to_remove: - Launchpad - Safari @@ -25,10 +25,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/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 5b47a103ce8379e9f7fd9c262b1448cc7f75d6db Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 17:37:55 +0200 Subject: [PATCH 13/24] 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 f5430f9..59cdc02 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,29 +6,31 @@ configure_terminal: false 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 +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 c00d8db..e7a2f46 100644 --- a/main.yml +++ b/main.yml @@ -48,7 +48,7 @@ executable: "{{ item.executable | default(omit) }}" loop: "{{ gem_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 c32d37ef49ff3cdd219bf39b48c7974c586414d7 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 18:56:21 +0200 Subject: [PATCH 14/24] 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 59cdc02..229e3cb 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,7 +6,7 @@ configure_terminal: false configure_osx: true configure_dock: [] -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 bd6b7a00930d0777b2dbc656a4f07a94209cddf6 Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Fri, 7 May 2021 10:26:27 -0500 Subject: [PATCH 15/24] PR #106 follow-up: More consistent docs and examples. --- README.md | 4 +++ default.config.yml | 34 ++++++++------------------ tasks/adddock.yml | 13 ---------- tasks/dock-add.yml | 12 +++++++++ tasks/{remdock.yml => dock-remove.yml} | 0 tasks/dock.yml | 17 +++++++------ tasks/osx.yml | 1 - 7 files changed, 35 insertions(+), 46 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/default.config.yml b/default.config.yml index 229e3cb..149b009 100644 --- a/default.config.yml +++ b/default.config.yml @@ -6,31 +6,17 @@ configure_terminal: false configure_osx: true configure_dock: [] -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/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 269e9258a9e830b17441a51e7ccc598853b892e8 Mon Sep 17 00:00:00 2001 From: dspolleke Date: Mon, 12 Apr 2021 15:15:57 +0200 Subject: [PATCH 16/24] fix terminal to run with remote tasks as well --- tasks/terminal.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/terminal.yml b/tasks/terminal.yml index 5ffa752..75aad5b 100644 --- a/tasks/terminal.yml +++ b/tasks/terminal.yml @@ -8,11 +8,11 @@ - name: ensure JJG-Term block: - - name: transfer the file - copy: + - name: transfer the file + copy: src: files/terminal/JJG-Term.terminal dest: /tmp/JJG-Term.terminal - + - name: Ensure custom Terminal profile is added. command: open /tmp/JJG-Term.terminal changed_when: false From ffcb2a64ae44f85ac8427b5c8329fcbe141aa361 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Wed, 26 May 2021 11:27:20 +0200 Subject: [PATCH 17/24] did i mention i really hate rebasing --- default.config.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/default.config.yml b/default.config.yml index 08d601e..e5fc2ef 100644 --- a/default.config.yml +++ b/default.config.yml @@ -4,7 +4,6 @@ downloads: ~/.ansible-downloads/ configure_dotfiles: true configure_terminal: false configure_osx: true -configure_dock: [] # Set to 'true' to configure the Dock via dockutil. configure_dock: false @@ -17,16 +16,6 @@ dockitems_persist: [] # - name: "Sublime Text" # path: "/Applications/Sublime Text.app/" -# 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/" configure_sudoers: false sudoers_custom_config: '' @@ -108,14 +97,14 @@ composer_packages: [] # state: present # present/absent, default: present # version: "^8.1" # default: N/A gem_packages: - - name: showoff +# - name: showoff # state: present # present/absent/latest, default: present # version: "~> 1.15.1" # default: N/A npm_packages: [] # - name: webpack # state: present # present/absent/latest, default: present # version: "^2.6" # default: N/A -#pip_packages: [] +pip_packages: [] # - name: mkdocs # state: present # present/absent/latest, default: present # version: "0.16.3" # default: N/A From 018ed6bba7d10c78c0f5865c54d9a17a692a2094 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Wed, 26 May 2021 12:15:13 +0200 Subject: [PATCH 18/24] empty array --- default.config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default.config.yml b/default.config.yml index e5fc2ef..bb556d8 100644 --- a/default.config.yml +++ b/default.config.yml @@ -96,7 +96,7 @@ composer_packages: [] # - name: drush # state: present # present/absent, default: present # version: "^8.1" # default: N/A -gem_packages: +gem_packages: [] # - name: showoff # state: present # present/absent/latest, default: present # version: "~> 1.15.1" # default: N/A From 0bcbb90abd5a58bb20e1d3e28622b2a78e44938b Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Thu, 27 May 2021 19:10:58 +0200 Subject: [PATCH 19/24] cleanup persoal crud --- inventory | 3 +-- main.yml | 8 -------- 2 files changed, 1 insertion(+), 10 deletions(-) diff --git a/inventory b/inventory index f296d73..5b72010 100644 --- a/inventory +++ b/inventory @@ -1,3 +1,2 @@ [all] -#127.0.0.1 ansible_connection=local -192.168.2.49 +127.0.0.1 ansible_connection=local diff --git a/main.yml b/main.yml index 9f3faad..9f99306 100644 --- a/main.yml +++ b/main.yml @@ -39,14 +39,6 @@ - import_tasks: tasks/extra-packages.yml 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 }}" - import_tasks: tasks/dock.yml when: configure_dock From 4d6e28cb3dbffae68356bd097d5af257af526c69 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Thu, 27 May 2021 19:13:21 +0200 Subject: [PATCH 20/24] cleanup persoal crud --- default.config.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/default.config.yml b/default.config.yml index bb556d8..b62bdfc 100644 --- a/default.config.yml +++ b/default.config.yml @@ -2,7 +2,7 @@ downloads: ~/.ansible-downloads/ configure_dotfiles: true -configure_terminal: false +configure_terminal: true configure_osx: true # Set to 'true' to configure the Dock via dockutil. @@ -16,7 +16,6 @@ dockitems_persist: [] # - name: "Sublime Text" # path: "/Applications/Sublime Text.app/" - configure_sudoers: false sudoers_custom_config: '' # Example: @@ -24,7 +23,7 @@ sudoers_custom_config: '' # # Allow users in admin group to use sudo with no password. # %admin ALL=(ALL) NOPASSWD: ALL -dotfiles_repo: https://github.com/dspolleke/dotfiles.git +dotfiles_repo: https://github.com/geerlingguy/dotfiles.git dotfiles_repo_accept_hostkey: true dotfiles_repo_local_destination: ~/Development/GitHub/dotfiles dotfiles_files: @@ -97,7 +96,7 @@ composer_packages: [] # state: present # present/absent, default: present # version: "^8.1" # default: N/A gem_packages: [] -# - name: showoff +# - name: bundler # state: present # present/absent/latest, default: present # version: "~> 1.15.1" # default: N/A npm_packages: [] From d1ee83239ca144f607645bac660fb585b0321cf1 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Thu, 27 May 2021 19:14:35 +0200 Subject: [PATCH 21/24] cleanup persoal crud --- bootstrap.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 bootstrap.sh diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100644 index 4c2b67f..0000000 --- a/bootstrap.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -alias python=python3 -pyenv install --list | grep -Ev '[abc-]' | tail -1 -python -V 2>&1 | awk '/Python/{ split($2, a, "."); print a[1]"."a[2] }' - -if curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py ; -then -python get-pip.py -fi - -export PATH="$HOME/Library/Python/${pyver}/bin/:$PATH" -python -m pip install --user ansible - -xcode-select --install > /dev/null 2>&1 -if [ "$?" == '0' ]; then - sleep 1 - osascript < Date: Thu, 27 May 2021 19:24:00 +0200 Subject: [PATCH 22/24] cleanup reuirements on request --- requirements.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/requirements.yml b/requirements.yml index c8046ca..859e695 100644 --- a/requirements.yml +++ b/requirements.yml @@ -3,5 +3,3 @@ roles: - name: geerlingguy.dotfiles - name: geerlingguy.homebrew - name: geerlingguy.mas -collections: - - name: community.general From 7c4b4c1e4c061c9b6bc2e7da8f5917f9d2ea9443 Mon Sep 17 00:00:00 2001 From: Paul van Noort Date: Thu, 27 May 2021 19:25:57 +0200 Subject: [PATCH 23/24] remove remove double double code code --- main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/main.yml b/main.yml index 9f99306..9097009 100644 --- a/main.yml +++ b/main.yml @@ -44,10 +44,6 @@ when: configure_dock tags: ['dock'] - - import_tasks: tasks/dock.yml - when: configure_dock - tags: ['dock'] - - name: Run configured post-provision ansible task files. include_tasks: "{{ outer_item }}" loop_control: From bbacfcbd9ace2cbb1ef4d37c5a0cd8ddd6249e2a Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Thu, 27 May 2021 13:39:20 -0500 Subject: [PATCH 24/24] Update tasks/terminal.yml --- tasks/terminal.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/terminal.yml b/tasks/terminal.yml index 528aec4..f4a2678 100644 --- a/tasks/terminal.yml +++ b/tasks/terminal.yml @@ -7,7 +7,7 @@ check_mode: false - name: Ensure custom Terminal profile is added. - ansible.builtin.copy: + copy: src: files/terminal/JJG-Term.terminal dest: /tmp/JJG-Term.terminal changed_when: false