Skip to content

Commit f4054ba

Browse files
author
George Adams
committed
Initial macOS ansible scripts
1 parent 326ca9d commit f4054ba

File tree

17 files changed

+279
-42
lines changed

17 files changed

+279
-42
lines changed

ansible/MANUAL_STEPS.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Manual steps required to run ansible on machines
2+
3+
## macOS
4+
1. Update Sudoers file:
5+
6+
this requires `NOPASSWD` to be added to the sudoers file to enable elevation
7+
8+
`sudo visudo`
9+
and change:
10+
`%admin ALL = (ALL) ALL`
11+
to
12+
`%admin ALL = (ALL) NOPASSWD:ALL`
13+
14+
2. Allow ssh access
15+
16+
```bash
17+
sudo systemsetup -setremotelogin on
18+
```

ansible/inventory.yml

+13
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ hosts:
130130
ubuntu1604-arm64_odroid_c2-2: {ip: 70.167.220.148, user: odroid}
131131
ubuntu1604-arm64_odroid_c2-3: {ip: 70.167.220.149, user: odroid}
132132

133+
- macstadium:
134+
macos10.08-x64-1: {ip: 207.254.58.162, port: 10009, user: administrator}
135+
macos10.08-x64-2: {ip: 207.254.58.162, port: 10010, user: administrator}
136+
macos10.09-x64-1: {ip: 207.254.58.162, port: 10007, user: administrator}
137+
macos10.09-x64-2: {ip: 207.254.58.162, port: 10008, user: administrator}
138+
macos10.10-x64-1: {ip: 207.254.58.162, port: 10005, user: administrator}
139+
macos10.10-x64-2: {ip: 207.254.58.162, port: 10006, user: administrator}
140+
macos10.11-x64-1: {ip: 207.254.58.162, port: 10003, user: administrator}
141+
macos10.11-x64-2: {ip: 207.254.58.162, port: 10004, user: administrator}
142+
macos10.12-x64-1: {ip: 207.254.58.162, port: 10001, user: administrator}
143+
macos10.12-x64-2: {ip: 207.254.58.162, port: 10002, user: administrator}
144+
145+
133146
- osuosl:
134147
aix61-ppc64_be-1: {ip: 140.211.9.101}
135148
aix61-ppc64_be-2: {ip: 140.211.9.100}

ansible/partials/install-homebrew.sh

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
yes | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

ansible/partials/install-xcode.sh

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/bash
2+
osx_vers=$(sw_vers -productVersion | awk -F "." '{print $2}')
3+
cmd_line_tools_temp_file="/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress"
4+
5+
# Installing the latest Xcode command line tools on 10.9.x or higher
6+
7+
if [[ "$osx_vers" -ge 9 ]]; then
8+
touch "$cmd_line_tools_temp_file";
9+
PROD=$(softwareupdate -l |
10+
grep "\*.*Command Line" |
11+
head -n 1 | awk -F"*" '{print $2}' |
12+
sed -e 's/^ *//' |
13+
tr -d '\n')
14+
softwareupdate -i "$PROD";
15+
fi
16+
17+
# Installing the latest Xcode command line tools on 10.7.x and 10.8.x
18+
19+
# on 10.7/10.8, instead of using the software update feed, the command line tools are downloaded
20+
# instead from public download URLs, which can be found in the dvtdownloadableindex:
21+
# https://devimages.apple.com.edgekey.net/downloads/xcode/simulators/index-3905972D-B609-49CE-8D06-51ADC78E07BC.dvtdownloadableindex
22+
23+
if [[ "$osx_vers" -eq 7 ]] || [[ "$osx_vers" -eq 8 ]]; then
24+
25+
if [[ "$osx_vers" -eq 7 ]]; then
26+
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_xcode_os_x_lion_april_2013.dmg
27+
fi
28+
29+
if [[ "$osx_vers" -eq 8 ]]; then
30+
DMGURL=http://devimages.apple.com/downloads/xcode/command_line_tools_for_osx_mountain_lion_april_2014.dmg
31+
fi
32+
33+
TOOLS=cltools.dmg
34+
curl "$DMGURL" -o "$TOOLS"
35+
TMPMOUNT=`/usr/bin/mktemp -d /tmp/clitools.XXXX`
36+
hdiutil attach "$TOOLS" -mountpoint "$TMPMOUNT" -nobrowse
37+
# The "-allowUntrusted" flag has been added to the installer
38+
# command to accomodate for now-expired certificates used
39+
# to sign the downloaded command line tools.
40+
installer -allowUntrusted -pkg "$(find $TMPMOUNT -name '*.mpkg')" -target /
41+
hdiutil detach "$TMPMOUNT"
42+
rm -rf "$TMPMOUNT"
43+
rm "$TOOLS"
44+
fi

ansible/plugins/inventory/nodejs_yaml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
# providers - validated for consistency
4949
'provider': ('azure', 'digitalocean', 'joyent', 'ibm', 'linuxonecc',
50-
'marist', 'mininodes', 'msft', 'osuosl', 'rackspace',
50+
'macstadium', 'marist', 'mininodes', 'msft', 'osuosl', 'rackspace',
5151
'requireio', 'scaleway', 'softlayer', 'voxer',
5252
'packetnet', 'nearform')
5353
}

ansible/roles/baselayout/handlers/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@
55
#
66

77
- name: restart sshd
8+
when: not os|startswith("macos")
89
service: name="{{ sshd_service_name }}" state=restarted

ansible/roles/baselayout/tasks/main.yml

+14-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# also, some os:es complain about underscores in hostnames
1414
- name: set hostname
1515
when: not os|startswith("alpine") and not os|startswith("smartos")
16-
and not os|startswith("zos")
16+
and not os|startswith("zos") and not os|startswith("macos")
1717
hostname: name="{{ inventory_hostname|replace('_', '-') }}"
1818

1919
- name: disable joyent smartconnect
@@ -51,7 +51,19 @@
5151
register: has_git
5252

5353
- name: install packages
54-
when: not os|startswith("zos")
54+
when: not os|startswith("zos") and not os|startswith("macos")
55+
package: name="{{ package }}" state=present
56+
loop_control:
57+
loop_var: package
58+
with_items:
59+
# ansible doesn't like empty lists
60+
- "{{ packages[os]|default('[]') }}"
61+
- "{{ packages[os|stripversion]|default('[]') }}"
62+
- "{{ common_packages|default('[]') }}"
63+
64+
- name: install packages (macos)
65+
when: os|startswith("macos")
66+
become_user: administrator
5567
package: name="{{ package }}" state=present
5668
loop_control:
5769
loop_var: package

ansible/roles/baselayout/vars/main.yml

+21-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ common_packages: [
3030
'automake',
3131
'bash',
3232
'libtool',
33-
'sudo',
3433
]
3534

3635
# you can either add os family or os to this list (see smartos)
@@ -46,40 +45,52 @@ packages: {
4645
'm4',
4746
'make',
4847
'procps',
49-
'xz'
48+
'xz',
49+
'sudo',
5050
],
5151

5252
centos: [
5353
'ccache',
5454
'git',
55+
'sudo',
5556
],
5657

5758
centos7: [
5859
'gcc-c++',
60+
'sudo',
5961
],
6062

6163
debian7: [
6264
'gcc-4.8',
6365
'g++-4.8',
66+
'sudo',
6467
],
6568

6669
debian8: [
6770
'ccache',
6871
'git',
6972
'libfontconfig1',
73+
'sudo',
7074
],
7175

7276
fedora: [
7377
'ccache',
7478
'gcc-c++',
7579
'git',
7680
'fontconfig',
81+
'sudo',
7782
],
7883

7984
freebsd: [
8085
'ccache',
8186
'git',
82-
'gmake'
87+
'gmake',
88+
'sudo',
89+
],
90+
91+
macos: [
92+
'curl',
93+
'python2',
8394
],
8495

8596
smartos14: [
@@ -88,7 +99,8 @@ packages: {
8899
'gccmakedep',
89100
'git',
90101
'gmake',
91-
'xz'
102+
'xz',
103+
'sudo',
92104
],
93105

94106
smartos15: [
@@ -97,7 +109,8 @@ packages: {
97109
'gccmakedep',
98110
'git',
99111
'gmake',
100-
'xz'
112+
'xz',
113+
'sudo',
101114
],
102115

103116
smartos16: [
@@ -106,7 +119,8 @@ packages: {
106119
'gccmakedep',
107120
'git',
108121
'gmake',
109-
'xz'
122+
'xz',
123+
'sudo',
110124
],
111125

112126
ubuntu: [
@@ -115,6 +129,7 @@ packages: {
115129
'gcc',
116130
'git',
117131
'libfontconfig1',
132+
'sudo',
118133
],
119134

120135
ubuntu1404: [

ansible/roles/java-base/tasks/main.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,26 @@
2929

3030
# if this fails you want to check in vars/main.yml and add package name
3131
# as appropriate -- try to use generic os family if available.
32+
33+
- name: Check if java is already installed
34+
raw: java -version
35+
register: java
36+
ignore_errors: yes
37+
3238
- name: install java
33-
when: not os|startswith("zos")
39+
when: java.rc > 0 and not os|startswith("zos") and not os|startswith("macos")
3440
package: name="{{ java_package_name }}" state=present
3541

3642
- name: install webupd8 oracle java 8 extras
37-
when: os in ("ubuntu1204", "ubuntu1404")
43+
when: java.rc > 0 and os in ("ubuntu1204", "ubuntu1404")
3844
package: name="{{item}}" state=present
3945
with_items:
4046
- ca-certificates
4147
- oracle-java8-set-default
48+
49+
- name: install java (macos)
50+
become_user: administrator
51+
when: java.rc > 0 and os|startswith("macos")
52+
homebrew_cask:
53+
name: java
54+
state: present

ansible/roles/jenkins-worker/tasks/main.yml

+20-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
line: ::1 localhost.localdomain localhost
2424

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

2828
- name: set NODE_TEST_DIR permission and owner
2929
file:
30-
path: /home/{{ server_user }}/tmp
30+
path: "{{ home }}/{{ server_user }}/tmp"
3131
owner: "{{ server_user }}"
3232
group: "{{ server_user }}"
3333
mode: 0755
@@ -53,7 +53,7 @@
5353
mode: 0644
5454
timeout: 60
5555

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

100+
# TODO - Should this run on every machine?
101+
- name: copy start.sh to {{ home }}/{{ server_user }}/start.sh
102+
when: os|startswith("macos")
103+
template:
104+
src: "start.j2"
105+
dest: "{{ home }}/{{ server_user }}/start.sh"
106+
mode: "0755"
107+
100108
- name: import manifest to svcadm
101109
when: os|startswith("smartos")
102110
raw: "svccfg import {{ jenkins.dest }}"
@@ -140,9 +148,17 @@
140148
command: "chown -R {{ server_user }} {{ home }}/{{ server_user }}/gyp"
141149

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

154+
- name: Load org.nodejs.osx.jenkins.plist into launchctl
155+
when: os|startswith("macos")
156+
command: launchctl load /Library/LaunchDaemons/org.nodejs.osx.jenkins.plist
157+
158+
- name: Start org.nodejs.osx.jenkins.plist
159+
when: os|startswith("macos")
160+
command: launchctl start org.nodejs.osx.jenkins
161+
146162
# lineinfile does not work on zos due to character conversions
147163
# the inserted line ends up in the wrong character set. We
148164
# tried a few variations to work around this without
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
3+
#
4+
# macos: python2.7
5+
#
6+
7+
- name: install pip
8+
pip:
9+
name: tap2junit
10+
executable: /usr/local/bin/pip2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Label</key>
6+
<string>org.nodejs.osx.jenkins</string>
7+
8+
<key>UserName</key>
9+
<string>iojs</string>
10+
11+
<key>WorkingDirectory</key>
12+
<string>/Users/iojs</string>
13+
14+
<key>Program</key>
15+
<string>/Users/iojs/start.sh</string>
16+
17+
<key>RunAtLoad</key>
18+
<true/>
19+
20+
<key>KeepAlive</key>
21+
<true/>
22+
23+
<key>StandardErrorPath</key>
24+
<string>/Users/iojs/jenkins_err.log</string>
25+
26+
<key>StandardOutPath</key>
27+
<string>/Users/iojs/jenkins.log</string>
28+
</dict>
29+
</plist>
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
#!/NODEJS2/bin/bash
2-
3-
su -s - iojs <<'EOF'
4-
5-
export PATH=/NODEJS/bin:$PATH
1+
#!/bin/bash
62
export HOME={{ home }}/{{ server_user }}
7-
export NODE_COMMON_PIPE="$HOME/test.pipe"
83
export NODE_TEST_DIR="$HOME/tmp"
9-
export JOBS="{{ server_jobs | default(ansible_processor_vcpus) }}"
10-
export OSTYPE=zos
11-
12-
export _BPXK_AUTOCVT=ON
13-
export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
14-
export _TAG_REDIR_ERR=txt
15-
export _TAG_REDIR_IN=txt
16-
export _TAG_REDIR_OUT=txt
17-
18-
export CC=/bin/xlc
19-
export LINK=/bin/xlc
20-
export CFLAGS="-q64"
21-
export LDFLAGS="-q64"
22-
23-
{{ java_path[os] }} -Dfile.encoding=ISO8859_1 -Xmx{{ server_ram|default('128m') }} \
24-
-jar {{ home }}/{{ server_user }}/slave.jar -secret {{ secret }} \
25-
-jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp >{{ home }}/{{ server_user }}/jenkins.log 2>&1 &
26-
EOF
4+
export JOBS=2
5+
export NODE_COMMON_PIPE=/Users/iojs/test.pipe
6+
export OSTYPE=osx
7+
export ARCH=x64
8+
export DESTCPU=x64
9+
10+
java -jar {{ home }}/{{ server_user }}/slave.jar -secret {{ secret }} \
11+
-jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp

0 commit comments

Comments
 (0)