Skip to content

Commit

Permalink
Merge pull request #83 from werne2j/cleanMacLogic
Browse files Browse the repository at this point in the history
Clean mac logic
  • Loading branch information
arilivigni authored Sep 7, 2018
2 parents 8f07025 + b360642 commit c129e6b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 22 deletions.
18 changes: 6 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
- [Example 3: Setup on a local machine :: Setup Minishift + OS templates + Jenkins 2.0 pipelines](#example-3-setup-on-a-local-machine--setup-minishift--os-templates--jenkins-20-pipelines)
- [Example 4: Setup on a local machine :: Start Minishift w/profile mysetup + OS templates + Jenkins 2.0 pipelines](#example-4-setup-on-a-local-machine--start-minishift-wprofile-mysetup--os-templates--jenkins-20-pipelines)
- [Example 5: Setup on a local machine :: Using the playbook hooks on contra-env-setup](#example-5-setup-on-a-local-machine--using-the-playbook-hooks-on-contra-env-setup)
- [Mac Setup](#mac-setup)
- [Mac Users](#mac-users)
- [Debugging Issues](#debugging-issues)
- [Issue #1: Can't push images to the Minishift cluster](#issue-1-cant-push-images-to-the-minishift-cluster)
- [Solution #1:](#solution-1)
Expand Down Expand Up @@ -65,10 +65,9 @@ or only certain components. ex. minishift, jenkins infra, pipeline containers,

## Pre-Setup options

* host_os: Set the OS of the machine you are running the setup on : default=linux
* shell_rc: Set your shell configuration file : default=.bashrc
* run_cleanup: Run clean up of previous setup : default=false
* run_prereqs: Run setting up virtualization and kvm-driver : default=true
* shell_rc: Set your shell configuration file : default=.bashrc
* contra_env_setup_dir: Directory to store the contra-env-setup : default "{{ ansible_env.HOME }}/.contra-env-setup

## Override options
Expand Down Expand Up @@ -246,21 +245,16 @@ _Note: The -K is used to prompt you for your password for sudo (if you require o
The -k is used to prompt you for your ssh password can hit enter if using -K and they are the same<br>
Instead of -k you could use --private-key=<absolute_path_to_ssh_private_key>_

## Mac Setup
## Mac Users

In order to run this setup when using a mac, a few other steps must be taken.
* Install [Homebrew](https://brew.sh/) and [Virtualbox](https://www.virtualbox.org/)
* With Homebrew, install jq and gtar. `brew install jq gtar`
* When running the `setup.yml` file..
- Override `host_os` with `darwin`
- Disable pre-reqs `run_prereqs=false`
- Add `--connection=local` to end of command
* When running the `setup.yml` add `--connection=local` to end of command

Example:
```
ansible-playbook -vv -i "localhost," playbooks/setup.yml \
-e user=cloud-user -e run_prereqs=false -e setup_pipelines=true \
-e host_os=darwin -e setup_sample_project -K -k --connection=local
-e user=cloud-user -e setup_pipelines=true \
-e setup_sample_project -K -k --connection=local
```

## Debugging Issues
Expand Down
3 changes: 0 additions & 3 deletions playbooks/group_vars/all/global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ dkvm_version: v0.10.0
# minishift version
minishift_version: v1.23.0

# host os
host_os: linux

# shell configutation file
shell_rc: .bashrc

Expand Down
10 changes: 10 additions & 0 deletions playbooks/roles/prereqs/tasks/check_os.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# Get OS of host machine

- name: Check Operating System
shell: "uname"
register: uname_result

- name: Save the OS as host_os
set_fact:
host_os: "{{ uname_result.stdout | lower }}"
36 changes: 36 additions & 0 deletions playbooks/roles/prereqs/tasks/install_mac_pre_reqs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
- name: Set homebrew packages to install
set_fact:
brew_cask_packages:
- "virtualbox"
brew_packages:
- "jq"
- "gnu-tar"

- name: Ensuring Homebrew Is Installed
stat:
path: "/usr/local/bin/brew"
register: "homebrew_check"

- name: Installing Homebrew
command: "/usr/bin/ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'"
when: not homebrew_check.stat.exists

- name: Updating Homebrew
homebrew:
update_homebrew: true
when: homebrew_check.stat.exists

- name: Installing Homebrew Packages
homebrew:
name: "{{ item }}"
state: "present"
with_items: "{{ brew_packages }}"
when: homebrew_check.stat.exists

- name: Installing Homebrew Cask Packages
homebrew_cask:
name: "{{ item }}"
state: "present"
with_items: "{{ brew_cask_packages }}"
when: homebrew_check.stat.exists
18 changes: 11 additions & 7 deletions playbooks/roles/prereqs/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
---
# tasks file for prereqs

# Check if nested virtualization is enabled
- import_tasks: setup_nested_virt.yml
# install necessary virtualization plugins
- name: Linux pre reqs setup
block:
- import_tasks: setup_nested_virt.yml
- import_tasks: install_virtual_reqs.yml
- import_tasks: install_kvm_plugin.yml
when: host_os == "linux"

# Install package requirements for contra-env-setup
- import_tasks: install_virtual_reqs.yml

# install the kvm plugin
- import_tasks: install_kvm_plugin.yml
# install homebrew and brew packages
- name: Mac pre req setup
import_tasks: install_mac_pre_reqs.yml
when: host_os == "darwin"
2 changes: 2 additions & 0 deletions playbooks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
become_user: '{{ become_user | default("root") }}'
remote_user: '{{ user | default("root") }}'
gather_facts: '{{ gather_facts | default("yes") }}'
pre_tasks:
- import_tasks: 'roles/prereqs/tasks/check_os.yml'
roles:
- { role: cleanup, when: run_cleanup|bool == true }
- role: create
Expand Down

0 comments on commit c129e6b

Please sign in to comment.