Skip to content

Commit

Permalink
Merge pull request #14 from fubarhouse/issue-11
Browse files Browse the repository at this point in the history
PR for #11: change to use configurable absolute path
  • Loading branch information
fubarhouse authored Sep 4, 2018
2 parents 7088f12 + 463f675 commit a5e7bea
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 26 deletions.
16 changes: 5 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
---
sudo: required
language: objective-c
# 10.11 (see https://docs.travis-ci.com/user/osx-ci-environment/#OS-X-Version)
osx_image: xcode7.3

before_install:
# Uninstall existing brew installation.
- 'ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"'
- rm -rf /usr/local/Homebrew
- rm -rf /usr/local/Caskroom
- rm -rf /usr/local/bin/brew
# 10.13 (see https://docs.travis-ci.com/user/osx-ci-environment/#OS-X-Version)
osx_image: xcode10

install:
# Install pip.
- sudo easy_install pip

# Install Ansible.
- sudo pip install ansible
Expand All @@ -30,6 +21,9 @@ script:
# Install roles
- "ansible-galaxy install -r tests/requirements.yml"

# Copy this role into place
- cp -rf $TRAVIS_BUILD_DIR/* ../fubarhouse.macdock/

# Check the role/playbook's syntax.
- "ansible-playbook tests/test.yml --syntax-check"

Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ Install [Dockutil](https://github.com/kcrawford/dockutil) and remove, add and an

## Requirements

- Homebrew
None.

## Role Variables

### Administration
````yaml
# The URL to the physical file where dockutil is available.
dockutil_url: https://raw.githubusercontent.com/kcrawford/dockutil/master/scripts/dockutil
# The installation path the above URL will be downloaded to.
dockutil_install_path: /usr/local/bin/dockutil
````

### Removal of dock items

Dock items to remove:
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
# To manage dock items.
#

dockutil_url: https://raw.githubusercontent.com/kcrawford/dockutil/master/scripts/dockutil
dockutil_install_path: /usr/local/bin/dockutil

dockitems_remove_all: false

dockitems_disabled:
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ galaxy_info:
- 10.10
- 10.11
- 10.12
- 10.13
- 10.7
- 10.8
- 10.9
Expand Down
27 changes: 17 additions & 10 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
---

- name: Dockutil | Detect installation
stat:
path: "{{ dockutil_install_path }}"
register: dockutil_stat

- name: Dockutil | Ensure installed.
homebrew:
name: "dockutil"
state: installed
get_url:
url: "{{ dockutil_url }}"
dest: "{{ dockutil_install_path }}"
mode: 0755
when: not dockutil_stat.stat.exists

- name: Dockutil | Get information on items to remove
shell: "dockutil --find '{{ item }}'"
shell: "{{ dockutil_install_path }} --find '{{ item }}'"
register: dockutil_removeditems
with_items: "{{ dockitems_disabled }}"
changed_when: false
Expand All @@ -15,12 +22,12 @@
when: dockitems_remove_all|bool == false

- name: Dockutil | Remove all dock items
shell: "dockutil --remove all --no-restart"
shell: "{{ dockutil_install_path }} --remove all --no-restart"
register: removed_items_task
when: dockitems_remove_all|bool == true

- name: Dockutil | Remove all unwanted dock items
shell: "dockutil --remove '{{ item.item }}' --no-restart"
shell: "{{ dockutil_install_path }} --remove '{{ item.item }}' --no-restart"
with_items: "{{ dockutil_removeditems.results }}"
loop_control:
label: "{{item.item}}"
Expand All @@ -30,31 +37,31 @@
notify: restart dock

- name: Dockutil | Get information on configured setup
shell: "dockutil --find '{{ item.name }}'"
shell: "{{ dockutil_install_path }} --find '{{ item.name }}'"
register: dockutil_newdata
with_items: "{{ dockitems_enabled }}"
changed_when: false
failed_when: false
check_mode: no

- name: Dockutil | Adding items
shell: "dockutil --add '{{ item.item.path }}' --position {{ item.item.pos }} --no-restart"
shell: "{{ dockutil_install_path }} --add '{{ item.item.path }}' --position {{ item.item.pos }} --no-restart"
with_items: "{{ dockutil_newdata.results }}"
loop_control:
label: "{{item.item}}"
when: (item.item.name ~ " was not found in") in item.stdout
notify: restart dock

- name: Dockutil | Get information on current setup
shell: "dockutil --find '{{ item.name }}'"
shell: "{{ dockutil_install_path }} --find '{{ item.name }}'"
register: dockutil_currdata
with_items: "{{ dockitems_enabled }}"
changed_when: false
failed_when: false
check_mode: no

- name: Dockutil | Moving items
shell: "dockutil --move '{{ item.item.name }}' --position {{ item.item.pos }} --no-restart"
shell: "{{ dockutil_install_path }} --move '{{ item.item.name }}' --position {{ item.item.pos }} --no-restart"
with_items: "{{ dockutil_currdata.results }}"
loop_control:
label: "{{item.item}}"
Expand Down
3 changes: 0 additions & 3 deletions tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
---

- src: https://github.com/geerlingguy/ansible-role-homebrew
version: 2.1.0
name: geerlingguy.homebrew
- src: https://github.com/fubarhouse/ansible-role-macdock
version: master
name: fubarhouse.macdock
1 change: 0 additions & 1 deletion tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
vars:
dockitems_enabled: []
roles:
- geerlingguy.homebrew
- fubarhouse.macdock

0 comments on commit a5e7bea

Please sign in to comment.