Skip to content

Commit c96cd4e

Browse files
author
George Adams
committed
ansible: inital macOS playbook
1 parent 114b481 commit c96cd4e

File tree

17 files changed

+277
-28
lines changed

17 files changed

+277
-28
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/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

+28-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
- name: set hostname
1919
when: not os|startswith("smartos") and not os|startswith("zos")
20+
and not os|startswith("macos")
2021
hostname: name="{{ safe_hostname }}"
2122

2223
- name: disable joyent smartconnect
@@ -60,7 +61,19 @@
6061
state: absent
6162

6263
- name: install packages
63-
when: not os|startswith("zos")
64+
when: not os|startswith("zos") and not os|startswith("macos")
65+
package: name="{{ package }}" state=present
66+
loop_control:
67+
loop_var: package
68+
with_items:
69+
# ansible doesn't like empty lists
70+
- "{{ packages[os]|default('[]') }}"
71+
- "{{ packages[os|stripversion]|default('[]') }}"
72+
- "{{ common_packages|default('[]') }}"
73+
74+
- name: install packages (macos)
75+
when: os|startswith("macos")
76+
become_user: administrator
6477
package: name="{{ package }}" state=present
6578
loop_control:
6679
loop_var: package
@@ -71,6 +84,20 @@
7184
- "{{ packages[os|stripversion]|default('[]') }}"
7285
- "{{ common_packages|default('[]') }}"
7386

87+
- name: Check whether /etc/paths contains "/usr/localopt/ccache/libexec" (macos)
88+
when: os|startswith("macos")
89+
command: grep -Fxq "/usr/localopt/ccache/libexec" /etc/paths
90+
register: ccache_mac
91+
check_mode: no
92+
ignore_errors: yes
93+
changed_when: no
94+
95+
- name: add ccache to the path (macos)
96+
when: ccache_mac.rc == 1
97+
lineinfile: dest=/etc/paths
98+
insertbefore=BOF
99+
line='/usr/localopt/ccache/libexec'
100+
74101
- name: ubuntu1404 | update package alternatives
75102
when: os == "ubuntu1404"
76103
alternatives: link=/usr/bin/{{ gcc }} name={{ gcc }} path=/usr/bin/{{ gcc }}-4.9

ansible/roles/baselayout/vars/main.yml

+13-12
Original file line numberDiff line numberDiff line change
@@ -27,53 +27,54 @@ ntp_service: {
2727
}
2828

2929
common_packages: [
30-
'automake,bash,libtool,sudo',
30+
'automake,bash,libtool',
3131
]
3232

3333
# you can either add os family or os to this list (see smartos)
3434
# but the playbook chooses os over family - not both
3535
packages: {
3636
centos6_x64: ['centos-release-scl'], # only available on x86_64, 32-bit is from https://copr.fedorainfracloud.org/coprs/mlampe
3737
centos6: [
38-
'ccache,git2u,gcc-c++,devtoolset-6', # even need gcc on centos6 so ccache has symlinks
38+
'ccache,git2u,gcc-c++,devtoolset-6,sudo', # even need gcc on centos6 so ccache has symlinks
3939
],
4040

4141
centos7_arm64: ['git'], # git2u not available for aarch64 (yet)
42-
centos7_x64: ['git2u','centos-release-scl'], # centos-release-scl is required to enable SCLo
42+
centos7_x64: ['git2u','centos-release-scl',], # centos-release-scl is required to enable SCLo
4343
# but we do it manually in partials/repo/centos7.yml for arm64
4444
centos7: [
45-
'ccache,gcc-c++,devtoolset-6',
45+
'ccache,gcc-c++,devtoolset-6,sudo',
4646
],
4747

4848
debian7: [
49-
'gcc-4.8,g++-4.8',
49+
'gcc-4.8,g++-4.8,sudo',
5050
],
5151

5252
debian8: [
53-
'ccache,git,gcc-4.9,g++-4.9,libfontconfig1,binutils-2.26',
53+
'ccache,git,gcc-4.9,g++-4.9,libfontconfig1,binutils-2.26,sudo',
5454
],
5555

5656
debian9: [
57-
'gcc-6,g++-6,ccache,git,curl,libfontconfig1,apt-transport-https,ca-certificates',
57+
'gcc-6,g++-6,ccache,git,curl,libfontconfig1,apt-transport-https,ca-certificates,sudo',
5858
],
5959

6060
fedora: [
61-
'bzip2,ccache,gcc-c++,git,fontconfig',
61+
'bzip2,ccache,gcc-c++,git,fontconfig,sudo',
6262
],
6363

6464
freebsd: [
65-
'ccache,git,gmake'
65+
'ccache,git,gmake,sudo'
6666
],
6767

6868
rhel72: [
69-
'gcc-c++',
69+
'gcc-c++,sudo',
7070
],
7171

7272
smartos: [
7373
'gccmakedep',
7474
'git',
7575
'gmake',
76-
'xz'
76+
'xz',
77+
'sudo',
7778
],
7879

7980
smartos14: [
@@ -96,7 +97,7 @@ packages: {
9697
],
9798

9899
ubuntu: [
99-
'ccache,g++,gcc,git,libfontconfig1',
100+
'ccache,g++,gcc,git,libfontconfig1,sudo',
100101
],
101102

102103
ubuntu1404: [

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

+8-2
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,18 @@
4848

4949
# if this fails you want to check in vars/main.yml and add package name
5050
# as appropriate -- try to use generic os family if available.
51+
52+
- name: Check if java is already installed
53+
raw: java -version
54+
register: java
55+
ignore_errors: yes
56+
5157
- name: install java
52-
when: not os|startswith("zos") and arch != "ppc64" and not inventory_hostname|regex_search('-arm(v6l|v7l|64)_pi')
58+
when: java.rc > 0 and not os|startswith("zos") and arch != "ppc64" and not inventory_hostname|regex_search('-arm(v6l|v7l|64)_pi')
5359
package: name="{{ java_package_name }}" state=present
5460

5561
- name: install webupd8 oracle java 8 extras
56-
when: os in ("ubuntu1204", "ubuntu1404") and arch != "ppc64"
62+
when: java.rc > 0 and os in ("ubuntu1204", "ubuntu1404") and arch != "ppc64"
5763
package: name="{{item}}" state=present
5864
with_items:
5965
- ca-certificates

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

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ packages: {
1212
'debian9': 'openjdk-8-jre-headless',
1313
'fedora': 'java-1.8.0-openjdk-headless',
1414
'freebsd': 'openjdk8-jre',
15+
'macos': 'adoptopenjdk-openjdk8'
1516
'rhel72': 'java-1.8.0-openjdk',
1617
'smartos': 'openjdk8',
1718
'ubuntu': 'openjdk-8-jre-headless',

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

+20-4
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@
6767
line: ::1 localhost.localdomain localhost
6868

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

7272
- name: set NODE_TEST_DIR permission and owner
7373
file:
74-
path: /home/{{ server_user }}/tmp
74+
path: "{{ home }}/{{ server_user }}/tmp"
7575
owner: "{{ server_user }}"
7676
group: "{{ server_user }}"
7777
mode: 0755
@@ -124,7 +124,7 @@
124124
timeout: 60
125125
force: yes
126126

127-
# temporary until we get the righ cert bundles
127+
# temporary until we get the right cert bundles
128128
- name: download slave.jar -zos
129129
when: os|startswith("zos")
130130
get_url:
@@ -176,6 +176,14 @@
176176
dest: "/etc/sysconfig/jenkins"
177177
mode: "0644"
178178

179+
# TODO - Should this run on every machine?
180+
- name: copy start.sh to {{ home }}/{{ server_user }}/start.sh
181+
when: os|startswith("macos")
182+
template:
183+
src: "start.j2"
184+
dest: "{{ home }}/{{ server_user }}/start.sh"
185+
mode: "0755"
186+
179187
- name: import manifest to svcadm
180188
when: os|startswith("smartos")
181189
raw: "svccfg import {{ jenkins.dest }}"
@@ -219,9 +227,17 @@
219227
command: "chown -R {{ server_user }} {{ home }}/{{ server_user }}/gyp"
220228

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

233+
- name: Load org.nodejs.osx.jenkins.plist into launchctl
234+
when: os|startswith("macos")
235+
command: launchctl load /Library/LaunchDaemons/org.nodejs.osx.jenkins.plist
236+
237+
- name: Start org.nodejs.osx.jenkins.plist
238+
when: os|startswith("macos")
239+
command: launchctl start org.nodejs.osx.jenkins
240+
225241
# lineinfile does not work on zos due to character conversions
226242
# the inserted line ends up in the wrong character set. We
227243
# 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>

ansible/roles/jenkins-worker/templates/start.j2

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
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"
94
export JOBS="{{ jobs_env }}"
105
export OSTYPE=zos
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
@@ -9,11 +9,12 @@ init: {
99
centos6: 'centos6',
1010
debian: ['debian7', 'ubuntu1204'],
1111
freebsd: 'freebsd',
12+
macos: 'macos',
1213
rhel72: 'rhel72',
1314
systemd: ['centos7', 'debian8', 'debian9', 'fedora', 'ubuntu1604', 'ubuntu1610', 'ubuntu1710'],
1415
svc: 'smartos',
1516
upstart: ['ubuntu12', 'ubuntu1404'],
16-
start: 'zos'
17+
zos_start: 'zos'
1718
}
1819

1920
jenkins_init: {
@@ -37,6 +38,11 @@ jenkins_init: {
3738
src: 'freebsd.initd.j2',
3839
mode: '0755'
3940
},
41+
macos: {
42+
dest: '/Library/LaunchDaemons/org.nodejs.osx.jenkins.plist',
43+
src: 'org.nodejs.osx.jenkins.plist',
44+
mode: '0755'
45+
},
4046
openrc: {
4147
dest: '/etc/init.d/jenkins',
4248
src: 'openrc.initd.j2',
@@ -59,9 +65,9 @@ jenkins_init: {
5965
dest: '/etc/init/jenkins.conf',
6066
src: 'upstart.j2'
6167
},
62-
start: {
68+
zos_start: {
6369
dest: '{{ home }}/{{ server_user }}/start.sh',
64-
src: 'start.j2'
70+
src: 'zos_start.j2'
6571
},
6672
}
6773

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2+
<plist version="1.0">
3+
<dict>
4+
<key>Label</key>
5+
<string>sysctl</string>
6+
<key>ProgramArguments</key>
7+
<array>
8+
<string>/usr/sbin/sysctl</string>
9+
<string>-w</string>
10+
<string>kern.corefile=core.%P</string>
11+
</array>
12+
<key>RunAtLoad</key>
13+
<true/>
14+
</dict>
15+
</plist>
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)"

0 commit comments

Comments
 (0)