mirror of
https://github.com/geerlingguy/mac-dev-playbook
synced 2024-11-21 19:33:03 +00:00
commit
97956cdbdc
8 changed files with 85 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
|||
[defaults]
|
||||
nocows = True
|
||||
roles_path = ./roles:/etc/ansible/roles
|
||||
stdout_callback = yaml
|
||||
|
||||
|
|
|
@ -5,6 +5,31 @@ 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'
|
||||
|
||||
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:
|
||||
|
|
4
main.yml
4
main.yml
|
@ -37,6 +37,10 @@
|
|||
- include_tasks: tasks/extra-packages.yml
|
||||
tags: ['extra-packages']
|
||||
|
||||
- import_tasks: tasks/dock.yml
|
||||
when: configure_dock
|
||||
tags: ['dock']
|
||||
|
||||
- name: Run configured post-provision ansible task files.
|
||||
include_tasks: "{{ outer_item }}"
|
||||
loop_control:
|
||||
|
|
13
tasks/adddock.yml
Normal file
13
tasks/adddock.yml
Normal file
|
@ -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']
|
22
tasks/dock.yml
Normal file
22
tasks/dock.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
- 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 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 }}"
|
|
@ -5,7 +5,7 @@
|
|||
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 }}"
|
||||
loop: "{{ composer_packages }}"
|
||||
|
||||
- name: Install global NPM packages.
|
||||
npm:
|
||||
|
@ -14,7 +14,7 @@
|
|||
version: "{{ item.version | default(omit) }}"
|
||||
global: true
|
||||
executable: "{{ item.executable | default(omit) }}"
|
||||
with_items: "{{ npm_packages }}"
|
||||
loop: "{{ npm_packages }}"
|
||||
|
||||
- name: Install global Pip packages.
|
||||
pip:
|
||||
|
@ -22,7 +22,7 @@
|
|||
state: "{{ item.state | default('present') }}"
|
||||
version: "{{ item.version | default(omit) }}"
|
||||
executable: "{{ item.executable | default(omit) }}"
|
||||
with_items: "{{ pip_packages }}"
|
||||
loop: "{{ pip_packages }}"
|
||||
|
||||
- name: Install global Ruby gems.
|
||||
gem:
|
||||
|
@ -31,4 +31,4 @@
|
|||
version: "{{ item.version | default(omit) }}"
|
||||
user_install: false
|
||||
executable: "{{ item.executable | default(omit) }}"
|
||||
with_items: "{{ gem_packages }}"
|
||||
loop: "{{ gem_packages }}"
|
||||
|
|
|
@ -3,3 +3,4 @@
|
|||
- name: Run .osx dotfiles.
|
||||
command: "{{ osx_script }}"
|
||||
changed_when: false
|
||||
tags: ['osx']
|
||||
|
|
14
tasks/remdock.yml
Normal file
14
tasks/remdock.yml
Normal file
|
@ -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']
|
Loading…
Reference in a new issue