Skip to content

Commit 5f40cd3

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

File tree

15 files changed

+206
-42
lines changed

15 files changed

+206
-42
lines changed

ansible/inventory.yml

+3
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ 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.12-x64-1: {ip: 207.254.58.162, port: 5, user: administrator}
135+
133136
- osuosl:
134137
aix61-ppc64_be-1: {ip: 140.211.9.101}
135138
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

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
3+
PROD=$(softwareupdate -l |
4+
grep "\*.*Command Line" |
5+
head -n 1 | awk -F"*" '{print $2}' |
6+
sed -e 's/^ *//' |
7+
tr -d '\n')
8+
softwareupdate -i "$PROD";

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/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,51 @@ 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+
'python2',
8393
],
8494

8595
smartos14: [
@@ -88,7 +98,8 @@ packages: {
8898
'gccmakedep',
8999
'git',
90100
'gmake',
91-
'xz'
101+
'xz',
102+
'sudo',
92103
],
93104

94105
smartos15: [
@@ -97,7 +108,8 @@ packages: {
97108
'gccmakedep',
98109
'git',
99110
'gmake',
100-
'xz'
111+
'xz',
112+
'sudo',
101113
],
102114

103115
smartos16: [
@@ -106,7 +118,8 @@ packages: {
106118
'gccmakedep',
107119
'git',
108120
'gmake',
109-
'xz'
121+
'xz',
122+
'sudo',
110123
],
111124

112125
ubuntu: [
@@ -115,11 +128,13 @@ packages: {
115128
'gcc',
116129
'git',
117130
'libfontconfig1',
131+
'sudo',
118132
],
119133

120134
ubuntu1404: [
121135
'ntp',
122136
'g++-4.9',
123137
'gcc-4.9',
138+
'sudo',
124139
]
125140
}

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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/NODEJS2/bin/bash
2+
3+
su -s - iojs <<'EOF'
4+
5+
export PATH=/NODEJS/bin:$PATH
6+
export HOME={{ home }}/{{ server_user }}
7+
export NODE_COMMON_PIPE="$HOME/test.pipe"
8+
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

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ init: {
88
centos: ['centos5', 'centos6','centos7'],
99
debian: ['debian7', 'ubuntu1204'],
1010
freebsd: 'freebsd',
11+
macos: 'macos',
1112
openrc: 'alpine',
1213
systemd: ['centos7', 'debian8', 'fedora', 'ubuntu1604',
1314
'ubuntu1610'],
1415
svc: 'smartos',
1516
upstart: ['ubuntu12', 'ubuntu1404'],
16-
start: 'zos'
17+
zos_start: 'zos'
1718
}
1819

1920
jenkins_init: {
@@ -32,6 +33,11 @@ jenkins_init: {
3233
src: 'freebsd.initd.j2',
3334
mode: '0755'
3435
},
36+
macos: {
37+
dest: '/Library/LaunchDaemons/org.nodejs.osx.jenkins.plist',
38+
src: 'org.nodejs.osx.jenkins.plist',
39+
mode: '0755'
40+
},
3541
openrc: {
3642
dest: '/etc/init.d/jenkins',
3743
src: 'openrc.initd.j2',
@@ -49,9 +55,9 @@ jenkins_init: {
4955
dest: '/etc/init/jenkins.conf',
5056
src: 'upstart.j2'
5157
},
52-
start: {
58+
zos_start: {
5359
dest: '{{ home }}/{{ server_user }}/start.sh',
54-
src: 'start.j2'
60+
src: 'zos_start.j2'
5561
},
5662
}
5763

0 commit comments

Comments
 (0)