Common Tools

The tools described here are meant to empower dev teams to accomplish the same steps described elsewhere in these docs -- e.g. creating a CI Build Node with VMware -- but with healthy dose of efficiency at scale. Using infrastructure as code -- the creation of pre-defined scripts to be executed in pre-defined contexts -- is how we'll get there.

Tools

Ansible
Packer
Xcode + Homebrew
MAMP Stack

Ansible

Installation Guide
Ansible Docs

Ansible is a largely free and open source server configuration tool. It must be installed, along with Python, on the "control machine," which can be your local desktop if you like. From there, Ansible will require SSH access to the target server -- in this case your Mac Cloud.

Once Ansible has gained access to the target environment via SSH, it can run provisioning scripts and the like to prepare your environment for whatever work needs to be done -- be it CI or anything else.

Starter Scripts

MacStadium maintains a handful of example scripts to get you started on the road to automating your deployments and more.

Ansible Roles


Roles are sets of tasks and files used to configure a host machine to perform a specific role (thus, the name).

Ansible Role: macOS CI
Ansible Role: Xcode

Ansible Playbooks


Playbooks are mappings of Ansible Roles and the various host machines they are meant to configure for a given process.

Ansible Playbook: macOS CI Setup

Packer

Installation Guide
Packer Docs

Packer is a powerful, open-source tool that allows you to store a "live image" of a virtual machine, which can be cloned in seconds, rather than minutes or hours. It utilizes JSON to define the VM template, and because it is command-line-driven, it can easily be integrated into your build pipeline.

Packer is not a direct substitute for provisioning solutions. In fact, it is built to interface easily with Chef, Puppet and Ansible for the provisioning of the base VM image.

VM Templates

OSX VM Templates for Packer and VeeWee


Virtual machine templates for your building pleasure.

VM Templates

Xcode + Homebrew

Homebrew is a package manager that makes installing packages from the Mac terminal quick and easy. If you need to brush up on your skills with the Mac terminal, check out this tutorial.

Prerequisites:
Homebrew relies upon Xcode. So, you'll need to have Xcode installed. If you don't already have it, you can find it in the Apple AppStore.

You will be required to have some fluency with the Mac Terminal App which is situated in the Utilities Folder under the Applications Folder.

Process:

Installing Homebrew is straightforward; you’re only required to paste a single line of code in to your Terminal in order to install it.

  1. Open your Terminal App

  2. Copy and paste the following command, and then press ENTER

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install”
  1. Hit the RETURN key when asked to do so

  2. Follow the installation process on screen

When necessary, you can update Homebrew by simply using the following command in the Terminal App:

brew update

You can also enable auto completion for your brew commands by entering the command:

brew install bash-completion

Uninstalling Homebrew:

Uninstalling Homebrew is just as simple as installing it.

  1. Open the Terminal App

  2. Copy and paste the following command and then press ENTER:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

MAMP Stack

Prerequisites:
Xcode
Homebrew
Homebrew-Cask
Text Editor (like Sublime Text 2) as you will need to edit some lines of code
Mac with High Sierra or above

Process:

First we need to stop the system installation of Apache from starting on boot:

sudo launchctl unload -w/System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

We then have to stop the system installation of Apache, in case it is running in the background. We are going to install Apache using Homebrew, which will allow us to control the version of Apache:

sudo apachectl stop

If you haven't installed Apache before, expect a notification that it could not find specified service.

Now we can proceed with the installation of Apache 2.4:

brew install httpd

Once the process finishes, you can check if your installation was successful. Be aware of the PATH used during installation of Homebrew-Cask, as you may have changed it:

which apachectl /usr/local/bin/apachectl

You can also check with:

httpd -v

This command will display the version of your server and its build.

At this stage, you should be ready to start Apache:

sudo apachectl start

Your website will be located under the IP address of your machine, for example http://207.254.1.1. Hopefully you’ll get a satisfying message saying “It Works!”

Now we have to make sure that Apache starts automatically on startup in case you decide to reboot your machine:

brew services start httpd

In the latest version of Brew, the default port used for Apache is 8080, you should change it to 80 using the Terminal App:

open -e /usr/local/etc/httpd/httpd.conf

Simply find the line that says Listen 8080 and change it to Listen 80.

Look for AllowOverride in your file, we will need to change it to:

AllowOverride controls what directives may be placed in .htaccess files.
It can be "All", "None", or any combination of the keywords:

AllowOverride FileInfoAuthConfig Limit

AllowOverride All

We also have to enable mod_rewrite

Search for the following line:

# LoadModule rewrite_module lib/httpd/modules/mod_rewrite.so

And simply remove the # just before LoadModule.

Finally, we need to edit our ServerName which would look like this in your file:

# ServerName www.example.com:8080

Replace it with your IP Address or domain:

ServerName 207.254.1.1

You can now restart apache:

sudo apachectl -k restart

PART 2 – PHP

First of all you need to decide which version of PHP you require ranging from 5.6 to 7.2, in this tutorial we’ll use 7.2 but installation of any other version would be much alike.

Install PHP 7.2 using brew.

brew install [email protected]

You can simply replace the 7.2 with another version according to your needs, it can be 5.6, 7.0, 7.1.

Once the installation finishes, you can begin editing files, beginning with php.ini. It is the default configuration file for running applications.

You can decide to change the memory_limit, upload_max_filesize or max_execution_time. You can also activate safe mode.

Now you need to go back to your httpd.conf file which we edited during the Apache installation process and add a line which will connect PHP with Apache once again use:

open -e /usr/local/etc/httpd/httpd.conf

Add libphp somewhere below the last edit we made by uncommenting LoadModule:

LoadModule php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.so

At your discretion, depending on the project you’re working on, you can also edit an option which will allow you to load index.php or index.html

Look for:

<IfModule dir_module>
   DirectoryIndex index.html
</IfModule>

And replace it with:

<IfModule dir_module>
   DirectoryIndex index.htmlindex.htm index.php 
</IfModule>
Now you can stop and start apache once again to validate the changes.

**PART 3 – MYSQL**

At last you can install mysql and the process is very straightforward. You can even use the Native Packages to run the whole installation process.

For this example, we will go through the process of installing it with Homebrew:
brew install mysql

Now you can load and start services:

brew services start mysql

It will tell you to secure your installation, run the following command:

mysql_secure_installation

Set a new root password, remove anonymous users and other options to limit access to localhost only.

You can now restart the MySQL server:

brew services restart mysql

You’re all set.

Updated 3 months ago


Common Tools


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.