do-community / do-blueprint-mysqlgrouprepl

Blueprint for setting up MySQL group replication with ProxySQL to route queries
MIT License
5 stars 1 forks source link

MacOS no longer uses BASH #7

Open cjboco opened 2 years ago

cjboco commented 2 years ago

The instructions for installing do not work on MacOS anymore, since MacOS has replaced bash with zsh.

Alternative instructions would be helpful

cjboco commented 2 years ago

So, I figured things out. These are the steps I took on MacOS to get this working.

1) Download Docker and install it. After installation, you need to open the app and accept the terms. This is required as it installs the docker CLI command that's needed for the bp() function below.

2) We need to add the bp() function to zsh. I use oh-my-zsh, so these instructions are specific to this setup. First, we need to add a directory called bp to the custom plugin directory located at ~/.oh-my-zsh/custom/plugins/. Inside the bp directory, create a file called bp.plugin.zsh and add the following contents:

bp() {
    docker run -it --rm \
    -v "${PWD}":"/blueprint" \
    -v "${HOME}/.terraform.d":"/root/.terraform.d" \
    -v "${HOME}/.bp-ssh":"/root/.bp-ssh" \
    -v "${HOME}/.config":"/root/.config" \
    -e ANSIBLE_TF_DIR='./terraform' \
    -e HOST_HOSTNAME="${HOSTNAME}" \
    -e HOST_UID="$(id -u)" \
    -e HOST_GID="$(id -g)" \
    docommunity/bp "$@"
}

complete -W "terraform doctl ./terraform.py ansible ansible-connection ansible-doc ansible-inventory ansible-pull ansible-config ansible-console ansible-galaxy ansible-playbook ansible-vault" "bp"

In the terminal, type the following command or open manually: $ open ~/.zshrc

Find the plugins=() line (around line 71) and add our new function to the list. Should look like plugins=(bp) or plugins=(bp git something), if you have multiple items. Once done, close the file and reload zsh by typing: $ source ~/.zshrc

3) If you haven't installed ansible, do so with homebrew (if you need to install homebrew, google it). $ brew update; brew install ansible;

That's it. From there you should be able to continue with the setup as described in the instructions: $ bp ansible-playbook setup.yml