Skip to content

Commit

Permalink
Initial macOS ansible scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
George Adams committed Nov 20, 2017
1 parent 326ca9d commit af48068
Show file tree
Hide file tree
Showing 17 changed files with 271 additions and 42 deletions.
18 changes: 18 additions & 0 deletions ansible/MANUAL_STEPS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Manual steps required to run ansible on machines

## macOS
1. Update Sudoers file:

this requires `NOPASSWD` to be added to the sudoers file to enable elevation

`sudo visudo`
and change:
`%admin ALL = (ALL) ALL`
to
`%admin ALL = (ALL) NOPASSWD:ALL`

2. Allow ssh access

```bash
sudo systemsetup -setremotelogin on
```
13 changes: 13 additions & 0 deletions ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ hosts:
ubuntu1604-arm64_odroid_c2-2: {ip: 70.167.220.148, user: odroid}
ubuntu1604-arm64_odroid_c2-3: {ip: 70.167.220.149, user: odroid}

- macstadium:
macos10.08-x64-1: {ip: 207.254.58.162, port: 10009, user: administrator}
macos10.08-x64-2: {ip: 207.254.58.162, port: 10010, user: administrator}
macos10.09-x64-1: {ip: 207.254.58.162, port: 10007, user: administrator}
macos10.09-x64-2: {ip: 207.254.58.162, port: 10008, user: administrator}
macos10.10-x64-1: {ip: 207.254.58.162, port: 10005, user: administrator}
macos10.10-x64-2: {ip: 207.254.58.162, port: 10006, user: administrator}
macos10.11-x64-1: {ip: 207.254.58.162, port: 10003, user: administrator}
macos10.11-x64-2: {ip: 207.254.58.162, port: 10004, user: administrator}
macos10.12-x64-1: {ip: 207.254.58.162, port: 10001, user: administrator}
macos10.12-x64-2: {ip: 207.254.58.162, port: 10002, user: administrator}


- osuosl:
aix61-ppc64_be-1: {ip: 140.211.9.101}
aix61-ppc64_be-2: {ip: 140.211.9.100}
Expand Down
2 changes: 2 additions & 0 deletions ansible/partials/install-homebrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
yes | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
44 changes: 44 additions & 0 deletions ansible/partials/install-xcode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
osx_vers=$(sw_vers -productVersion | awk -F "." '{print $2}')
cmd_line_tools_temp_file="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"

# Installing the latest Xcode command line tools on 10.9.x or higher

if [[ "$osx_vers" -ge 9 ]]; then
touch "$cmd_line_tools_temp_file";
PROD=$(softwareupdate -l |
grep "\*.*Command Line" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
softwareupdate -i "$PROD";
fi

# Installing the latest Xcode command line tools on 10.7.x and 10.8.x

# on 10.7/10.8, instead of using the software update feed, the command line tools are downloaded
# instead from public download URLs, which can be found in the dvtdownloadableindex:
# https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex

if [[ "$osx_vers" -eq 7 ]] || [[ "$osx_vers" -eq 8 ]]; then

if [[ "$osx_vers" -eq 7 ]]; then
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg
fi

if [[ "$osx_vers" -eq 8 ]]; then
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_osx_mountain_lion_april_2014.dmg
fi

TOOLS=cltools.dmg
curl "$DMGURL" -o "$TOOLS"
TMPMOUNT=`/usr/bin/mktemp -d /tmp/clitools.XXXX`
hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" -nobrowse
# The "-allowUntrusted" flag has been added to the installer
# command to accomodate for now-expired certificates used
# to sign the downloaded command line tools.
installer -allowUntrusted -pkg "$(find $TMPMOUNT -name '*.mpkg')" -target /
hdiutil detach "$TMPMOUNT"
rm -rf "$TMPMOUNT"
rm "$TOOLS"
fi
2 changes: 1 addition & 1 deletion ansible/plugins/inventory/nodejs_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

# providers - validated for consistency
'provider': ('azure', 'digitalocean', 'joyent', 'ibm', 'linuxonecc',
'marist', 'mininodes', 'msft', 'osuosl', 'rackspace',
'macstadium', 'marist', 'mininodes', 'msft', 'osuosl', 'rackspace',
'requireio', 'scaleway', 'softlayer', 'voxer',
'packetnet', 'nearform')
}
Expand Down
1 change: 1 addition & 0 deletions ansible/roles/baselayout/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
#

- name: restart sshd
when: not os|startswith("macos")
service: name="{{ sshd_service_name }}" state=restarted
16 changes: 14 additions & 2 deletions ansible/roles/baselayout/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# also, some os:es complain about underscores in hostnames
- name: set hostname
when: not os|startswith("alpine") and not os|startswith("smartos")
and not os|startswith("zos")
and not os|startswith("zos") and not os|startswith("macos")
hostname: name="{{ inventory_hostname|replace('_', '-') }}"

- name: disable joyent smartconnect
Expand Down Expand Up @@ -51,7 +51,19 @@
register: has_git

- name: install packages
when: not os|startswith("zos")
when: not os|startswith("zos") and not os|startswith("macos")
package: name="{{ package }}" state=present
loop_control:
loop_var: package
with_items:
# ansible doesn't like empty lists
- "{{ packages[os]|default('[]') }}"
- "{{ packages[os|stripversion]|default('[]') }}"
- "{{ common_packages|default('[]') }}"

- name: install packages (macos)
when: os|startswith("macos")
become_user: administrator
package: name="{{ package }}" state=present
loop_control:
loop_var: package
Expand Down
27 changes: 21 additions & 6 deletions ansible/roles/baselayout/vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ common_packages: [
'automake',
'bash',
'libtool',
'sudo',
]

# you can either add os family or os to this list (see smartos)
Expand All @@ -46,40 +45,51 @@ packages: {
'm4',
'make',
'procps',
'xz'
'xz',
'sudo',
],

centos: [
'ccache',
'git',
'sudo',
],

centos7: [
'gcc-c++',
'sudo',
],

debian7: [
'gcc-4.8',
'g++-4.8',
'sudo',
],

debian8: [
'ccache',
'git',
'libfontconfig1',
'sudo',
],

fedora: [
'ccache',
'gcc-c++',
'git',
'fontconfig',
'sudo',
],

freebsd: [
'ccache',
'git',
'gmake'
'gmake',
'sudo',
],

macos: [
'python2',
],

smartos14: [
Expand All @@ -88,7 +98,8 @@ packages: {
'gccmakedep',
'git',
'gmake',
'xz'
'xz',
'sudo',
],

smartos15: [
Expand All @@ -97,7 +108,8 @@ packages: {
'gccmakedep',
'git',
'gmake',
'xz'
'xz',
'sudo',
],

smartos16: [
Expand All @@ -106,7 +118,8 @@ packages: {
'gccmakedep',
'git',
'gmake',
'xz'
'xz',
'sudo',
],

ubuntu: [
Expand All @@ -115,11 +128,13 @@ packages: {
'gcc',
'git',
'libfontconfig1',
'sudo',
],

ubuntu1404: [
'ntp',
'g++-4.9',
'gcc-4.9',
'sudo',
]
}
17 changes: 15 additions & 2 deletions ansible/roles/java-base/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,26 @@

# if this fails you want to check in vars/main.yml and add package name
# as appropriate -- try to use generic os family if available.

- name: Check if java is already installed
raw: java -version
register: java
ignore_errors: yes

- name: install java
when: not os|startswith("zos")
when: java.rc > 0 and not os|startswith("zos") and not os|startswith("macos")
package: name="{{ java_package_name }}" state=present

- name: install webupd8 oracle java 8 extras
when: os in ("ubuntu1204", "ubuntu1404")
when: java.rc > 0 and os in ("ubuntu1204", "ubuntu1404")
package: name="{{item}}" state=present
with_items:
- ca-certificates
- oracle-java8-set-default

- name: install java (macos)
become_user: administrator
when: java.rc > 0 and os|startswith("macos")
homebrew_cask:
name: java
state: present
24 changes: 20 additions & 4 deletions ansible/roles/jenkins-worker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
line: ::1 localhost.localdomain localhost

- name: create NODE_TEST_DIR directory
file: path=/home/{{ server_user }}/tmp state=directory
file: path="{{ home }}/{{ server_user }}/tmp" state=directory

- name: set NODE_TEST_DIR permission and owner
file:
path: /home/{{ server_user }}/tmp
path: "{{ home }}/{{ server_user }}/tmp"
owner: "{{ server_user }}"
group: "{{ server_user }}"
mode: 0755
Expand All @@ -53,7 +53,7 @@
mode: 0644
timeout: 60

# temporary until we get the righ cert bundles
# temporary until we get the right cert bundles
- name: download slave.jar -zos
when: os|startswith("zos")
get_url:
Expand Down Expand Up @@ -97,6 +97,14 @@
dest: "{{ jenkins.dest }}"
mode: "{{ jenkins.mode|default('0644') }}"

# TODO - Should this run on every machine?
- name: copy start.sh to {{ home }}/{{ server_user }}/start.sh
when: os|startswith("macos")
template:
src: "start.j2"
dest: "{{ home }}/{{ server_user }}/start.sh"
mode: "0755"

- name: import manifest to svcadm
when: os|startswith("smartos")
raw: "svccfg import {{ jenkins.dest }}"
Expand Down Expand Up @@ -140,9 +148,17 @@
command: "chown -R {{ server_user }} {{ home }}/{{ server_user }}/gyp"

- name: enable jenkins at startup - general
when: not os|startswith("zos")
when: not os|startswith("zos") and not os|startswith("macos")
service: name=jenkins state=started enabled=yes

- name: Load org.nodejs.osx.jenkins.plist into launchctl
when: os|startswith("macos")
command: launchctl load /Library/LaunchDaemons/org.nodejs.osx.jenkins.plist

- name: Start org.nodejs.osx.jenkins.plist
when: os|startswith("macos")
command: launchctl start org.nodejs.osx.jenkins

# lineinfile does not work on zos due to character conversions
# the inserted line ends up in the wrong character set. We
# tried a few variations to work around this without
Expand Down
10 changes: 10 additions & 0 deletions ansible/roles/jenkins-worker/tasks/partials/tap2junit/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---

#
# macos: python2.7
#

- name: install pip
pip:
name: tap2junit
executable: /usr/local/bin/pip2
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.nodejs.osx.jenkins</string>

<key>UserName</key>
<string>iojs</string>

<key>WorkingDirectory</key>
<string>/Users/iojs</string>

<key>Program</key>
<string>/Users/iojs/start.sh</string>

<key>RunAtLoad</key>
<true/>

<key>KeepAlive</key>
<true/>

<key>StandardErrorPath</key>
<string>/Users/iojs/jenkins_err.log</string>

<key>StandardOutPath</key>
<string>/Users/iojs/jenkins.log</string>
</dict>
</plist>
Loading

0 comments on commit af48068

Please sign in to comment.