diff --git a/setup/freebsd/README.md b/setup/freebsd/README.md index 1ef37ac9c..097c2aba1 100644 --- a/setup/freebsd/README.md +++ b/setup/freebsd/README.md @@ -1,6 +1,12 @@ # io.js Build FreeBSD Setup -The current FreeBSD lives at Digitalocean. +The current FreeBSD VMs lives at Digitalocean. + +You have to install `python` before running ansible. Log in to the VM +and run the following: +``` +sudo pkg update && sudo pkg install -y python +``` To set up hosts, make sure you add them to your ssh config first: ``` @@ -13,14 +19,12 @@ Host test-digitalocean-freebsd10-x64-2 User freebsd ``` -Note that these hostnames are also used in the ansible-inventory file. The IP addresses will need to be updated each time the servers are reprovisioned. +Note that these hostnames are also used in the ansible-inventory file. +The IP addresses will need to be updated each time +the servers are reprovisioned. To set up a host, run: ```text $ ansible-playbook -i ../ansible-inventory ansible-playbook.yaml ``` - -**Users**: The ansible-vars.yaml file contains a list of users who's GitHub public keys are pulled and placed into -authorized_keys for both root and iojs users. This file should be updates when new users are added to the build project -who are able to help maintain the containerized builds. diff --git a/setup/freebsd/ansible-playbook.yaml b/setup/freebsd/ansible-playbook.yaml index a9c232239..d3ed903e7 100644 --- a/setup/freebsd/ansible-playbook.yaml +++ b/setup/freebsd/ansible-playbook.yaml @@ -1,4 +1,3 @@ ---- - hosts: iojs-freebsd10 remote_user: freebsd @@ -17,7 +16,7 @@ tags: general - name: General | Install required packages - command: pkg install -U -y {{ item }} + command: pkg install -U -y {{ item }} with_items: packages tags: general @@ -49,22 +48,36 @@ command: curl -sL https://ci.nodejs.org/jnlpJars/slave.jar -o /home/{{ server_user }}/slave.jar tags: jenkins - - name: Jenkins | Copy init script - copy: src=./resources/jenkins dest={{ init_script_path }} owner={{ server_user }} group={{ server_user }} mode=0755 - tags: jenkins - - - name: Jenkins | Copy secret into init script - replace: dest={{ init_script_path }} regexp="\{\{secret\}\}" replace="{{ server_secret }}" - tags: jenkins - - - name: Jenkins | Copy server id into init script - replace: dest={{ init_script_path }} regexp="\{\{id\}\}" replace="{{ server_id }}" - tags: jenkins - - - name: Jenkins | Enable init script at startup - lineinfile: dest=/etc/rc.conf line="jenkins_enable=YES" - tags: jenkins - - - name: Jenkins | Start service - command: service jenkins start - tags: jenkins + - name: Assures that {{ init_base }}/{rc.d, rc.conf.d} directories exists + file: path={{ init_base }}/{{ item }} state=directory + with_items: + - rc.d + - rc.conf.d + tags: init + + - name: Init | Copy init script + copy: src=./resources/jenkins dest={{ init_base }}/rc.d/jenkins owner={{ server_user }} group={{ server_user }} mode=0755 + tags: init + + - name: Init | Copy config template + copy: src=./resources/jenkins.conf dest={{ init_base }}/rc.conf.d/jenkins owner={{ server_user }} group={{ server_user }} mode=0600 + tags: init + + - name: Init | Copy secret to config` + replace: dest={{ init_base }}/rc.conf.d/jenkins regexp="\{\{secret\}\}" replace="{{ server_secret }}" + tags: init + + - name: Init | Copy user/group to config` + replace: dest={{ init_base }}/rc.conf.d/jenkins regexp="\{\{{{item}}\}\}" replace="{{ server_user }}" + with_items: + - user + - group + tags: init + + - name: Init | Copy id to config + replace: dest={{ init_base }}/rc.conf.d/jenkins regexp="\{\{id\}\}" replace="{{ inventory_hostname }}" + tags: init + + - name: Init | Add to boot and start service + service: name=jenkins state=started enabled=yes + tags: init diff --git a/setup/freebsd/ansible-vars.yaml b/setup/freebsd/ansible-vars.yaml index 0d2294fdd..c164f1b63 100644 --- a/setup/freebsd/ansible-vars.yaml +++ b/setup/freebsd/ansible-vars.yaml @@ -1,11 +1,12 @@ --- server_user: iojs -init_script_path: /usr/local/etc/rc.d/jenkins +init_base: /usr/local/etc/ ssh_users: - rvagg - jbergstroem + - joaocgreis packages: - - openjdk-jre + - openjdk - git - gmake - ccache diff --git a/setup/freebsd/resources/jenkins b/setup/freebsd/resources/jenkins index 7593559e1..841ab14d3 100644 --- a/setup/freebsd/resources/jenkins +++ b/setup/freebsd/resources/jenkins @@ -1,13 +1,9 @@ #!/bin/sh -# $FreeBSD: $ # -# Based on the jenkins init script -# -# PROVIDE: jenkins-iojs +# PROVIDE: jenkins # REQUIRE: LOGIN # KEYWORD: shutdown - # # Configuration settings for jenkins in /etc/rc.conf: # @@ -21,31 +17,32 @@ name="jenkins" rcvar=jenkins_enable -load_rc_config "${name}" - +load_rc_config ${name} -OSTYPE="freebsd" -NODE_COMMON_PIPE="/home/iojs/test.pipe" PATH="/usr/local/libexec/ccache:/usr/local/bin:${PATH}" +NODE_COMMON_PIPE="/home/iojs/test.pipe" -jenkins_jnlpurl="https://ci.nodejs.org/computer/{{id}}/slave-agent.jnlp" -jenkins_secret="{{secret}}" jenkins_jar="/home/iojs/slave.jar" -jenkins_log_file="/home/iojs/jenkins_console.log" -jenkins_args="-jnlpUrl ${jenkins_jnlpurl} -secret ${jenkins_secret}" -jenkins_user="iojs" -jenkins_group="iojs" +jenkins_log_file="/home/${jenkins_user}/${name}_console.log" +jenkins_args="-jar ${jenkins_jar} \ + -jnlpUrl ${jenkins_jnlpurl} \ + -secret ${jenkins_secret}" jenkins_jobs="$(getconf NPROCESSORS_ONLN)" -pidfile="/var/run/jenkins/jenkins.pid" +# FreeBSD uses a java wrapper. Without full path pid monitoring won't work +procname=`cat /usr/local/etc/javavms | cut -d "#" -f 1` +pidfile="/var/run/${name}/${name}.pid" +monitor_pidfile="/var/run/${name}/${name}_monitor.pid" command="/usr/sbin/daemon" -procname="/usr/local/openjdk7-jre/bin/java" -command_args="-r -p ${pidfile} ${procname} -jar ${jenkins_jar} ${jenkins_args} > ${jenkins_log_file} 2>&1" -env="PATH=${PATH} JOBS=${jenkins_jobs} OSTYPE=${OSTYPE} NODE_COMMON_PIPE=${NODE_COMMON_PIPE} CC=cc CXX=c++" +command_args="-r -p ${pidfile} -P ${monitor_pidfile} ${procname} \ + ${jenkins_args} > ${jenkins_log_file} 2>&1" +env="PATH=${PATH} JOBS=${jenkins_jobs} OSTYPE=${OSTYPE} \ + NODE_COMMON_PIPE=${NODE_COMMON_PIPE} CC=cc CXX=c++" required_files="${procname} ${jenkins_jar}" -start_precmd="jenkins_prestart" -start_cmd="jenkins_start" +start_precmd="${name}_prestart" +start_cmd="${name}_start" +stop_cmd="${name}_stop" jenkins_prestart() { if [ ! -f "${jenkins_log_file}" ]; then @@ -53,8 +50,9 @@ jenkins_prestart() { chown "${jenkins_user}:${jenkins_group}" "${jenkins_log_file}" chmod 640 "${jenkins_log_file}" fi - if [ ! -d "/var/run/jenkins" ]; then - install -d -o "${jenkins_user}" -g "${jenkins_group}" -m 750 "/var/run/jenkins" + if [ ! -d `basename ${pidfile}` ]; then + install -d -o "${jenkins_user}" -g "${jenkins_group}" \ + -m 750 `basename ${pidfile}` fi if [ ! $jenkins_secret ]; then @@ -64,8 +62,21 @@ jenkins_prestart() { jenkins_start() { - check_startmsgs && echo "Starting ${name}." + check_startmsgs && echo -n "Starting ${name}" su -l ${jenkins_user} -c "${env} exec ${command} ${command_args}" + echo . +} + +jenkins_stop() +{ + if [ ! -f ${pidfile} ]; then + echo "${name} isn't running." + else + echo -n "Stopping service: ${name}" + kill `cat ${monitor_pidfile}` + rm ${pidfile} ${monitor_pidfile} + echo . + fi } run_rc_command "$1" diff --git a/setup/freebsd/resources/jenkins.conf b/setup/freebsd/resources/jenkins.conf new file mode 100644 index 000000000..b79f203d9 --- /dev/null +++ b/setup/freebsd/resources/jenkins.conf @@ -0,0 +1,4 @@ +jenkins_jnlpurl="https://ci.nodejs.org/computer/{{id}}/slave-agent.jnlp" +jenkins_secret="{{secret}}" +jenkins_user="{{user}}" +jenkins_group="{{group}}"