2022-08-05 14:03:38 +02:00
|
|
|
---
|
2020-09-25 08:01:17 +02:00
|
|
|
####################################################################
|
|
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
|
|
####################################################################
|
|
|
|
|
2020-03-27 11:11:27 +01:00
|
|
|
# Test code for the homebrew module.
|
2022-08-05 12:28:29 +02:00
|
|
|
# Copyright (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
|
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2022-08-05 14:03:38 +02:00
|
|
|
|
2020-03-27 11:11:27 +01:00
|
|
|
- name: Find brew binary
|
|
|
|
command: which brew
|
|
|
|
register: brew_which
|
|
|
|
when: ansible_distribution in ['MacOSX']
|
|
|
|
|
|
|
|
- name: Get owner of brew binary
|
|
|
|
stat:
|
|
|
|
path: "{{ brew_which.stdout }}"
|
|
|
|
register: brew_stat
|
|
|
|
when: ansible_distribution in ['MacOSX']
|
|
|
|
|
|
|
|
#- name: Use ignored-pinned option while upgrading all
|
|
|
|
# homebrew:
|
2023-02-15 22:55:23 +01:00
|
|
|
# upgrade_all: true
|
2020-03-27 11:11:27 +01:00
|
|
|
# upgrade_options: ignore-pinned
|
2023-02-15 22:55:23 +01:00
|
|
|
# become: true
|
2020-03-27 11:11:27 +01:00
|
|
|
# become_user: "{{ brew_stat.stat.pw_name }}"
|
|
|
|
# register: upgrade_option_result
|
|
|
|
# environment:
|
|
|
|
# HOMEBREW_NO_AUTO_UPDATE: True
|
|
|
|
|
|
|
|
#- assert:
|
|
|
|
# that:
|
|
|
|
# - upgrade_option_result.changed
|
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- vars:
|
|
|
|
package_name: gnu-tar
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
block:
|
|
|
|
- name: Make sure {{ package_name }} package is not installed
|
|
|
|
homebrew:
|
|
|
|
name: "{{ package_name }}"
|
|
|
|
state: absent
|
2023-02-15 22:55:23 +01:00
|
|
|
update_homebrew: false
|
|
|
|
become: true
|
2021-10-02 21:18:03 +02:00
|
|
|
become_user: "{{ brew_stat.stat.pw_name }}"
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- name: Install {{ package_name }} package using homebrew
|
|
|
|
homebrew:
|
|
|
|
name: "{{ package_name }}"
|
|
|
|
state: present
|
2023-02-15 22:55:23 +01:00
|
|
|
update_homebrew: false
|
|
|
|
become: true
|
2021-10-02 21:18:03 +02:00
|
|
|
become_user: "{{ brew_stat.stat.pw_name }}"
|
|
|
|
register: package_result
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- package_result.changed
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- name: Again install {{ package_name }} package using homebrew
|
|
|
|
homebrew:
|
|
|
|
name: "{{ package_name }}"
|
|
|
|
state: present
|
2023-02-15 22:55:23 +01:00
|
|
|
update_homebrew: false
|
|
|
|
become: true
|
2021-10-02 21:18:03 +02:00
|
|
|
become_user: "{{ brew_stat.stat.pw_name }}"
|
|
|
|
register: package_result
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- not package_result.changed
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- name: Uninstall {{ package_name }} package using homebrew
|
|
|
|
homebrew:
|
|
|
|
name: "{{ package_name }}"
|
|
|
|
state: absent
|
2023-02-15 22:55:23 +01:00
|
|
|
update_homebrew: false
|
|
|
|
become: true
|
2021-10-02 21:18:03 +02:00
|
|
|
become_user: "{{ brew_stat.stat.pw_name }}"
|
|
|
|
register: package_result
|
2020-03-27 11:11:27 +01:00
|
|
|
|
2021-10-02 21:18:03 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- package_result.changed
|
|
|
|
|
|
|
|
- name: Again uninstall {{ package_name }} package using homebrew
|
|
|
|
homebrew:
|
|
|
|
name: "{{ package_name }}"
|
|
|
|
state: absent
|
2023-02-15 22:55:23 +01:00
|
|
|
update_homebrew: false
|
|
|
|
become: true
|
2021-10-02 21:18:03 +02:00
|
|
|
become_user: "{{ brew_stat.stat.pw_name }}"
|
|
|
|
register: package_result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- not package_result.changed
|