Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds tasks for installing dependencies on Mac #14

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 36 additions & 2 deletions ansible/install-dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

- hosts: localhost
tasks:
- name: Install Vagrant, Virtualbox and other dependencies
- name: Install Vagrant, Virtualbox and other dependencies (linux)
become: yes
package:
name: "{{ item }}"
Expand All @@ -16,8 +16,29 @@
- virtualbox
- vagrant
- jq
when: ansible_facts['os_family'] != "Darwin"

- name: Install Terraform
- name: Install Vagrant & Virtualbox (mac)
become: no
homebrew_cask:
name: "{{ item }}"
state: present
with_items:
- virtualbox
- vagrant
when: ansible_facts['os_family'] == "Darwin"

- name: Other dependencies (mac)
become: no
homebrew:
name: "{{ item }}"
state: present
with_items:
- coreutils # for GNU ls
- jq
when: ansible_facts['os_family'] == "Darwin"

- name: Install Terraform (linux)
shell: >
wget -O /tmp/terraform.zip "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip"
&& unzip -d ~/.local/bin /tmp/terraform.zip
Expand All @@ -27,6 +48,19 @@
args:
creates: ~/.local/bin/terraform
warn: False
when: ansible_facts['os_family'] != "Darwin"

- name: Install Terraform Homebrew Tap (Mac)
homebrew_tap:
name: hashicorp/tap
state: present
when: ansible_facts['os_family'] == "Darwin"

- name: Install Terraform (Mac)
homebrew:
name: hashicorp/tap/terraform
state: present
when: ansible_facts['os_family'] == "Darwin"

- hosts: localhost
tags:
Expand Down
22 changes: 14 additions & 8 deletions scripts/commands/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ main () {

echo "Installing Ansible..."
if ! command -v ansible > /dev/null; then
echo "Your SUDO password may be asked"

[[ "${TADS_VERBOSE:-}" == true ]] && set -x
sudo apt-get update \
&& sudo apt-get --yes install software-properties-common \
&& sudo apt-add-repository --yes --update ppa:ansible/ansible \
&& sudo apt-get --yes install ansible
set +x
if command -v apt-get > /dev/null; then
echo "Your SUDO password may be asked"

[[ "${TADS_VERBOSE:-}" == true ]] && set -x
sudo apt-get update \
&& sudo apt-get --yes install software-properties-common \
&& sudo apt-add-repository --yes --update ppa:ansible/ansible \
&& sudo apt-get --yes install ansible
set +x
else
echo "Unable to work out how to install Ansible. Either install it first, manually,"
echo "or update the ${SELF_PATH}/${SELF_NAME} script"
echo "to support installing automatically on your OS."
fi
else
echo "Ansible is already installed. Skipping"
fi
Expand Down
7 changes: 6 additions & 1 deletion scripts/includes/ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ readonly TADS_MIN_ANSIBLE_VERSION="2.8"
export ANSIBLE_DEPRECATION_WARNINGS="False"

get_ansible_remote_environments () {
ls -1 -I "localhost" -I "*.sample*" "${ROOT_PATH}/ansible/inventories"
# Test for Mac GNU ls command (installed in `ansible/install-dependencies.yml`)
if [ -f /usr/local/opt/coreutils/libexec/gnubin/ls ] ; then
/usr/local/opt/coreutils/libexec/gnubin/ls -1 -I "localhost" -I "*.sample*" "${ROOT_PATH}/ansible/inventories"
else
ls -1 -I "localhost" -I "*.sample*" "${ROOT_PATH}/ansible/inventories"
fi
}

check_ansible () {
Expand Down