Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---

Check failure on line 1 in meta/main.yml

View workflow job for this annotation

GitHub Actions / Lint

schema[meta]

$.dependencies[0] {'community.general': '>=3.0.0'} is not of type 'string'. See https://docs.ansible.com/projects/ansible/latest/playbook_guide/playbooks_reuse_roles.html#using-role-dependencies
namespace: geerlingguy
name: mac
version: "1.2.0"
readme: README.md

authors:
- geerlingguy

description: Collection of macOS automation tools for Ansible.

# Either a single license or a list of licenses for content inside of a collection. Ansible Galaxy currently only
# accepts L(SPDX,https://spdx.org/licenses/) licenses. This key is mutually exclusive with 'license_file'
license:
- MIT

# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags:
- mac
- macos
- tools
- osx
- homebrew
- brew
- workstation
- dev
- mas
- appstore
- apps
- configure
- development
- apple
- ios
- macbook
- imac
- macmini
- server

dependencies:
- community.general: ">=3.0.0"

repository: https://github.com/geerlingguy/ansible-collection-mac
documentation: https://github.com/geerlingguy/ansible-collection-mac
homepage: https://www.jeffgeerling.com
issues: https://github.com/geerlingguy/ansible-collection-mac/issues

build_ignore: []
4 changes: 2 additions & 2 deletions roles/homebrew/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
homebrew_repo: https://github.com/Homebrew/brew

homebrew_prefix: "{{ (ansible_machine == 'arm64') | ternary('/opt/homebrew', '/usr/local') }}"
homebrew_install_path: "{{ homebrew_prefix }}{{ '/Homebrew' if ansible_machine != 'arm64' }}"
homebrew_prefix: "{{ (ansible_facts['machine'] == 'arm64') | ternary('/opt/homebrew', '/usr/local') }}"
homebrew_install_path: "{{ homebrew_prefix }}{{ '/Homebrew' if ansible_facts['machine'] != 'arm64' }}"
homebrew_brew_bin_path: "{{ homebrew_prefix }}/bin"

homebrew_installed_packages: []
Expand Down
2 changes: 1 addition & 1 deletion roles/homebrew/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
path: "{{ homebrew_cache_path.stdout | trim }}"
state: absent
when: 'homebrew_clear_cache | bool'
become: "{{ (homebrew_user != ansible_user_id) | bool }}"
become: "{{ (homebrew_user != ansible_facts['user_id']) | bool }}"
become_user: "{{ homebrew_user }}"
22 changes: 11 additions & 11 deletions roles/homebrew/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
- name: Determine Homebrew ownership variables
set_fact:
homebrew_user: '{{ homebrew_user | default(ansible_user_id) }}'
homebrew_group: '{{ homebrew_group | default(ansible_user_gid) }}'
homebrew_user: '{{ homebrew_user | default(ansible_facts["user_id"]) }}'
homebrew_group: '{{ homebrew_group | default(ansible_facts["user_gid"]) }}'

# Homebrew setup prerequisites.
- name: Ensure Homebrew parent directory has correct permissions (Apple Silicon).
Expand All @@ -11,18 +11,18 @@
owner: "{{ homebrew_user }}"
state: directory
become: true
when: ansible_machine == 'arm64'
when: ansible_facts["machine"] == 'arm64'

- name: Ensure Homebrew parent directory has correct permissions (Intel).
when: ansible_machine == 'x86_64'
when: ansible_facts["machine"] == 'x86_64'
block:
- name: Ensure Homebrew parent directory has correct permissions (MacOS >= 10.13).
file:
path: "{{ homebrew_prefix }}"
owner: root
state: directory
become: true
when: "ansible_distribution_version is version('10.13', '>=')"
when: "ansible_facts['distribution_version'] is version('10.13', '>=')"

- name: Ensure Homebrew parent directory has correct permissions (MacOS < 10.13).
file:
Expand All @@ -32,7 +32,7 @@
state: directory
mode: "0775"
become: true
when: "ansible_distribution_version is version('10.13', '<')"
when: "ansible_facts['distribution_version'] is version('10.13', '<')"

- name: Check if homebrew already exists.
stat:
Expand Down Expand Up @@ -98,7 +98,7 @@
- name: Add missing folder if not on Apple-chipset
set_fact:
homebrew_folders_base: "{{ homebrew_folders_base + ['Homebrew'] }}"
when: ansible_machine != 'arm64'
when: ansible_facts["machine"] != 'arm64'

- name: Ensure proper homebrew folders are in place.
file:
Expand All @@ -111,12 +111,12 @@

- name: Collect package manager fact.
setup:
filter: ansible_pkg_mgr
filter: ansible_facts["pkg_mgr"]

- name: Perform brew installation.
# Privilege escalation is only required for inner steps when
# the `homebrew_user` doesn't match the `ansible_user_id`
become: "{{ (homebrew_user != ansible_user_id) | bool }}"
become: "{{ (homebrew_user != ansible_facts['user_id']) | bool }}"
become_user: "{{ homebrew_user }}"
block:
- name: Force update brew after installation.
Expand All @@ -142,7 +142,7 @@
homebrew_cask:
name: "{{ item }}"
state: absent
sudo_password: "{{ ansible_become_password | default(omit) }}"
sudo_password: "{{ ansible_facts['become_password'] | default(omit) }}"
loop: "{{ homebrew_cask_uninstalled_apps }}"

- name: Install configured cask applications.
Expand All @@ -151,7 +151,7 @@
state: present
install_options: "{{ item.install_options | default('appdir=' + homebrew_cask_appdir) }}"
accept_external_apps: "{{ homebrew_cask_accept_external_apps }}"
sudo_password: "{{ ansible_become_password | default(omit) }}"
sudo_password: "{{ ansible_facts['become_password'] | default(omit) }}"
loop: "{{ homebrew_cask_apps }}"
notify:
- Clear homebrew cache
Expand Down
2 changes: 1 addition & 1 deletion roles/mas/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ mas_installed_apps:
- { id: 497799835, name: "Xcode (8.1)" }
mas_upgrade_all_apps: false
mas_signin_dialog: false
mas_path: "{{ '/opt/homebrew/bin/mas' if ansible_architecture == 'arm64' else '/usr/local/bin/mas' }}"
mas_path: "{{ '/opt/homebrew/bin/mas' if ansible_facts['architecture'] == 'arm64' else '/usr/local/bin/mas' }}"
6 changes: 3 additions & 3 deletions roles/mas/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
check_mode: false
changed_when: false
when:
- ansible_distribution_version is version('12', '<')
- ansible_facts["distribution_version"] is version('12', '<')

- name: Sign in to MAS when email and password are provided.
command: '"{{ mas_path }}" signin "{{ mas_email }}" "{{ mas_password }}"'
register: mas_signin_result
when:
- ansible_distribution_version is version('10.13', '<')
- ansible_facts["distribution_version"] is version('10.13', '<')
- mas_account_result.rc == 1
- mas_email is truthy
- mas_password is truthy
Expand All @@ -27,7 +27,7 @@
command: '"{{ mas_path }}" signin "{{ mas_email }}" "{{ mas_password }}" --dialog'
register: mas_signin_result
when:
- ansible_distribution_version is version('10.13', '<')
- ansible_facts["distribution_version"] is version('10.13', '<')
- mas_signin_dialog
- mas_account_result.rc == 1
- mas_email is truthy
Expand Down
Loading