Skip to content

Commit d31d2d4

Browse files
committed
patch1: fix warnig - Use ansible_facts["fact_name"] (no ansible_ prefix) instead
1 parent a7e5852 commit d31d2d4

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

roles/homebrew/defaults/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
homebrew_repo: https://github.com/Homebrew/brew
33

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

88
homebrew_installed_packages: []

roles/homebrew/handlers/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
path: "{{ homebrew_cache_path.stdout | trim }}"
77
state: absent
88
when: 'homebrew_clear_cache | bool'
9-
become: "{{ (homebrew_user != ansible_user_id) | bool }}"
9+
become: "{{ (homebrew_user != ansible_facts['user_id']) | bool }}"
1010
become_user: "{{ homebrew_user }}"

roles/homebrew/tasks/main.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
- name: Determine Homebrew ownership variables
33
set_fact:
4-
homebrew_user: '{{ homebrew_user | default(ansible_user_id) }}'
5-
homebrew_group: '{{ homebrew_group | default(ansible_user_gid) }}'
4+
homebrew_user: '{{ homebrew_user | default(ansible_facts["user_id"]) }}'
5+
homebrew_group: '{{ homebrew_group | default(ansible_facts["user_gid"]) }}'
66

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

1616
- name: Ensure Homebrew parent directory has correct permissions (Intel).
17-
when: ansible_machine == 'x86_64'
17+
when: ansible_facts["machine"] == 'x86_64'
1818
block:
1919
- name: Ensure Homebrew parent directory has correct permissions (MacOS >= 10.13).
2020
file:
2121
path: "{{ homebrew_prefix }}"
2222
owner: root
2323
state: directory
2424
become: true
25-
when: "ansible_distribution_version is version('10.13', '>=')"
25+
when: "ansible_facts['distribution_version'] is version('10.13', '>=')"
2626

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

3737
- name: Check if homebrew already exists.
3838
stat:
@@ -98,7 +98,7 @@
9898
- name: Add missing folder if not on Apple-chipset
9999
set_fact:
100100
homebrew_folders_base: "{{ homebrew_folders_base + ['Homebrew'] }}"
101-
when: ansible_machine != 'arm64'
101+
when: ansible_facts["machine"] != 'arm64'
102102

103103
- name: Ensure proper homebrew folders are in place.
104104
file:
@@ -111,12 +111,12 @@
111111

112112
- name: Collect package manager fact.
113113
setup:
114-
filter: ansible_pkg_mgr
114+
filter: ansible_facts["pkg_mgr"]
115115

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

148148
- name: Install configured cask applications.
@@ -151,7 +151,7 @@
151151
state: present
152152
install_options: "{{ item.install_options | default('appdir=' + homebrew_cask_appdir) }}"
153153
accept_external_apps: "{{ homebrew_cask_accept_external_apps }}"
154-
sudo_password: "{{ ansible_become_password | default(omit) }}"
154+
sudo_password: "{{ ansible_facts['become_password'] | default(omit) }}"
155155
loop: "{{ homebrew_cask_apps }}"
156156
notify:
157157
- Clear homebrew cache

roles/mas/defaults/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ mas_installed_apps:
1010
- { id: 497799835, name: "Xcode (8.1)" }
1111
mas_upgrade_all_apps: false
1212
mas_signin_dialog: false
13-
mas_path: "{{ '/opt/homebrew/bin/mas' if ansible_architecture == 'arm64' else '/usr/local/bin/mas' }}"
13+
mas_path: "{{ '/opt/homebrew/bin/mas' if ansible_facts['architecture'] == 'arm64' else '/usr/local/bin/mas' }}"

roles/mas/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
check_mode: false
1212
changed_when: false
1313
when:
14-
- ansible_distribution_version is version('12', '<')
14+
- ansible_facts["distribution_version"] is version('12', '<')
1515

1616
- name: Sign in to MAS when email and password are provided.
1717
command: '"{{ mas_path }}" signin "{{ mas_email }}" "{{ mas_password }}"'
1818
register: mas_signin_result
1919
when:
20-
- ansible_distribution_version is version('10.13', '<')
20+
- ansible_facts["distribution_version"] is version('10.13', '<')
2121
- mas_account_result.rc == 1
2222
- mas_email is truthy
2323
- mas_password is truthy
@@ -27,7 +27,7 @@
2727
command: '"{{ mas_path }}" signin "{{ mas_email }}" "{{ mas_password }}" --dialog'
2828
register: mas_signin_result
2929
when:
30-
- ansible_distribution_version is version('10.13', '<')
30+
- ansible_facts["distribution_version"] is version('10.13', '<')
3131
- mas_signin_dialog
3232
- mas_account_result.rc == 1
3333
- mas_email is truthy

0 commit comments

Comments
 (0)