Added check if homebrew exists and path as variable

This commit is contained in:
Raphael Werner 2025-05-03 20:10:14 +02:00
parent 055e077e95
commit 3faa5f5d34
2 changed files with 32 additions and 21 deletions

View file

@ -1,25 +1,33 @@
--- ---
# tasks file for homebrewInstall # tasks file for homebrewInstall
- name: "Create Folder linuxbrew" - name: "Check if homebrew is installed"
become: true ansible.builtin.stat:
ansible.builtin.file: path: "{{ homebrewinstall_path }}"
path: "/home/linuxbrew" register: path_check
state: directory
mode: '0755'
- name: "Create Folder .linuxbrew"
become: true
ansible.builtin.file:
path: "/home/linuxbrew/.linuxbrew"
state: directory
mode: '0755'
owner: "{{ ansible_env.USER }}"
group: "{{ ansible_env.USER }}"
- name: "Install Homebrew" - name: "Install Homebrew"
ansible.builtin.shell: when: not path_check.stat.exists
cmd: 'set -o pipefail && yes | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"' block:
executable: /bin/bash - name: "Create Folder linuxbrew"
register: homebrew_install become: true
changed_when: homebrew_install.rc != 0 ansible.builtin.file:
path: "{{ homebrewinstall_home }}/linuxbrew"
state: directory
mode: '0755'
- name: "Create Folder .linuxbrew"
become: true
ansible.builtin.file:
path: "{{ homebrewinstall_home }}/linuxbrew/.linuxbrew"
state: directory
mode: '0755'
owner: "{{ ansible_env.USER }}"
group: "{{ ansible_env.USER }}"
- name: "Install Homebrew"
ansible.builtin.shell:
cmd: 'set -o pipefail && yes | /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
executable: /bin/bash
register: homebrew_install
changed_when: homebrew_install.rc != 0

View file

@ -53,4 +53,7 @@
- name: "Install Homebrew" - name: "Install Homebrew"
ansible.builtin.include_role: ansible.builtin.include_role:
name: homebrewInstall name: homebrewinstall
vars:
homebrewinstall_home: "/var/home"
homebrewinstall_path: "/home/linuxbrew/.linuxbrew/bin/brew"