Giter Club home page Giter Club logo

mac-dev-playbook's Introduction

Mac Dev Playbook Logo

Mac Development Ansible Playbook

CI

This playbook installs and configures most of the software I use on my Mac for web and software development. Some things in macOS are slightly difficult to automate, so I still have a few manual installation steps, but at least it's all documented here.

Installation

  1. Ensure Apple's command line tools are installed (xcode-select --install to launch the installer).

  2. Install Ansible:

    1. Run the following command to add Python 3 to your $PATH: export PATH="$HOME/Library/Python/3.9/bin:/opt/homebrew/bin:$PATH"
    2. Upgrade Pip: sudo pip3 install --upgrade pip
    3. Install Ansible: pip3 install ansible
  3. Clone or download this repository to your local drive.

  4. Run ansible-galaxy install -r requirements.yml inside this directory to install required Ansible roles.

  5. Run ansible-playbook main.yml --ask-become-pass inside this directory. Enter your macOS account password when prompted for the 'BECOME' password.

Note: If some Homebrew commands fail, you might need to agree to Xcode's license or fix some other Brew issue. Run brew doctor to see if this is the case.

Use with a remote Mac

You can use this playbook to manage other Macs as well; the playbook doesn't even need to be run from a Mac at all! If you want to manage a remote Mac, either another Mac on your network, or a hosted Mac like the ones from MacStadium, you just need to make sure you can connect to it with SSH:

  1. (On the Mac you want to connect to:) Go to System Preferences > Sharing.
  2. Enable 'Remote Login'.

You can also enable remote login on the command line:

sudo systemsetup -setremotelogin on

Then edit the inventory file in this repository and change the line that starts with 127.0.0.1 to:

[ip address or hostname of mac]  ansible_user=[mac ssh username]

If you need to supply an SSH password (if you don't use SSH keys), make sure to pass the --ask-pass parameter to the ansible-playbook command.

Running a specific set of tagged tasks

You can filter which part of the provisioning process to run by specifying a set of tags using ansible-playbook's --tags flag. The tags available are dotfiles, homebrew, mas, extra-packages and osx.

ansible-playbook main.yml -K --tags "dotfiles,homebrew"

Overriding Defaults

Not everyone's development environment and preferred software configuration is the same.

You can override any of the defaults configured in default.config.yml by creating a config.yml file and setting the overrides in that file. For example, you can customize the installed packages and apps with something like:

homebrew_installed_packages:
  - cowsay
  - git
  - go

mas_installed_apps:
  - { id: 443987910, name: "1Password" }
  - { id: 498486288, name: "Quick Resizer" }
  - { id: 557168941, name: "Tweetbot" }
  - { id: 497799835, name: "Xcode" }

composer_packages:
  - name: hirak/prestissimo
  - name: drush/drush
    version: '^8.1'

gem_packages:
  - name: bundler
    state: latest

npm_packages:
  - name: webpack

pip_packages:
  - name: mkdocs

configure_dock: true
dockitems_remove:
  - Launchpad
  - TV
dockitems_persist:
  - name: "Sublime Text"
    path: "/Applications/Sublime Text.app/"
    pos: 5

Any variable can be overridden in config.yml; see the supporting roles' documentation for a complete list of available variables.

Included Applications / Configuration (Default)

Applications (installed with Homebrew Cask):

Packages (installed with Homebrew):

  • autoconf
  • bash-completion
  • doxygen
  • gettext
  • gifsicle
  • git
  • gh
  • go
  • gpg
  • httpie
  • iperf
  • libevent
  • sqlite
  • nmap
  • node
  • nvm
  • php
  • ssh-copy-id
  • cowsay
  • readline
  • openssl
  • pv
  • wget
  • wrk
  • zsh-history-substring-search

My dotfiles are also installed into the current user's home directory, including the .osx dotfile for configuring many aspects of macOS for better performance and ease of use. You can disable dotfiles management by setting configure_dotfiles: no in your configuration.

Finally, there are a few other preferences and settings added on for various apps and services.

Full / From-scratch setup guide

Since I've used this playbook to set up something like 20 different Macs, I decided to write up a full 100% from-scratch install for my own reference (everyone's particular install will be slightly different).

You can see my full from-scratch setup document here: full-mac-setup.md.

Testing the Playbook

Many people have asked me if I often wipe my entire workstation and start from scratch just to test changes to the playbook. Nope! This project is continuously tested on GitHub Actions' macOS infrastructure.

You can also run macOS itself inside a VM, for at least some of the required testing (App Store apps and some proprietary software might not install properly). I currently recommend:

Ansible for DevOps

Check out Ansible for DevOps, which teaches you how to automate almost anything with Ansible.

Author

This project was created by Jeff Geerling (originally inspired by MWGriffin/ansible-playbooks).

mac-dev-playbook's People

Contributors

beansisfat avatar brian-williams avatar danielmcfarland avatar dspolleke avatar elisiano avatar geerlingguy avatar jezmck avatar kauffinger avatar ksoda avatar ladyrassilon avatar mikesouza avatar newtonne avatar oxyc avatar pavelzw avatar peterramsing avatar rainyskye avatar readmecritic 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  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

mac-dev-playbook's Issues

Automate remapping Caps Lock to Escape

Now that macOS 10.12.1 includes built-in remapping for Caps Lock-to-Escape, I've ditched Karabiner Elements (since that was the only thing I used it for). See: Remapping the Caps Lock key to Escape in macOS Sierra

But I'd still like to have that setting automated so I don't have to click through the Keyboard system preferences when setting up my Mac fresh.

See: Updating modifier key mappings through defaults command tool; the setting has to be set per keyboard (in my case, I have two, an 'Apple Keyboard', and an 'Apple Internal Keyboard / Trackpad', with unique IDs. I'd have to set it up (maybe in the .osx bash script in my dotfiles?) to add the mapping for each keyboard detected.

Kick off bootstrap with a single shell command

@geerlingguy Great work on this! 👏 I've been following various "ansible provision my Mac" projects for over a year and this is the simplest, most straightforward yet.

I was digging into the various forks, I came across @siyelo's fork that has added an install.sh file that can be run via curl without having to install anything.

You might consider pulling in the install.sh and adding the Fast Install option. 😄

gem installation failed due to path write permission, user_install is ignored

I tried to install cocoapods gem, but i get the error of not writable path. Even when i try to use the user installation flag, it is ignored and the same not writable path is used. Do i have an fucked-up ruby installation here?

What do i have to do, to get the gem installed?

default.config.yml

gem_packages: 
  - name: cocoapods
    state: present # present/absent/latest, default: present
    version: "~> 1.6.2"
    user_install: yes

error:

failed: [127.0.0.1] (item={'name': 'cocoapods', 'state': 'present', 'version': '~> 1.6.2', 'user_install': True}) => {"ansible_loop_var": "item", "changed": false, "cmd": "/usr/bin/gem install --version '~> 1.6.2' --no-user-install --no-document cocoapods", "item": {"name": "cocoapods", "state": "present", "user_install": true, "version": "~> 1.6.2"}, "msg": "ERROR:  While executing gem ... (Gem::FilePermissionError)\n    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.", "rc": 1, "stderr": "ERROR:  While executing gem ... (Gem::FilePermissionError)\n    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.\n", "stderr_lines": ["ERROR:  While executing gem ... (Gem::FilePermissionError)", "    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory."], "stdout": "", "stdout_lines": []}

Travis Build failing with cryptic error about an unexpected colon

Example failed build: https://travis-ci.org/geerlingguy/mac-dev-playbook/builds/383429609#L723-L729

The command "ansible-playbook main.yml --syntax-check" exited with 0.
1.00s$ travis_wait 30 ansible-playbook --extra-vars '{"configure_sudoers":"false"}' main.yml
�ERROR! Syntax Error while loading YAML.
  found unexpected ':'
The error appears to have been in '<string>': line 1, column 19, but may
be elsewhere in the file depending on the exact syntax problem.

This only happens on the run with travis_wait (travis_wait 30 ansible-playbook --extra-vars '{"configure_sudoers":"false"}' main.yml); it doesn't happen if running the command directly...

Add ability to control dock items

The following blog entry shows how we can control dock items and position with your existing homebrew role.

https://blog.vandenbrand.org/2016/01/04/how-to-automate-your-mac-os-x-setup-with-ansible/

It would be freaking awesome to control this through your role too! I'll be using it in my forks regardless, but this is a legitimate improvement which adds to the value and purpose of this role.

vars/main.yml additions

dockitems_disabled:
  - Launchpad
  - Mail
  - Safari
  - Contacts
  - Notes
  - Reminders
  - Maps
  - Photos
  - Messages
  - FaceTime
  - iTunes
  - iBooks
  - App Store
  - System Preferences
  - Calendar
  - Terminal

dockitems_enabled:
  - name: Google Chrome
    path: "/Applications/Google Chrome.app"
    pos: 1
  - name: Tower
    path: "/Applications/Tower.app"
    pos: 2
  - name: FirefoxDeveloperEdition
    path: "/Applications/FirefoxDeveloperEdition.app"
    pos: 3
  - name: Sublime Text
    path: "/Applications/Sublime Text.app"
    pos: 4
  - name: iTerm
    path: "/Applications/iTerm.app"
    pos: 5
  - name: JetBrains Toolbox
    path: "/Applications/JetBrains Toolbox.app"
    pos: 6
  - name: TeavViewer
    path: "/Applications/TeamViewer.app"
    pos: 7

tasks/dockutil.yml:

- name: Dockutil | Remove all unwanted dock items
  shell: dockutil --remove "{{ item }}"
  ignore_errors: true
  with_items: "{{ dockitems_disabled }}"
  when: "{{ dockitems_disabled | length > 0 }}"

- name: Dockutil | Adding items
  shell: dockutil --find "{{ item.name }}" || dockutil --add "{{ item.path }}"
  with_items: "{{ dockitems_enabled }}"
  when: "{{ dockitems_enabled | length > 0 }}"

- name: Dockutil | Moving items
  shell: dockutil --move "{{ item.name }}" --position "{{ item.pos }}"
  with_items: "{{ dockitems_enabled }}"
  when: "{{ dockitems_enabled | length > 0 }}"

Question about standard practice of getting around issue.

Having some trouble getting a success on three casks, I'm just wondering what the standard practice on resolving this problem is? I've tried a lot of things so far and so far nothing has fixed it.

failed: [127.0.0.1] (item=adobe-creative-cloud) => {"changed": true, "cmd": ["bash", "-l", "-c", "/usr/local/bin/brew cask install adobe-creative-cloud --appdir=/Applications"], "delta": "0:00:05.343239", "end": "2016-09-25 00:36:41.952803", "failed": true, "item": "adobe-creative-cloud", "rc": 1, "start": "2016-09-25 00:36:36.609564", "stderr": "Error: Failed to eject /private/tmp/dmg.JZOyio", "stdout": "==> Downloading https://ccmdls.adobe.com/AdobeProducts/KCCC/1/osx10/CreativeCloudInstaller.dmg\n==> No checksum defined for Cask adobe-creative-cloud, skipping verification", "stdout_lines": ["==> Downloading https://ccmdls.adobe.com/AdobeProducts/KCCC/1/osx10/CreativeCloudInstaller.dmg", "==> No checksum defined for Cask adobe-creative-cloud, skipping verification"], "warnings": []}

Ensuring homebrew packages are on the path

I just want to question how getting installed packages on the path is achieved with the default set up. I would have expected either

  • /usr/local/Cellar gets added to the path (i.e. in the .bash_profile)

  • symlinks are created in /usr/local/bin (i.e. for the homebrew module using state=linked rather than state=present)

I don't see evidence of either, so just wondering what is required to get this playbook working

There is a catch all in the README about brew issues and running brew doctor, so here is the info I see

  • Warning: The following directories are not writable: /usr/local/bin (this is expected as pip was used to install ansible with sudo)
  • Warning: You have unlinked kegs in your Cellar (could be fixed manually by making /usr/local/bin writable and running brew link for each pkg or alternatively automatically through the roles by updating the "Ensure proper ownership" task to include the user owner/group and configuring the homebrew module to be state=linked)

That is how I see things at least, but I'm probably missing something so would be happy to be shown the way

Drop hardcoded 'connection: local' in playbook so it can be configured in inventory

I was talking with Jeff Vincent from MacStadium.com, and he likes to demo using this playbook to manage cloud Mac servers—and it would be super easy to make it easier to manage other machines by just dropping this line: https://github.com/geerlingguy/mac-dev-playbook/blob/master/main.yml#L3

Instead, that connection option can be in the inventory, and I could add in the README how to configure the inventory for remote server administration (vs. the default of running on the local host).

See https://docs.macstadium.com/docs/ansible

formula that depends on cask

How could I use this role to install a formula that depends on certain casks?

In my case I want to install wine, which requires the cask xquartz. I imagine there could be other similar cases.

homebrew_installed_packages not installed if homebrew_cask_apps encounters apps which are already installed

I'm running the playbook on a new macbook pro 10.13.1 with some apps installed. When running this playbook it initially failed on brew. see MacOs High Sierra gives problem with Homebrew permissions #55

After I solved that issue I ran into the issue that it will never finish properly due to some overlap in apps needing to be installed and those already on the device. This seems to be related to how homebrew-cask is supposed to behave: Exit with error, if the app is already there ?
Is there an option or workaround to ignore/update apps that are already present on the device?

The issue relates to this part of the code:

homebrew_installed_packages:
  # - ansible # Installed via Pip.
  - autoconf
  - bash-completion
  - chromedriver
  - doxygen
  - gettext
  - gifsicle
  - git
  - go
  - gpg
  - hub
  - httpie
  - iperf
  - libevent
  - sqlite
  - mcrypt
  - nmap
  - node
  - nvm
  - ssh-copy-id
  - cowsay
  - readline
  - openssl
  - pv
  - wget
  - wrk

homebrew_taps:
  - homebrew/core
  - caskroom/cask
  - homebrew/php

homebrew_cask_appdir: /Applications
homebrew_cask_apps:
  - docker
  - dropbox
  # - fing # Download link keeps getting changed, d'oh!
  - firefox
  - google-chrome
  - handbrake
  - licecap
  - limechat
  - macvim
  - sequel-pro
  - skitch
  - slack
  - sublime-text
  - transmit
  - vagrant
  - virtualbox

remove deprecated homebrew casks from config.yml

issue (minor cleanup)

the following casks have

  • homebrew-dupes has been deprecated
  • homebrew-binary
  • homebrew-versions

from https://github.com/Homebrew/homebrew-dupes:

These formulae were those that duplicated software provided by macOS.
All formulae were migrated to Homebrew/homebrew-core or deleted.

from https://github.com/Homebrew/homebrew-binary

These formulae were binary installs of software that, for whatever reason, weren't available as source builds.
This tap was deprecated because Homebrew Cask handles this use-case better. All formulae were migrated to caskroom/homebrew-cask or other taps.

from https://github.com/Homebrew/homebrew-versions

These formulae provided multiple versions of existing packages or newer versions of packages that were too incompatible to go in homebrew/core.
This tap was deprecated because homebrew/core has started to support multiple versions. All widely used, buildable formulae were migrated to homebrew/core.
Learn more about this migration in the Versions documentation.

proposed solution

default config should probably no longer include these in the list of taps

ERROR! Syntax Error while loading YAML.

Been a while since I've run this playbook. But setting up a new machine today I hit a problem when running for the first time complaining about a syntax error in the inventory.

I'm not sure if this is ansible now preferring the YAML inventory syntax over INI but adding -I to the command seems to have done the trick.

Console output:

[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that
the implicit localhost does not match 'all'

PLAY [all] *********************************************************************
skipping: no hosts matched

PLAY RECAP *********************************************************************

ERROR! Syntax Error while loading YAML.
  expected '<document start>', but found '<scalar>'

The error appears to be in '/Users/ryanh/Development/Projects/git/mac-dev-playbook/inventory': line 2, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

[localhost]
127.0.0.1
^ here

Not sure if I've ever thanked you for this project so thanks @geerlingguy. It's a must for setting up a new dev machine in a reproducible way.

Cheers!
Ryan

Ansible hangs when installing java cask.

Description

I'm currently trying to install Java via homebrew but the task "Install configured cask applications." hangs forever and never returns when I run it on my laptop remotely.

Steps to Reproduce

Run:
'ansible-playbook main.yml -l macbook -i inventory --user=$USERNAME --ask-pass -K -vvvv'

With this very simple playbook:

- hosts: all
  roles:
    - role: geerlingguy.homebrew
      homebrew_upgrade_all_packages: no
      homebrew_taps: []
      homebrew_installed_packages: []
      homebrew_cask_apps:
        - java
      homebrew_use_brewfile: no
      when: ansible_os_family == "Darwin"
      tags: ['home-brew']

Analysis

I suspect an issue related to permissions between brew and ssh, maybe it requires a password and it hangs forever.

For instance I've the following error when running the brew command directly from ssh:

ssh $USERNAME@macbook 'PATH=/usr/local/bin:$PATH && brew cask install java'
==> Caveats
This Cask makes minor modifications to the JRE to prevent issues with
packaged applications, as discussed here:

  https://bugs.eclipse.org/bugs/show_bug.cgi?id=411361

If your Java application still asks for JRE installation, you might need
to reboot or logout/login.

Installing this Cask means you have AGREED to the Oracle Binary Code
License Agreement for Java SE at

  https://www.oracle.com/technetwork/java/javase/terms/license/index.html

==> Satisfying dependencies
==> Downloading http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-macosx-x64.dmg
Already downloaded: /Users/username/Library/Caches/Homebrew/Cask/java--1.8.0_144-b01,090f390dda5b47b9b721c7dfaa008135.dmg
==> Verifying checksum for Cask java
==> Installing Cask java
==> Running installer for java; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
==> sudo: no tty present and no askpass program specified
Error: Command failed to execute!

==> Failed command:
/usr/bin/sudo -E -- /usr/sbin/installer -pkg /usr/local/Caskroom/java/1.8.0_144-b01,090f390dda5b47b9b721c7dfaa008135/JDK 8 Update 144.pkg -target /

==> Standard Output of failed command:


==> Standard Error of failed command:
sudo: no tty present and no askpass program specified


==> Exit status of failed command:
#<Process::Status: pid 17126 exit 1>
Error: Install incomplete.

Any idea about this error? How could I workaround this?

Sudo password asked twice

Hi! Thanks for a great repo!

I launched the ansible-playbook command and left it running. I was hoping that after coming back the playbook would had finished. Instead it was stuck asking my sudo password again.

TASK: [geerlingguy.homebrew | Get list of apps installed with cask.] ********** 
Password:

Can this be avoided?

Fresh Macbook Install

failed: [127.0.0.1] => {"cmd": "/usr/bin/git clone --origin origin --branch master git://github.com/Homebrew/homebrew.git /usr/local", "failed": true, "rc": 128}
stderr: fatal: destination path '/usr/local' already exists and is not an empty directory.

document what the dotfiles thing does, or better disable by default

First of all, thanks for this nice thing! It's a great idea and I want to use it as much as possible for package installation.

Eventually also for the dotfiles handling, but not yet.

The dotfile role behaves strangely IMHO.

It does, without further warning, remove a users dotfiles and replace them with yours, which is, in most cases, not very desireable.

Nobody especially wants to commit stuff to git with your own email and such.
Nobody wants his .vimrc and .bash_profile and such erased and replaced with yours without further notice

This was not all very bad in my case as I tested it on a new system. And sure people should check what they run. But the documentation could still be better and defaults set so no destruction occurs.

But still, even after setting up my own fork of a dotfiles repository and having the files committed there in what seems to be the "proper" way, this functionality behaves strangely. It seems to checkout changed but not committed files again, removing all my changes.

This might be desireable on server systems, where I do not want any manual change to hang around.

On a desktop system where sometimes such a change happens, I dont want it to be reverted, but the system telling me to commit. I've seen that warning once or twice, but in other situations files have been just reverted.

I tried to set it uop and work properly with it, but I still experience strange situations, it seems to checkout directory of the dotfiles sometimes gets deleted completely, or local commits that I have not yet pushed seem to get lost.

The dotfiles workflow should be made optional, should work in a way that no changes are reverted without asking the user, and it should be documented how it is supposed to work with it properly.

Concrete questions:

  • how to disable the dotfiles management completely? (commenting out all variables did not work, just lead to run everything with defaults)
  • why does the "config.defaults.yml file set a strange default for the checkout dir (in Dropbox..)? The roles itself already has a sensible default, this additional default seems to be more a personal preference (and therefor might better go into your local config.yml)
  • do changes in the local dotfiles repository need to be pushed before being properly used?
    • or put another way: does the role always do a fresh clone of this repo or reset to the HEAD of origin/master?

Currently, it's just making me mad, getting in my way, and breaking adjustments I made to my system , rendering me unable to do my work in the most unfavorable moments (e.g. right now, when I just wanted to quickly add a brew package, and again something strange happened, and commenting out all dotfiles stuff didn't help, but only made it even worse... )

AttributeError: 'NoneType' object has no attribute 'startswith'

Hi thanks for the repo

I'm new to ansible so forgive me if this is not specific to your work.

(Also, I am using Mojave, which might be something untested?)

When installing "mac-dev-playbook" I get this error:

TASK [geerlingguy.dotfiles : Ensure dotfiles repository is cloned locally.] ********************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'NoneType' object has no attribute 'startswith'
fatal: [127.0.0.1]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/Users/jason/.ansible/tmp/ansible-tmp-1538039081.27-262465592920192/AnsiballZ_git.py\", line 113, in <module>\n    _ansiballz_main()\n  File \"/Users/jason/.ansible/tmp/ansible-tmp-1538039081.27-262465592920192/AnsiballZ_git.py\", line 105, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/Users/jason/.ansible/tmp/ansible-tmp-1538039081.27-262465592920192/AnsiballZ_git.py\", line 48, in invoke_module\n    imp.load_module('__main__', mod, module, MOD_DESC)\n  File \"/var/folders/4n/zf2p613n7411gdzvnqr631v80000gn/T/ansible_git_payload_ca528q/__main__.py\", line 1234, in <module>\n  File \"/var/folders/4n/zf2p613n7411gdzvnqr631v80000gn/T/ansible_git_payload_ca528q/__main__.py\", line 1075, in main\nAttributeError: 'NoneType' object has no attribute 'startswith'\n", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error", "rc": 1}

After a little research, I have tried downgrading Ansible to 2.5.0, and also upgrading to 2.8.0.dev0 .... however neither helped

Any ideas?

thanks

Ways to install non-brew packages.

I personally have a few projects I want to install that aren't available as brew formulas.

Some examples:

Not sure how to automate the installation of dmg packages in a proper way, but I'll look into it. One idea that would make the playbook flexible enough to install my first two requirements is:

extra_git_installs:
  - repo: https://github.com/chriskempson/base16-shell
    destination: ~/.local/lib/base16-shell
  - repo: [email protected]:oxyc/vimrc.git
    destination: ~/Projects/Personal/vimrc
    accept_hostkey: yes
    install_command: "make install"

Thoughts? Should I just keep this in my fork or might something like this be useful for you or others?

Setting the default Terminal theme

I have quite a hacky piece of AppleScript I use to set the default terminal theme. It was pulled from some dotfiles/setup repo but I can't remember where so I'm not able to give proper attribution to the original author. I'm not that familiar with Ansible so I can't make a proper pull request, but I'll leave it here in bash form in case you want to integrate it.

osascript <<EOD
tell application "Terminal"
	local allOpenedWindows
	local initialOpenedWindows
	local windowID
	set themeName to "Flat" (* Set the name of the theme*)
	(* Store the IDs of all the open terminal windows. *)
	set initialOpenedWindows to id of every window
	(* Open the custom theme so that it gets added to the list
	   of available terminal themes (note: this will open two
	   additional terminal windows). *)
	do shell script "open '$HOME/Desktop/" & themeName & ".terminal'"
	(* Wait a little bit to ensure that the custom theme is added. *)
	delay 1
	(* Set the custom theme as the default terminal theme. *)
	set default settings to settings set themeName
	(* Get the IDs of all the currently opened terminal windows. *)
	set allOpenedWindows to id of every window
	repeat with windowID in allOpenedWindows
		(* Close the additional windows that were opened in order
		   to add the custom theme to the list of terminal themes. *)
		if initialOpenedWindows does not contain windowID then
			close (every window whose id is windowID)
		(* Change the theme for the initial opened terminal windows
		   to remove the need to close them in order for the custom
		   theme to be applied. *)
		else
			set current settings of tabs of (every window whose id is windowID) to settings set themeName
		end if
	end repeat
end tell
EOD

Add Sublime configuration and package manager setup

In the README and playbook you've stated you wanted sublime to be configured.

Purely for your information, here's how I've done it - but I based mine off Drupal.org's recommended sublime configuration. (https://www.drupal.org/docs/develop/development-tools/configuring-sublime-text)

The recommended script is here: https://github.com/enzolutions/sublime-drupal or more directly https://raw.githubusercontent.com/enzolutions/sublime-drupal/master/SublimeDrupal.sh.

I haven't covered all of the scripts functionality, but I've covered a lot of it.

tasks/sublime.yml

- name: Sublime | Copying configuration
  copy:
    src: "./files/sublime/Library/Packages/User/Preferences.sublime-settings"
    dest: "{{ sublime_dir }}/{{ sublime_packages_dir }}/User/Preferences.sublime-settings"

- name: Sublime | Install Package Manager
  get_url:
    url: "https://packagecontrol.io/Package%20Control.sublime-package"
    dest: "{{ sublime_dir }}/{{ sublime_packageman_dir }}/Package Control.sublime-package"

- name: Sublime | Install Packages
  git:
    repo: "{{ item.repo }}"
    dest: "{{ sublime_dir }}/{{ sublime_packages_dir }}/{{ item.name }}"
    clone: yes
    update: yes
    force: yes
    accept_hostkey: yes
  become: no
  with_items: "{{ sublime_packages }}"

vars/main.yml

sublime_dir: ~/Library/Application Support/Sublime Text 3
sublime_packages_dir: "Packages"
sublime_packageman_dir: "Installed Packages"
sublime_packageman_file: https://packagecontrol.io/Package%20Control.sublime-package
sublime_packages:
- name: Colorsublime
  repo: https://github.com/Colorsublime/Colorsublime-Plugin.git
- name: DrupalSublimeConfig
  repo: https://github.com/enzolutions/drupal-sublime-config.git
- name: BracketHighlighter
  repo: https://github.com/facelessuser/BracketHighlighter.git
- name: Highlighter
  repo: https://github.com/bluegray/Highlighter.git
- name: ApplySyntax
  repo: https://github.com/facelessuser/ApplySyntax.git
- name: PrettyYAML
  repo: https://github.com/aukaost/SublimePrettyYAML.git
- name: Dracula Color Scheme
  repo: https://github.com/dracula/textmate.git
- name: Darkula
  repo: https://github.com/mattchanner/darkula.git
- name: DocBlockr
  repo: https://github.com/spadgos/sublime-jsdocs.git
- name: Sublime-Text-2-Goto-Drupal-API
  repo: https://github.com/BrianGilbert/Sublime-Text-2-Goto-Drupal-API.git
- name: DrupalSublimeSnippets
  repo: https://github.com/juhasz/drupal_sublime-snippets.git
- name: DrupalCodingStandard
  repo: https://github.com/rypit/DrupalCodingStandard.git
- name: sublime-text-2-goto-documentation
  repo: https://github.com/kemayo/sublime-text-2-goto-documentation.git
- name: SyncedSideBar
  repo: https://github.com/sobstel/SyncedSideBar.git
- name: TrailingSpaces
  repo: https://github.com/SublimeText/TrailingSpaces.git
- name: st2-drupal-autocomplete
  repo: https://github.com/tanc/st2-drupal-autocomplete.git
- name: sublime-find-function-definition
  repo: https://github.com/timdouglas/sublime-find-function-definition.git
- name: sublime-text-2-git
  repo: https://github.com/kemayo/sublime-text-2-git.git
- name: GitGutter
  repo: https://github.com/jisaacks/GitGutter.git
- name: SideBarGit
  repo: https://github.com/SublimeText/SideBarGit.git
- name: SublimeLinter
  repo: https://github.com/SublimeLinter/SublimeLinter.git
- name: SASS
  repo: https://github.com/nathos/sass-textmate-bundle.git
- name: SideBarEnhancements
  repo: https://github.com/titoBouzout/SideBarEnhancements.git
- name: CssSnippets
  repo: https://github.com/P233/Emmet-Css-Snippets-for-Sublime-Text-2.git
- name: JSLint
  repo: https://github.com/darrenderidder/Sublime-JSLint.git
- name: MacTerminal
  repo: https://github.com/afterdesign/MacTerminal.git
- name: Theme - Soda
  repo: https://github.com/buymeasoda/soda-theme.git

Add travis_wait configuration for long-running initial install on Travis CI

See build failure: https://travis-ci.org/geerlingguy/mac-dev-playbook/builds/174228609

TASK [geerlingguy.homebrew : Ensure configured homebrew packages are installed.] ***
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.

Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received

The build has been terminated

We should be able to use travis_wait to fix this.

Allow custom osx script

Currently the osx script is hardcoded as ~/.osx --no-restart while I personally keep it in an .osx/ subfolder of my dotfiles repo–It would be nice if this was configurable. As you pass arguments to your script maybe just add it an osx_script variable?

I dropped a bottle on my laptop during the night and apparently the MacBook 12" isn't as durable as it looks... Once I get my fork of this project set up, and vim configured, I can start pushing PR's for review.

Make things work with macOS Sierra

Just creating an issue to track some changes... it's been a couple months since last time I ran the playbook, plus Homebrew 1.0.0 is out, so the geerlingguy.homebrew role has changed in the way it installs Homebrew (for new installs).

Question: How do you handle python, pip, php, composer installations?

I noticed that you are installing node and nvm with homebrew. Why not ruby/rbenv python/pip/pipenv, php/composer?

If you are installing these with another method what is it? I know you are saying that you install ansible with pip but your missing the pip installation step. Are you using the built in python/php?

Post provision script

Part of my bootstrap is switching to bash4 but this requires a manual command to add it to change the login shell.

if ! grep -Fxq "/usr/local/bin/bash" /etc/shells; then
  echo /usr/local/bin/bash >> /etc/shells
  sudo -u oxy 'chsh -s /usr/local/bin/bash'
fi

Interested in adding post_provision_scripts? Feel free to simply close any of these suggestions–I'll use a fork either way but posting in case you're interested.

Travis CI build idempotence test failing due to Caskroom and bin dirs

 _____________________________________________________________ 
/ TASK [geerlingguy.homebrew : Ensure proper homebrew folders \
\ are in place]                                               /
 ------------------------------------------------------------- 
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
ok: [localhost] => (item=Cellar)
ok: [localhost] => (item=Homebrew)
ok: [localhost] => (item=Frameworks)
changed: [localhost] => (item=Caskroom)
changed: [localhost] => (item=bin)
ok: [localhost] => (item=etc)
ok: [localhost] => (item=include)
ok: [localhost] => (item=lib)
ok: [localhost] => (item=opt)
ok: [localhost] => (item=sbin)
ok: [localhost] => (item=share)
ok: [localhost] => (item=share/zsh)
ok: [localhost] => (item=share/zsh/site-functions)
ok: [localhost] => (item=var)

See: https://travis-ci.org/geerlingguy/mac-dev-playbook/builds/370149396#L1162-L1185

I'm guessing it's a file ownership issue, something like that. This could be an upstream issue in the geerlingguy.homebrew role, though. In any case, tests pass otherwise... it would be nice to not have to remove the idempotence test though, especially since it's just these two tiny items in one task that are causing the failure.

Automated testing via travis CI

I've been playing around with OSX travis tests lately, and I don't believe it would be overly difficult to implement into mac-dev-playbook.

I don't know if there's any reason it isn't done already as the associated roles have tests attached to them - but is there any particular reason mac-dev-playbook wasn't made with tests in mind?

I'm thinking of doing it myself to my own fork, but I wanted to hear the reasons of decisions and gather all the information before I try it.

Passwordless sudo for vagrant-hostsupdater does not work with GNU sed

If the user replaces the default BSD sed with GNU sed through homebrew, the path will be /usr/local/bin/sed rather than /usr/bin/sed, and therefore the passwordless sudo wont work.

Disclaimer:
Personally it's always been confusing to me when the default tools on macos are a) waaay outdated and b) BSD versions rather than GNU versions which I'm used to from Linux (sed flags being particularly confusing in it's BSD version). To normalize my environments I update all builtin packages and switch to GNU when possible https://github.com/oxyc/mac-dev-playbook/blob/master/config.yml#L31:L68

TLS Protocol Version errors on Travis

I noticed Travis CI errors when installing dependency roles from Ansible Galaxy. The full error message:

[ERROR]: failed to download the file: Failed to validate the SSL certificate
for github.com:443. Make sure your managed systems have a valid CA certificate
installed. You can use validate_certs=False if you do not need to confirm the
servers identity but this is unsafe and not recommended. Paths checked for this
platform: /etc/ssl/certs, /etc/ansible, /usr/local/etc/openssl. The exception
msg was: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
(_ssl.c:590).

I believe this is because GitHub/Galaxy dropped support for TLS 1.0 and MacOS's system Python relies on an old openssl library.

I've proposed a workaround to this error here: geerlingguy/ansible-role-homebrew#91

Add composer/npm/gem support

Would you be interested in PR's for supporting installing composer with global packages, ruby gems and npm packages?

For composer we could use geerlingguy.composer with something like:

composer_keep_updated: true
composer_add_to_path: false
composer_add_project_to_path: false
composer_home_path: '~/.composer'
composer_home_owner: "{{ ansible_env.SUDO_USER | default(ansible_env.USER, true) | default(ansible_user_id, true) }}"
composer_home_group: "staff" # @todo
composer_global_packages:
  - { name: hirak/prestissimo, release: '^0.3' }
  - { name: wp-cli/wp-cli, release: '^1.0' }
  - { name: drush/drush, release: '^8.1' }

For NPM and gems, we could probably just rely on the user installing the brew formulas and then use the ansible package modules.

Add /etc/sudoers configuration for more Vagrant convenience

Things like NFS exports and hosts updating are annoying, since they happen mid-vagrant up and mid-vagrant destroy. I would like to configure sudoers by adding the following to the file:

# Vagrant sudoers config
Cmnd_Alias VAGRANT_EXPORTS_ADD = /usr/bin/tee -a /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /bin/sed -i -e /*/ d /etc/hosts
%admin ALL=(root) NOPASSWD: VAGRANT_EXPORTS_ADD, VAGRANT_NFSD, VAGRANT_EXPORTS_REMOVE, VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE

Some problems on completely fresh macbook

  1. You have to create inventory file and apecify self host or modify it in main.yml
  2. Without github host in .ssh/known_hosts homebrew first task will fail
  3. Homebrew taps packer, drush, php56, php56-xdebug, drush are missed

MacOs High Sierra gives problem with Homebrew permissions

I am running playbook similar to your Mac-dev-playbook. Recently I upgraded to Mac OS High Sierra. Everything was running fine until recently. After the upgrade there is permissions issue which fails the playbook. Attached is the screenshot of the error.

homebrew error

Any idea how to resolve this issue?

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.