Code Monkey home page Code Monkey logo

mac-playbook's Introduction

Mac Ansible Playbook

The Web server (nginx), PHP and the services (MariaDB, PostgreSQL, Mailpit) are installed locally with Ansible.

All the management of the system (configuration, update, etc) goes through this tool which allows everyone to have a similar environment.

Install

You must first clone the repository to setup the environment.

$ xcode-select --install
$ git clone https://github.com/Akollade/mac-playbook.git ~/.mac-playbook
# With SSH
$ git clone [email protected]:Akollade/mac-playbook.git ~/.mac-playbook

Then you have to configure the environment:

$ cd ~/.mac-playbook
$ touch config.yml
$ vim config.yml

You can look in the file default.config.yml to customize your environment.

Example :

---
############
# SYSTEM   #
############

edit_dev_config_with: code

homebrew_cask_packages:
  - tableplus
  - iterm2
  - alfred
  - code

############
# dotfiles #
############

zsh_theme: agnoster

#########
# GIT   #
#########

git_user_name: John Doe
git_user_email: [email protected]

###########
# Nginx   #
###########

nginx_sites:
  - name: wallabag
    server_name: wallabag.localhost
    type: symfony
    root: "~/dev/wallabag/web"
    php_version: '8.0'

Homebrew is needed, see https://brew.sh/ to install it.

Then :

# Edit your bashrc or zshrc to include "export PIPX_HOME=$HOME/.local/pipx"
$ make bootstrap
$ make setup-mkcert

And to finish : reboot the computer.

From there, you can use the dev binary to manage the environment.

Save password

To avoid having to enter the SUDO password all the time we will encrypt our SUDO password with a password that will be stored in the keychain :

$ ./scripts/generate-ansible-password

Usages

To list all commands just type dev.

License

mac-playbook is licensed under the MIT license.

mac-playbook's People

Contributors

notfloran avatar nclshart avatar tomberriot avatar renovate[bot] avatar gignonje avatar

Stargazers

Dominik Antal avatar Mark avatar Arnaud Lecat avatar  avatar  avatar

Watchers

Arnaud Lecat avatar  avatar  avatar James Cloos avatar

Forkers

gignonje

mac-playbook's Issues

Cleanup - brew services

The "brew services" has a cleanup mode => brew services cleanup

We can add it to the cleanup role.

Allow to add custom zsh aliases

Add a new key in config to allow user to add custom zsh aliases.

Example:

zsh_aliases:
  - ll='ls -lh'
  - gut="git"
  - gti="git"

Allow to configure zsh plugins

Currently, list of activated zsh plugins is hard coded in the project. Even if most of this playbook users are working in the same company, we are sometimes working on different projects and different stacks.

With the same idea as #61, it could be a great UX improvement to allow user to configure their zsh plugins through config file.

For example:

zsh_plugins:
  - git
  - history-substring-search
  - sudo
  - composer
  - brew
  - httpie
  - extract

mkcert - generate only one certificate

Like in the example :

$ mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1
Using the local CA at "/Users/filippo/Library/Application Support/mkcert" ✨

Created a new certificate valid for the following names 📜
 - "example.com"
 - "*.example.com"
 - "example.test"
 - "localhost"
 - "127.0.0.1"
 - "::1"

The certificate is at "./example.com+5.pem" and the key at "./example.com+5-key.pem" ✅

force postgresql 11

Replace usage of package name postgresql by postgresql@11

  • brew install
  • brew services

Improve management of custom zsh plugins

With #60, we are now adding 3 externals zsh plugins.

For this 3 plugins, we have 2 different modes of operation:

  • plugin is installed but need to be activate using config key
  • plugin is installed and always activated

I think we could improve this in order to have only one consistent way for handling custom zsh plugins and at the same time, allow user to add their own plugins through configuration.

zsh_custom_plugins:
  - name: symfony
    url: [email protected]:TheGrowingPlant/symfony.plugin.zsh.git
  - name: zsh-autosuggestions
    url: https://github.com/zsh-users/zsh-autosuggestions.git
  - name: zsh-syntax-highlighting
    url: https://github.com/zsh-users/zsh-syntax-highlighting.git

Custom plugins should be added at the end of the list and order should be preserved for plugin like zsh-syntax-highlighting which need to be loaded after others.

I identify one problem with this config: we are adding special config to zshrc for zsh-syntax-highlighting plugin. Maybe we could handle this using an extra_config key or something like this.

Allow custom git aliases

Like zsh aliases, it could be great to allow git aliases customization.

Something like:

git_aliases:
    sl: stash list
    sa: stash apply
    ss: stash save

Use of outdated brew cask commands by Ansible

The actual version of Ansible uses a deprecated command from actual brew commands.

TASK [common : Install homebrew cask packages] *********************************************
failed: [127.0.0.1] (item=google-chrome) => changed=false
  ansible_loop_var: item
  item: google-chrome
  msg: 'Error: Calling brew cask install is disabled! Use brew install [--cask] instead.'

There is actually a PR on ansible-collections / community.general to fix this issue.

ansible-collections/community.general#1481

Homebrew version has to be downgraded manually while this issue is not fixed.

ansible-collections/community.general#1524 (comment)

I ran a manual brew upgrade as the script was breakinb due to an outdated version of curl on my environment.

failed: [127.0.0.1] (item=filezilla) => changed=false
  ansible_loop_var: item
  item: filezilla
  msg: |-
    Updating Homebrew...
    Warning: curl is outdated!
    To avoid broken installations, as soon as possible please run:
      brew upgrade
    Or, if you're OK with a less reliable fix:
      brew upgrade curl
    Error: Calling brew cask install is disabled! Use brew install [--cask] instead.

Maybe we will have to upgrade the version of Ansible when the fix will be released ?

Git noprefix and Grumphp git_blacklist compatibility

There is a compatibility issue between the git option noprefix and the git_blacklist task of Grumphp.

Example:

No match for regexp /diff --git (a\/.*) (b\/.*)\n/ Upcoming: diff --git REA
  DME.md README.md

I see 3 ways to fix this issues:

  1. wontfix: we keep the git option by default and we must override it localy in projects using grumphp.
  2. we remove the option noprefix from global git config and add a git df alias including it.
  3. we just remove the option noprefix from global git config

Remove fixed xdebug version

The xdebug version is set in xdebug_version and so we often forget to update the variable to the latest version.

We must find a way to install the latest version directly.

macOS Catalina

cd ~/.mac-playbook
./scripts/bootstrap.sh
brew upgrade
brew cleanup
dev restart

Big Sur

restart of services failes

CleanShot 2020-11-17 at 21 20 56@2x

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.