Coder Social home page Coder Social logo

geerlingguy / ansible-role-homebrew Goto Github PK

View Code? Open in Web Editor NEW
228.0 228.0 140.0 121 KB

Ansible Role - Homebrew (MOVED to geerlingguy.mac collection)

Home Page: https://galaxy.ansible.com/geerlingguy/homebrew/

License: MIT License

Shell 100.00%
ansible brew homebrew mac macos package-manager role setup

ansible-role-homebrew's Introduction

Ansible Role: Homebrew (MOVED)

MOVED: This role has been moved into the geerlingguy.mac collection. Please see this issue for a migration guide and more information.

MIT licensed Galaxy Role Downloads CI

Installs Homebrew on MacOS, and configures packages, taps, and cask apps according to supplied variables.

Requirements

None.

Role Variables

Available variables are listed below, along with default values (see defaults/main.yml):

homebrew_repo: https://github.com/Homebrew/brew

The GitHub repository for Homebrew core.

homebrew_prefix: "{{ (ansible_machine == 'arm64') | ternary('/opt/homebrew', '/usr/local') }}"
homebrew_install_path: "{{ homebrew_prefix }}/Homebrew"

The path where Homebrew will be installed (homebrew_prefix is the parent directory). It is recommended you stick to the default, otherwise Homebrew might have some weird issues. If you change this variable, you should also manually create a symlink back to /usr/local so things work as Homebrew expects.

homebrew_brew_bin_path: /usr/local/bin

The path where brew will be installed.

homebrew_installed_packages:
  - ssh-copy-id
  - pv
  - { name: vim, install_options: "with-luajit,override-system-vi" }

Packages you would like to make sure are installed via brew install. You can optionally add flags to the install by setting an install_options property, and if used, you need to explicitly set the name for the package as well. By default, no packages are installed (homebrew_installed_packages: []).

homebrew_uninstalled_packages: []

Packages you would like to make sure are uninstalled.

homebrew_upgrade_all_packages: false

Whether to upgrade homebrew and all packages installed by homebrew. If you prefer to manually update packages via brew commands, leave this set to false.

homebrew_taps:
  - homebrew/core
  - { name: my_company/internal_tap, url: 'https://example.com/path/to/tap.git' }

Taps you would like to make sure Homebrew has tapped.

homebrew_cask_apps:
  - firefox
  - { name: virtualbox, install_options:"debug,appdir=/Applications" }

Apps you would like to have installed via cask. Search for popular apps to see if they're available for install via Cask. Cask will not be used if it is not included in the list of taps in the homebrew_taps variable. You can optionally add flags to the install by setting an install_options property, and if used, you need to explicitly set the name for the package as well. By default, no Cask apps will be installed (homebrew_cask_apps: []).

homebrew_cask_accept_external_apps: true

Default value is false and would result in interruption of further processing of the whole role (and ansible play) in case any app given in homebrew_cask_apps is already installed without cask. Good for a tightly managed system.

Specify as true instead if you prefer to silently continue if any App is already installed without cask. Generally good for a system that is managed with cask / Ansible as well as other install methods (like manually) at the same time.

homebrew_cask_uninstalled_apps:
  - google-chrome

Apps you would like to make sure are uninstalled.

homebrew_cask_appdir: /Applications

Directory where applications installed via cask should be installed.

homebrew_use_brewfile: true

Whether to install via a Brewfile. If so, you will need to install the homebrew/bundle tap, which could be done within homebrew_taps.

homebrew_brewfile_dir: '~'

The directory where your Brewfile is located.

homebrew_clear_cache: false

Set to true to remove the Hombrew cache after any new software is installed.

homebrew_user: "{{ ansible_user_id }}"

The user that you would like to install Homebrew as.

homebrew_group: "{{ ansible_user_gid }}"

The group that you would like to use while installing Homebrew.

homebrew_folders_additional: []

Any additional folders inside homebrew_prefix for which to ensure homebrew user/group ownership.

Dependencies

Example Playbook

- hosts: localhost
  vars:
    homebrew_installed_packages:
      - mysql
  roles:
    - geerlingguy.homebrew

See the tests/local-testing directory for an example of running this role over Ansible's local connection. See also: Mac Development Ansible Playbook.

License

MIT

Author Information

This role was created in 2014 by Jeff Geerling, author of Ansible for DevOps.

Maintainer(s)

ansible-role-homebrew's People

Contributors

bartoszj avatar bodo avatar brettporter avatar cthachuk avatar cybertk avatar daften avatar elliotweiser avatar geerlingguy avatar josephholsten avatar kersson avatar knightsc avatar ksylvan avatar lvnilesh avatar matthewcosgrove avatar mikesouza avatar opdavies avatar opdavies-cti avatar oxyc avatar proinsias avatar shuuji3 avatar supertylerc avatar tonyarnold avatar tsterker avatar won23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-homebrew's Issues

How to pass compilation flags to installers

If I have in my config, say this

homebrew_installed_packages:
  - ...
  - vim --with-lua --with-luajit --with-python3

It fails for me with the error:

failed: [127.0.0.1] (item=vim --with-lua --with-luajit --with-python3) => {"failed": true, "item": "vim --with-lua --with-luajit --with-python3", "msg": "Invalid package: vim --with-lua --with-luajit --with-python3."}

Is there an alternate syntax to do this? or is it supported? I tried this as well:

homebrew_installed_packages:
  - ...
  - "vim --with-lua --with-luajit --with-python3"

Add a cleanup task.

brew cask cleanup should be ran before installing applications via cask to prevent attempted execution of corrupt or incomplete applications.

The task could be optional based off a boolean, and it also helps free up disk space.
In my case running it on my work mac gave me an additional gigabyte of storage.

Thoughts?

Integrate Homebrew Cask if caskroom/cask is tapped

I have a feeling many/most people who use homebrew are using Cask as well... and if they aren't, they should be :)

I currently run cask-related tasks separately in my mac-dev-playbook, but it would be nice if it were all integrated in the homebrew role, so all aspects of software configuration/provisioning could be done as part of this role.

homebrew module loop deprecation warning

The homebrew module used by this role is capable of installing multiple packages without a loop construct.

TASK [geerlingguy.homebrew : Ensure configured homebrew packages are installed.] ***********************
[DEPRECATION WARNING]: Invoking "homebrew" only once while using a loop via squash_actions is 
deprecated. Instead of using a loop to supply multiple items and specifying `name: {{ item.name | 
default(item) }}`, please use `name: u'{{ homebrew_installed_packages }}'` and remove the loop. This 
feature will be removed in version 2.11. Deprecation warnings can be disabled by setting 
deprecation_warnings=False in ansible.cfg.

The problem is, the stanza dealing with installing packages via brew needs to also deal with the install_options variant of specifying the homebew_installed_packages

# Brew.
- name: Ensure configured homebrew packages are installed.
  homebrew:
    name: "{{ item.name | default(item) }}"
    install_options: "{{ item.install_options | default(omit) }}"
    state: present
  with_items: "{{ homebrew_installed_packages }}"
  notify:
    - Clear homebrew cache

'sudo: a password is required\n' for task 'Ensure Homebrew parent directory has correct permissions (on High Sierra).'

Hey there, I just gave this a try (I forked geerlingguy/mac-dev-playbook) and I'm unable to run homebrew task locally, I first had same error as #94 but now I hit the following wall:

TASK [geerlingguy.homebrew : Ensure Homebrew parent directory has correct permissions (on High Sierra).] ***********************************************************************************************************************************************************************
task path: /Users/gableroux/repos/gists/mac-dev-playbook/roles/geerlingguy.homebrew/tasks/main.yml:3
Using module file /usr/local/Cellar/ansible/2.5.4/libexec/lib/python2.7/site-packages/ansible/modules/files/file.py
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: gableroux
<127.0.0.1> EXEC /bin/sh -c 'sudo -H -S -n -u root /bin/sh -c '"'"'echo BECOME-SUCCESS-xaiohcgccqsuoygwzsuzqfhlfksxzjbm; /usr/bin/python'"'"' && sleep 0'
fatal: [127.0.0.1]: FAILED! => {
    "changed": false,
    "module_stderr": "sudo: a password is required\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "rc": 1
}
	to retry, use: --limit @/tmp/ansible-retry/main.retry

I'm running MacOS High Sierra 10.13.5 (17F77)

Install Cask Apps with sudo requirement

Some Cask Applications require me to authenticate with my sudo password. The ansible provisioning just hangs then forever. Is this known/expected behaviour? Putting the user into sudoers with NOPASSWORD option works around the problem. Can we maybe have an option to pass the sudoers password to homebrew_cask step?

ansible_pkg_mgr is unknown after executing this role

Hello there!

First of all, thank your for your outstanding role!

The reason I decided to open an issue is my current project. I'm working on automation of initialization of my working environment. After applying this role, I'm trying to install sdkman using another role. The code looks like this there:

- name: Install system packages
  package:
    name: '{{ system_packages }}'
    use: '{{ ansible_pkg_mgr }}'
    state: present
  become: yes
  tags:
    - sdkman_privilege

On this line this code fails as ansible_pkg_mgr is 'unknown' in a travis-ci environment. Homebrew was removed on a Travis instance the same way as here

Could you be so kind as to assist? As I don't use Ansible very often, I'm not an expert and not sure that this is a bug of your role. Did I miss something?

Is aggregation of variables (e.g. homebrew_installed_packages) possible?

Is it possible to aggregate e.g. homebrew_installed_packages from different sources? In my case I would like to have some Homebrew packages to install defined in

  1. A Role (roles/myrole/vars/main.yml)
  2. Another role (roles/anotherrole/vars/main.yml)
  3. Host specific (host_vars/myhost.yml)
  4. Group specific (group_vars/mygroup/vars.yml)

Unfortunately only packages defined in my first role are installed. Is this kind of aggregation possible? Thanks!

Build failing with 'failed to tap: homebrew/cask'

See:

TASK [ansible-role-homebrew : Ensure configured taps are tapped.] **************
failed: [localhost] (item=homebrew/cask) => {"ansible_loop_var": "item", "changed": false, "item": "homebrew/cask", "msg": "added: 0, unchanged: 0, error: failed to tap: homebrew/cask"}

It looks like Cask may be part of Homebrew itself now...

Ensure configured taps are tapped

I have this error on multiple machines.

TASK [geerlingguy.homebrew : Ensure configured taps are tapped.] *********************
failed: [127.0.0.1] (item=caskroom/cask) => {"failed": true, "item": "caskroom/cask", "msg": "added: 0, unchanged: 0, error: failed to tap: caskroom/cask"}
failed: [127.0.0.1] (item=caskroom/versions) => {"failed": true, "item": "caskroom/versions", "msg": "added: 0, unchanged: 0, error: failed to tap: caskroom/versions"}

cask programs only work if previously installed?

cask items are only processed if brew cask list contains the entry.

It would be convenient for me (and others I imagine) if there was an easy boolean switch to always run, or have an array of items which install if they haven't previously been installed.

What are your recommendations for this?

Failing on 10.13 due to missing fuse.pc

I'm running your vanilla version of mac-dev-playbook with the default config (have tried my own config with the same result) and hitting this strange error in the homebrew role:

TASK [geerlingguy.homebrew : Ensure proper ownership on homebrew_install_path subdirs.] *************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: OSError: [Errno 2] No such file or directory: '/usr/local/lib/pkgconfig/fuse.pc'
fatal: [127.0.0.1]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_zlVUfm/ansible_module_file.py\", line 473, in <module>\n    main()\n  File \"/tmp/ansible_zlVUfm/ansible_module_file.py\", line 350, in main\n    changed |= recursive_set_attributes(module, to_bytes(file_args['path'], errors='surrogate_or_strict'), follow, file_args)\n  File \"/tmp/ansible_zlVUfm/ansible_module_file.py\", line 172, in recursive_set_attributes\n    changed |= module.set_fs_attributes_if_different(tmp_file_args, changed, expand=False)\n  File \"/tmp/ansible_zlVUfm/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1507, in set_fs_attributes_if_different\n  File \"/tmp/ansible_zlVUfm/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1164, in set_owner_if_different\n  File \"/tmp/ansible_zlVUfm/ansible_modlib.zip/ansible/module_utils/basic.py\", line 1059, in user_and_group\nOSError: [Errno 2] No such file or directory: '/usr/local/lib/pkgconfig/fuse.pc'\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
    to retry, use: --limit @/Users/jbramley/Code/vanilla-playbook/main.retry

Always run list commands, even in check mode

I was running my mac-dev-playbook with --check today just to confirm my Mac is in sync with the configuration, but noticed that the command tasks that get listings of what's currently installed are not run in check mode.

I'd like to always run those tasks using always_run: yes.

On first install: "The following directories are not writable: /usr/local/bin"

Warning: The following directories are not writable:
/usr/local/bin

This can happen if you "sudo make install" software that isn't managed
by Homebrew. If a formula tries to write a file to this directory, the
install will fail during the link step.

You should change the ownership and permissions of these directories.
back to your user account.
  sudo chown -R $(whoami) /usr/local/bin

Looks like one more dir I need to update permissions on.

Feature suggestion: enable brew services

Hi,

In conjunction with this role, I've been enabling a couple of homebrew services. Would you be interested in incorporating a couple of small tasks and a variable like the following? (If so, I can create a PR.)

# Variables.
homebrew_enabled_services:
  - mysql
  - php70
  - syncthing
# Tasks.
- name: Get currently available brew services.
  shell: "brew services list | sed '1 d' | cut -d ' ' -f 1"
  register: brew_services

- name: Enable brew services.
  command: "brew services start {{ item }}"
  with_items: "{{ homebrew_enabled_services }}"
  when: "'{{ item }}' in brew_services.stdout_lines"

I've been using a check (as above) to make sure the service exists, though it might be better to let the task fail when the service is not present.

Uninstall packages before installing packages

Right now the order is to install packages first and uninstall packages second. I think the other way around makes more sense. E.g. for my use case now i'm installing bash through brew and bash-completion@2, but since i already had bash-completion installed, it stops because of a conflict.

I can make a PR quickly, but would like to check if there aren't valid reasons to keep it like this.

Variable `homebrew_uninstalled_packages` is undefined

ansible-role-homebrew_uninstalled_packages

I think this is a bug, but I'm not sure if it's something with my particular ansible configuration (default) or what. Based on commits 50c72f2 and b5bb8f5, I can't tell whether it's just me getting this error or not.

In my existing and new playbooks dependent on this role, I MUST define the variable homebrew_uninstalled_packages: [] else I get the error above.

Anyways, the simple fix is to uncomment the homebrew_uninstalled_packages variable in defaults/main.yml. I'm just unsure if there was a reason for commenting it out in the first place.

Let me know if you need any further details. Thanks.

Unnecessary (/dangerous) accept_hostkey in homebrew clone

This may be incorrect, as I'm new to Ansible and just looking around. But, it's my impression that:
As currently configured, the git directive in tasks/main.yml has an accept_hostkey. However, the homebrew_repo defaults to an https connection, so accept_hostkey is ignored.

If anyone was to override the default homebrew_repo to an ssh-addressed repo, they would inadvertently open themself up to remote code execution. Anyone in a privileged network position could impersonate GitHub (via DNS poisoning or intercepting TCP stream) to the client. The clone would succeed, due to accept_hostkey. Since brew is run following the clone, this would cause code execution.

Assuming my understanding is correct, I'd argue for the removal of the accept_hostkey directive. It's unexpected behavior, and could be dangerous to anyone overriding to an SSH URL.

Pre-downloading role

Hey,

Basically I have 3 scripts that run some ansible tasks which depend on your two roles. So as I don't have to repeatedly download them as requirements on multiple machines, I would like to bundle the roles on my internal(company) git repo, together with my scripts.

Do you know of any way that I might achieve that?

Thanks

Homebrew git clone fails with "'/usr/local' already exists and is not an empty directory"

So the git clone fails if homebrew is already there

 _____________________________________________________________ 
< TASK [geerlingguy.homebrew : Ensure homebrew is installed.] >
 ------------------------------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": "/usr/local/bin/git clone --origin origin --branch master --depth 1 git://github.com/Homebrew/homebrew.git /usr/local", "failed": true, "msg": "fatal: destination path '/usr/local' already exists and is not an empty directory.", "rc": 128, "stderr": "fatal: destination path '/usr/local' already exists and is not an empty directory.\n", "stdout": "", "stdout_lines": []}

Ensure Homebrew is installed: NoneType object has no attribute version

Just trying to get started installing homebrew on macOS Sierra 10.12.1 with this play:

- name: Install brew
  hosts: all_osx_hosts
  vars:
    homebrew_installed_packages:
      - ant
      - cmake
      - jq
  roles:
    - geerlingguy.homebrew
  tags:
    - debug

This fails with

Traceback (most recent call last):
  File "/var/folders/jm/3n8_ksbs4fz49dlz_mlchtgw0000gn/T/ansible_HPa4di/ansible_module_git.py", line 1040, in <module>
    main()
  File "/var/folders/jm/3n8_ksbs4fz49dlz_mlchtgw0000gn/T/ansible_HPa4di/ansible_module_git.py", line 923, in main
    if depth is not None and git_version_used < LooseVersion(1.9.1):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/version.py", line 296, in __cmp__
    return cmp(self.version, other.version)
AttributeError: NoneType object has no attribute version

at which point I don't even know where to being looking for the cause.

How can I get this work ?

Sierra install issues

Fresh install of Sierra 10.12.2 and this ansible role installs Homebrew 1.1.0 but it errors and fails at the following point

TASK [geerlingguy.homebrew : Force update brew after installation.] ************
fatal: [127.0.0.1]: FAILED! => {"changed": true, "cmd": ["/usr/local/bin/brew", "update", "--force"],
"delta": "0:00:00.147456", "end": "2016-12-27 16:02:43.209803", "failed": true, "rc": 1, "start": "2016-12-27 16:02:43.062347", 
"stderr": "Error: Running Homebrew as root is extremely dangerous and no longer supported.\n
As Homebrew does not drop privileges on installation you would be giving all\n
build scripts full access to your system.", 
"stdout": "", "stdout_lines": [], "warnings": []}

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=9    changed=5    unreachable=0    failed=1 

To unblock progressing the role to allow completion I'm thinking I should just disable the specific "Force update" task which could be done via this approach http://allwrightythen.com/using-a-forked-ansible-galaxy-role/

Could someone please clarify the best way forwards to workaround and/or fix this?

Thanks,

Matthew

p.s. for reference the previous commands run were

Matthews-MacBook-Air:macos-bootstrap matthewcosgrove$ sudo ansible-galaxy install -r pre-req-roles.yml
- downloading role 'dotfiles', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-dotfiles/archive/1.1.0.tar.gz
- extracting geerlingguy.dotfiles to /etc/ansible/roles/geerlingguy.dotfiles
- geerlingguy.dotfiles was installed successfully
- downloading role 'homebrew', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-homebrew/archive/2.1.0.tar.gz
- extracting geerlingguy.homebrew to /etc/ansible/roles/geerlingguy.homebrew
- geerlingguy.homebrew was installed successfully
Matthews-MacBook-Air:macos-bootstrap matthewcosgrove$ ansible-playbook main.yml -i inventory -K
Traceback (most recent call last):
  File "/usr/local/bin/ansible-playbook", line 43, in <module>
    import ansible.constants as C
  File "/Library/Python/2.7/site-packages/ansible/constants.py", line 161, in <module>
    DEFAULT_LOCAL_TMP         = get_config(p, DEFAULTS, 'local_tmp',        'ANSIBLE_LOCAL_TEMP',      '$HOME/.ansible/tmp', istmppath=True)
  File "/Library/Python/2.7/site-packages/ansible/constants.py", line 81, in get_config
    makedirs_safe(value, 0o700)
  File "/Library/Python/2.7/site-packages/ansible/utils/path.py", line 67, in makedirs_safe
    raise AnsibleError("Unable to create local directories(%s): %s" % (to_native(rpath), to_native(e)))
ansible.errors.AnsibleError: Unable to create local directories(/Users/matthewcosgrove/.ansible/tmp): [Errno 13] Permission denied: '/Users/matthewcosgrove/.ansible/tmp'
Matthews-MacBook-Air:macos-bootstrap matthewcosgrove$ sudo !!
sudo ansible-playbook main.yml -i inventory -K

Ensure configured taps are tapped failing

I just have updated to the latest version of the role and see following error:

TASK [geerlingguy.homebrew : Ensure configured taps are tapped.] ***************
task path: /home/gitlab-runner/builds/4845653c/0/ops/macos-build-agent/roles/geerlingguy.homebrew/tasks/main.yml:99
ok: [10.0.0.5] => (item=homebrew/core) => {"changed": false, "failed": false, "item": "homebrew/core", "msg": "added: 0, unchanged: 1"}
failed: [10.0.0.5] (item=caskroom/cask) => {"changed": false, "failed": true, "item": "caskroom/cask", "msg": "added: 0, unchanged: 0, error: failed to tap: caskroom/cask"}

Unable to use this role if /usr/local is not empty

I encountered this problem when I was trying to run mac-dev-playbook. Before running the playbook, I installed ansible using pip. This role fails to clone the homebrew repo if /usr/local is not empty.

As a workaround, I installed homebrew manually, then re-ran the playbook.

Refactor role for Homebrew 1.0.0+ compatibility

It seems Homebrew 1.0.0 has introduced a few changes that cause things to break a little with this role.

I will still not recommend—or personally use, on principle—the curl-install-script-to-install method, except as a last resort, so the role will need some refactoring.

Things to fix

  • Homebrew installation not working due to repo split (see #32)
  • Pathing based on new install location in /usr/local/Homebrew (instead of /usr/local — see #18)
  • Other emergent issues

Wrong group for /usr/local

Hello,
I try to use your role with this Playbook https://github.com/fubarhouse/mac-dev-playbook but I have one issue :
In ansible-role-homebrew/tasks/main.yml you check if the group is admin

- name: Ensure Homebrew parent directory has correct permissions (on non-'High Sierra' versions of Mac OS X).
  file:
    path: "{{ homebrew_prefix }}"
    owner: root
    group: admin    <--------
    state: directory
    mode: 0775
  become: yes
when: "not ansible_distribution_version.startswith('10.13')"

I would like to know why this value, on the differents Mac I manage they are all at wheel group => root wheel /usr/local

Do I have to change it ? but not seems to be the right solution
or do I have to make a PR to make this value configurable in your role ?

Thank you.
Matthéo

Use more reasonable defaults

At the moment, the default settings in main.yml install ssh-copy-id and pv packages, homebrew/core and caskroom/cask taps and the firefox cask.

These defaults are arbitrary at best; main.yml seems to me like 'active' sample code with mostly documentary purposes. The user is required to take extra action to undo those most likely unwanted settings - and for that, they need to find the file and get the syntax right.

Instead, I propose to not install any arbitrary components by default, but document how this is achieved and link to official documentation.

Pull request in the making.

Permission issue with directory '/usr/local/var/homebrew/'

Never had this problem before, not quite sure where the issue is.

Tried to apply this role onto a clean 'El Capitan' vagrant box, and getting this error message:

TASK [geerlingguy.homebrew : Force update brew after installation.] ************
task path: /Users/vagrant/.freckles/runs/archive/run_170801_23_36_48/roles/internal/geerlingguy.homebrew/tasks/main.yml:61
Using module file /Users/vagrant/.local/opt/conda/envs/inaugurate/lib/python2.7/site-packages/ansible/modules/commands/command.py
ESTABLISH LOCAL CONNECTION FOR USER: vagrant
EXEC /bin/sh -c '/usr/bin/python && sleep 0'
fatal: [localhost]: FAILED! => {
"changed": true,
"cmd": [
"/usr/local/bin/brew",
"update",
"--force"
],
"delta": "0:00:00.646622",
"end": "2017-08-01 23:41:23.749635",
"failed": true,
"invocation": {
"module_args": {
"_raw_params": "/usr/local/bin/brew update --force",
"_uses_shell": false,
"chdir": null,
"creates": null,
"executable": null,
"removes": null,
"warn": true
}
},
"rc": 1,
"start": "2017-08-01 23:41:23.103013",
"stderr": "mkdir: /usr/local/var/homebrew/locks: Permission denied\nError: Can't create update lock in /usr/local/var/homebrew/locks!\nFix permissions by running:\n sudo chown -R $(whoami) /usr/local/var/homebrew",
"stderr_lines": [
"mkdir: /usr/local/var/homebrew/locks: Permission denied",
"Error: Can't create update lock in /usr/local/var/homebrew/locks!",
"Fix permissions by running:",
" sudo chown -R $(whoami) /usr/local/var/homebrew"
],
"stdout": "",
"stdout_lines": []
}

It looks like homebrew expects a directory '/usr/local/var/homebrew', and write access to it. It should be easy enough to add a task to create that, but I'm not sure whether I'm not maybe missing something else?

The Homebrew repository has moved...

Apparently this just happened...

image

The Homebrew installation process will need to be revisited to account for the structural changes to the Homebrew project.

Role runs incorrectly as root when running on remote system

I'm trying to use this role for setting up our mac build nodes. When it runs remotely via ssh, the commands start to run as root, and Homebrew is installed in a broken state.

The command I run is:
**ansible-playbook -i "192.168.56.102," -b -u build -k -K mac-node-setup.yml **

ansible-playbook is v 2.5.3, installed on the local machine by Homebrew

On a fresh installed High Sierra VM, the role is throwing an error at

TASK [homebrew : Ensure configured taps are tapped.] *****************************************************************************************
task path: /Users/alberghi/repos/buildtest/roles/homebrew/tasks/main.yml:99
failed: [192.168.56.102] (item=homebrew/core) => {"changed": false, "item": "homebrew/core", "msg": "added: 0, unchanged: 0, error: failed to tap: homebrew/core"}
failed: [192.168.56.102] (item=homebrew/cask) => {"changed": false, "item": "homebrew/cask", "msg": "added: 0, unchanged: 0, error: failed to tap: homebrew/cask"}

Running brew tap directly on the machine throws a permissions error:

build$ brew tap
Error: /usr/local/Cellar is not writable. You should change the
ownership and permissions of /usr/local/Cellar back to your
user account:
sudo chown -R $(whoami) /usr/local/Cellar

Dumping the facts on the VM shows: ansible_user_id": "root" which means that Homebrew is installed owned by root. Many of the tasks in the second half are running as root, and those fail as brew commands because of security settings in homebrew.

To get it running on my systems I had to make two changes.

First, I had to explicity set ansible_user_id to ansible_env.SUDO_USER in vars:
ansible_user_id: "{{ ansible_env.SUDO_USER }}"

Second, I split the roles main.yml into two blocks. The first one, which installs and sets permissions, runs as root. The second, which runs brew installs, runs as ansible_user_id. This seems to have fixed the problems.

Homebrew update not allowing sudo

Hello

Since the last update of Homebrew there is an error about Homebrew not allowing the usage of sudo

TASK [geerlingguy.homebrew : Where is the cache?] ******************************
fatal: [local]: FAILED! => {"changed": false, "cmd": ["/usr/local/bin/brew", "--cache"], "delta": "0:00:00.272510", "end": "2018-09-06 14:55:17.341289", "msg": "non-zero return code", "rc": 1, "start": "2018-09-06 14:55:17.068779", "stderr": "Error: Running Homebrew as root is extremely dangerous and no longer supported.\nAs Homebrew does not drop privileges on installation you would be giving all\nbuild scripts full access to your system.", "stderr_lines": ["Error: Running Homebrew as root is extremely dangerous and no longer supported.", "As Homebrew does not drop privileges on installation you would be giving all", "build scripts full access to your system."], "stdout": "", "stdout_lines": []}

Homebrew version: 1.7.3
Role version: 2.6.0

Do you have an idea on how to fix this?

Thank you!

Matthéo

Error: Unknown command: cask at Get list of apps installed with cask

I was getting a failure when the cask list was being retrieved. It appears to be a conflict between what brew assumes is set up and the environment ssh sets up when running commands.

I have fixed it by changing the command from brew cask to brew-cask:

# Cask.
- name: Get list of apps installed with cask.
  command: "{{ homebrew_brew_bin_path }}/brew-cask list"
  register: homebrew_cask_list
  always_run: yes
  changed_when: false

Log before fix:

TASK: [geerlingguy.homebrew | Ensure configured taps are tapped.] ************* 
ok: [post1] => (item=caskroom/cask)

TASK: [geerlingguy.homebrew | Ensure configured homebrew packages are installed.] *** 
ok: [post1] => (item=coreutils)
ok: [post1] => (item=git)
ok: [post1] => (item=parallel)
ok: [post1] => (item=dcraw)
ok: [post1] => (item=jpeg)
ok: [post1] => (item=graphicsmagick)
ok: [post1] => (item=the_silver_searcher)
ok: [post1] => (item=brew-cask)

TASK: [geerlingguy.homebrew | Upgrade all homebrew packages (if configured).] *** 
skipping: [post1]

TASK: [geerlingguy.homebrew | Get list of apps installed with cask.] ********** 
failed: [post1] => {"changed": false, "cmd": ["/usr/local/bin/brew", "cask", "list"], "delta": "0:00:00.232802", "end": "2015-08-10 20:53:43.307777", "rc": 1, "start": "2015-08-10 20:53:43.074975", "stdout_lines": [], "warnings": []}
stderr: Error: Unknown command: cask

FATAL: all hosts have already failed -- aborting

I noted that sshing to the host then running the command works, but calling the command directly via ssh does not work:

$ ssh post1 "/usr/local/bin/brew cask list"
Error: Unknown command: cask
$ ssh post1
Last login: Mon Aug 10 20:58:26 2015 from 10.10.0.1
Post1:~ post1$ /usr/local/bin/brew cask list
Warning: nothing to list
Post1:~ post1$ 

Cask task fails

TASK: [geerlingguy.homebrew | Get list of apps installed with cask.] ********** 
failed: [io] => {"changed": false, "cmd": "brew cask list", "failed": true, "rc": 2}
msg: [Errno 2] No such file or directory

Installing cask applications fails

If I try and run just the 'Install configured cask applications' task without the 'et list of apps installed with cask.' task and remove the when clause, the remaining cask task still fails:

TASK: [geerlingguy.homebrew | Install configured cask applications.] **********
ESTABLISH CONNECTION FOR USER: vagrant
REMOTE_MODULE command brew cask install firefox --appdir=/Users/vagrant/Applications
EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/greena28/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 localhost /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1434018141.95-212269048581360 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1434018141.95-212269048581360 && echo $HOME/.ansible/tmp/ansible-tmp-1434018141.95-212269048581360'
PUT /var/folders/sm/vgbwtrps3yv2yl79n43t_f916ldxgl/T/tmpYpLcVk TO /Users/vagrant/.ansible/tmp/ansible-tmp-1434018141.95-212269048581360/command
EXEC ssh -C -tt -vvv -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/Users/greena28/.ansible/cp/ansible-ssh-%h-%p-%r" -o StrictHostKeyChecking=no -o Port=2222 -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=vagrant -o ConnectTimeout=10 localhost /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /Users/vagrant/.ansible/tmp/ansible-tmp-1434018141.95-212269048581360/command; rm -rf /Users/vagrant/.ansible/tmp/ansible-tmp-1434018141.95-212269048581360/ >/dev/null 2>&1'
failed: [test] => (item=firefox) => {"cmd": "brew cask install firefox --appdir=/Users/vagrant/Applications", "failed": true, "item": "firefox", "rc": 2}
msg: [Errno 2] No such file or directory

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
to retry, use: --limit @/Users/greena28/io.retry

test : ok=6 changed=0 unreachable=0 failed=1

Failing with 'error: failed to tap: homebrew/core'

I'm trying to create something similar to your mac-dev-playbook and am seeing this issue:

failed: [127.0.0.1] (item=homebrew/core) => {"changed": false, "item": "homebrew/core", "msg": "added: 0, unchanged: 0, error: failed to tap: homebrew/core"}
failed: [127.0.0.1] (item=homebrew/cask) => {"changed": false, "item": "homebrew/cask", "msg": "added: 0, unchanged: 0, error: failed to tap: homebrew/cask"}

I tried installing them before running the playbook to see if it made any difference, but no luck.
Testing inside this Vagrant High Sierra box https://app.vagrantup.com/jhcook/boxes/macos-sierra.
Looks like it might be an issue with homebrew_tap.

Homebrew install no longer works due to deprecated repository

The repository git://github.com/Homebrew/homebrew.git is now deprecated, causing this role to fail when attempting to install homebrew. This can be verified by cloning the above repository and reading the README.md file.

Since the hombrew repositories have been split into two parts, I'm not certain what the quick fix is for this role.

[Feature Request] - Tap Custom URLs

Summary of Request

As a user of homebrew, I want the ability to tap a custom formula repository that is not hosted on GitHub. This is advantageous for organizations that use Homebrew and store formula repositories internally, but for whom GitHub is not an option. Therefore, this role needs the ability to pass a custom URL to the brew tap command. For context, the usage in man brew is brew tap [--full] user/repo [URL].

Existing usage of the homebrew_tap module today:

# Tap.
- name: Ensure configured taps are tapped.
  homebrew_tap: "tap={{ item }} state=present"
  with_items: "{{ homebrew_taps }}"

According to ansible-doc homebrew_tap, there is a url option (added in version 2.2) that can be added or omitted as appropriate:

- url
        The optional git URL of the repository to tap. The URL is not assumed to be on GitHub, and the protocol doesn't have to be HTTP.
        Any location and protocol that git can handle is fine.
        `name' option may not be a list of multiple taps (but a single tap instead) when this option is provided.
        [Default: (null)]
        version_added: 2.2

Example usage w/ role vars:

homebrew_taps:
  - caskroom/versions
  - { name: mycompany/homebrew, url: https://example.company.com/homebrew-example.git }

Accept Criteria for Completion

  • Users can tap custom URLs
  • Backwards compatible with the existing usage of homebrew_tap which does not supply a URL (hint: it should be omitted.)

Permission issue on install on empty machine high sierra

When I use this role on a freshly reset machine (high sierra), I get the error from #76 and it seems to be because the /usr/local/var folder doesn't exist and brew update doesn't seem to create that folder.

Output from my run and some manual steps after that on the file:
output.txt

After that output there's another non-existing folder that is apparently needed.

Cross dependency issues with Casks

It happens, when installing some formulas, they depend on a cask to be already installed (maven and android-sdk depends on java), but, since casks are installed after non cask packages, this results in a blocking cross dependency.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.