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 cc1e899
Show file tree
Hide file tree
Showing 16 changed files with 224 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
```
3 changes: 3 additions & 0 deletions ansible/inventory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ 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.12-x64-1: {ip: 207.254.58.162, port: 5, 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)"
8 changes: 8 additions & 0 deletions ansible/partials/install-xcode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress;
PROD=$(softwareupdate -l |
grep "\*.*Command Line" |
head -n 1 | awk -F"*" '{print $2}' |
sed -e 's/^ *//' |
tr -d '\n')
softwareupdate -i "$PROD";
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
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>
33 changes: 9 additions & 24 deletions ansible/roles/jenkins-worker/templates/start.j2
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
#!/NODEJS2/bin/bash

su -s - iojs <<'EOF'
export PATH=/NODEJS/bin:$PATH
#!/bin/bash
export HOME={{ home }}/{{ server_user }}
export NODE_COMMON_PIPE="$HOME/test.pipe"
export NODE_TEST_DIR="$HOME/tmp"
export JOBS="{{ server_jobs | default(ansible_processor_vcpus) }}"
export OSTYPE=zos
export _BPXK_AUTOCVT=ON
export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt
export CC=/bin/xlc
export LINK=/bin/xlc
export CFLAGS="-q64"
export LDFLAGS="-q64"
{{ java_path[os] }} -Dfile.encoding=ISO8859_1 -Xmx{{ server_ram|default('128m') }} \
-jar {{ home }}/{{ server_user }}/slave.jar -secret {{ secret }} \
-jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp >{{ home }}/{{ server_user }}/jenkins.log 2>&1 &
EOF
export JOBS=2
export NODE_COMMON_PIPE=/Users/iojs/test.pipe
export OSTYPE=osx
export ARCH=x64
export DESTCPU=x64

java -jar {{ home }}/{{ server_user }}/slave.jar -secret {{ secret }} \
-jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp
26 changes: 26 additions & 0 deletions ansible/roles/jenkins-worker/templates/zos_start.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/NODEJS2/bin/bash

su -s - iojs <<'EOF'
export PATH=/NODEJS/bin:$PATH
export HOME={{ home }}/{{ server_user }}
export NODE_COMMON_PIPE="$HOME/test.pipe"
export NODE_TEST_DIR="$HOME/tmp"
export JOBS="{{ server_jobs | default(ansible_processor_vcpus) }}"
export OSTYPE=zos
export _BPXK_AUTOCVT=ON
export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)"
export _TAG_REDIR_ERR=txt
export _TAG_REDIR_IN=txt
export _TAG_REDIR_OUT=txt
export CC=/bin/xlc
export LINK=/bin/xlc
export CFLAGS="-q64"
export LDFLAGS="-q64"
{{ java_path[os] }} -Dfile.encoding=ISO8859_1 -Xmx{{ server_ram|default('128m') }} \
-jar {{ home }}/{{ server_user }}/slave.jar -secret {{ secret }} \
-jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp >{{ home }}/{{ server_user }}/jenkins.log 2>&1 &
EOF
Loading

0 comments on commit cc1e899

Please sign in to comment.