diff --git a/ansible/inventory.yml b/ansible/inventory.yml index 6df4e5830..509ec19bf 100644 --- a/ansible/inventory.yml +++ b/ansible/inventory.yml @@ -53,7 +53,7 @@ hosts: - softlayer: centos5-x86-1: {ip: 50.23.85.253} - centos6-x64-1: {ip: 50.97.245.10} + centos6-x64-1: {ip: 169.62.77.228} - linuxonecc: rhel72-s390x-1: {ip: 148.100.110.65} diff --git a/ansible/roles/baselayout/files/centos-aarch-sclo.repo b/ansible/roles/baselayout/files/centos-aarch-sclo.repo new file mode 100644 index 000000000..2acb67765 --- /dev/null +++ b/ansible/roles/baselayout/files/centos-aarch-sclo.repo @@ -0,0 +1,5 @@ +[sclo-aarch64] +name=CentOS-$releasever - AArch64 SCLo +baseurl=http://mirror.centos.org/altarch/$releasever/sclo/aarch64/rh/ +gpgcheck=1 +gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo diff --git a/ansible/roles/baselayout/tasks/main.yml b/ansible/roles/baselayout/tasks/main.yml index 1f761d5d6..b3865b040 100644 --- a/ansible/roles/baselayout/tasks/main.yml +++ b/ansible/roles/baselayout/tasks/main.yml @@ -53,6 +53,12 @@ stat: path="{{ binary_dest }}" register: has_git +- name: centos | remove existing git package + when: "(os == 'centos6' or os == 'centos7') and arch != 'arm64'" + yum: + name: "git" + state: absent + - name: install packages when: not os|startswith("zos") package: name="{{ package }}" state=present @@ -60,6 +66,7 @@ loop_var: package with_items: # ansible doesn't like empty lists + - "{{ packages[os+'_'+arch]|default('[]') }}" - "{{ packages[os]|default('[]') }}" - "{{ packages[os|stripversion]|default('[]') }}" - "{{ common_packages|default('[]') }}" @@ -73,6 +80,13 @@ - gcc - g++ +- name: centos6 | install devtoolset-2 + when: "os == 'centos6'" + yum: + disable_gpg_check: true + name: "devtoolset-2-gcc,devtoolset-2-gcc-c++" + state: present + - name: remove fortune from login shells when: os|stripversion == 'freebsd' lineinfile: diff --git a/ansible/roles/baselayout/tasks/partials/repo/centos6.yml b/ansible/roles/baselayout/tasks/partials/repo/centos6.yml index feac8043a..42d0109dd 100644 --- a/ansible/roles/baselayout/tasks/partials/repo/centos6.yml +++ b/ansible/roles/baselayout/tasks/partials/repo/centos6.yml @@ -1,22 +1,24 @@ --- -# -# centos6 - almost getting there -# - -- name: "repo : add scl devtoolset" - yum_repository: - baseurl: http://linuxsoft.cern.ch/cern/devtoolset/slc6-devtoolset.repo - gpgkey: http://ftp.scientificlinux.org/linux/scientific/5x/{{ ansible_architecture }}/RPM-GPG-KEYs/RPM-GPG-KEY-cern - gpgcheck: yes - -- name: "repo : add scl" - yum_repository: - baseurl: http://linuxsoft.cern.ch/cern/scl/slc6-scl.repo - gpgkey: http://ftp.scientificlinux.org/linux/scientific/5x/{{ ansible_architecture }}/RPM-GPG-KEYs/RPM-GPG-KEY-cern - gpgcheck: yes +- name: centos6 | install epel + yum: + name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" + state: present -- name: install epel +- name: centos6 | install ius yum: - name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm" + name: "https://centos{{ ansible_distribution_major_version }}.iuscommunity.org/ius-release.rpm" state: present + +- name: centos6 | install devtoolset-2 repo + get_url: + url: http://people.centos.org/tru/devtools-2/devtools-2.repo + dest: /etc/yum.repos.d/devtools-2.repo + mode: 0644 + +- name: centos6 | install devtoolset-6 for i686 + when: "arch == 'x86'" + get_url: + url: "https://copr.fedorainfracloud.org/coprs/mlampe/devtoolset-6.1/repo/epel-6/mlampe-devtoolset-6.1-epel-6.repo" + dest: "/etc/yum.repos.d/mlampe-devtoolset-6.1-epel-6.repo" + mode: 0644 diff --git a/ansible/roles/baselayout/tasks/partials/repo/centos7.yml b/ansible/roles/baselayout/tasks/partials/repo/centos7.yml index 08bfde35b..530477315 100644 --- a/ansible/roles/baselayout/tasks/partials/repo/centos7.yml +++ b/ansible/roles/baselayout/tasks/partials/repo/centos7.yml @@ -1,6 +1,26 @@ --- -- name: install epel +- name: centos7 | install epel yum: - name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm" + name: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm" state: present + +- name: centos7 | install ius + when: "arch != 'arm64'" + yum: + name: "https://centos{{ ansible_distribution_major_version }}.iuscommunity.org/ius-release.rpm" + state: present + +- name: centos7 | aarch64 | install sclo repo + when: "arch == 'arm64'" + copy: + src: "{{ role_path }}/files/centos-aarch-sclo.repo" + dest: "/etc/yum.repos.d/centos-aarch-sclo.repo" + mode: 0644 + +- name: centos7 | aarch64 | install sclo repo key + when: "arch == 'arm64'" + get_url: + url: "https://www.centos.org/keys/RPM-GPG-KEY-CentOS-SIG-SCLo" + dest: "/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo" + mode: 0644 diff --git a/ansible/roles/baselayout/vars/main.yml b/ansible/roles/baselayout/vars/main.yml index 03c289031..5d07d0d3e 100644 --- a/ansible/roles/baselayout/vars/main.yml +++ b/ansible/roles/baselayout/vars/main.yml @@ -27,19 +27,22 @@ ntp_service: { } common_packages: [ - 'automake', - 'bash', - 'libtool', - 'sudo', + 'automake,bash,libtool,sudo', ] # you can either add os family or os to this list (see smartos) # but the playbook chooses os over family - not both packages: { - centos: [ - 'ccache', - 'git', - 'gcc-c++', # even need this on centos6 so ccache has symlinks + centos6_x64: ['centos-release-scl'], # only available on x86_64, 32-bit is from https://copr.fedorainfracloud.org/coprs/mlampe + centos6: [ + 'ccache,git2u,gcc-c++,devtoolset-6', # even need gcc on centos6 so ccache has symlinks + ], + + centos7_arm64: ['git'], # git2u not available for aarch64 (yet) + centos7_x64: ['git2u','centos-release-scl'], # centos-release-scl is required to enable SCLo + # but we do it manually in partials/repo/centos7.yml for arm64 + centos7: [ + 'ccache,gcc-c++,devtoolset-6', ], debian7: [ @@ -55,17 +58,11 @@ packages: { ], fedora: [ - 'bzip2', - 'ccache', - 'gcc-c++', - 'git', - 'fontconfig', + 'bzip2,ccache,gcc-c++,git,fontconfig', ], freebsd: [ - 'ccache', - 'git', - 'gmake' + 'ccache,git,gmake' ], rhel72: [ @@ -73,30 +70,15 @@ packages: { ], smartos14: [ - 'gcc48', - 'gcc48-libs', - 'gccmakedep', - 'git', - 'gmake', - 'xz' + 'gcc48,gcc48-libs,gccmakedep,git,gmake,xz' ], smartos15: [ - 'gcc49', - 'gcc49-libs', - 'gccmakedep', - 'git', - 'gmake', - 'xz' + 'gcc49,gcc49-libs,gccmakedep,git,gmake,xz' ], smartos16: [ - 'gcc49', - 'gcc49-libs', - 'gccmakedep', - 'git', - 'gmake', - 'xz' + 'gcc49,gcc49-libs,gccmakedep,git,gmake,xz' ], ubuntu: [ diff --git a/ansible/roles/bootstrap/tasks/partials/centos6.yml b/ansible/roles/bootstrap/tasks/partials/centos6.yml new file mode 100644 index 000000000..6751c4bb7 --- /dev/null +++ b/ansible/roles/bootstrap/tasks/partials/centos6.yml @@ -0,0 +1,21 @@ +--- + +# +# a centos6 bootstrap - copied from fedora +# + +- name: check for python + raw: stat /usr/bin/python + register: has_python + failed_when: has_python.rc > 1 + +- name: check for libselinux-python bindings + raw: yum info libselinux-python | grep Installed + register: has_libselinux + failed_when: has_libselinux.rc > 1 + +- name: install libselinux-python bindings + raw: yum install -y libselinux-python + +- name: disable selinux + selinux: state=disabled diff --git a/ansible/roles/jenkins-worker/files/centos5.monitrc b/ansible/roles/jenkins-worker/files/centos.monitrc similarity index 100% rename from ansible/roles/jenkins-worker/files/centos5.monitrc rename to ansible/roles/jenkins-worker/files/centos.monitrc diff --git a/ansible/roles/jenkins-worker/tasks/main.yml b/ansible/roles/jenkins-worker/tasks/main.yml index 63cae53ec..7ea68b2e4 100644 --- a/ansible/roles/jenkins-worker/tasks/main.yml +++ b/ansible/roles/jenkins-worker/tasks/main.yml @@ -147,6 +147,13 @@ dest: "{{ jenkins.dest }}" mode: "{{ jenkins.mode|default('0644') }}" +- name: centos6 | render sysconfig into place + when: "os == 'centos6'" + template: + src: "{{ role_path }}/templates/centos6.sysconfig.j2" + dest: "/etc/sysconfig/jenkins" + mode: "0644" + - name: import manifest to svcadm when: os|startswith("smartos") raw: "svccfg import {{ jenkins.dest }}" diff --git a/ansible/roles/jenkins-worker/tasks/partials/tap2junit/centos6.yml b/ansible/roles/jenkins-worker/tasks/partials/tap2junit/centos6.yml index fbfc72f2a..734d330f3 100644 --- a/ansible/roles/jenkins-worker/tasks/partials/tap2junit/centos6.yml +++ b/ansible/roles/jenkins-worker/tasks/partials/tap2junit/centos6.yml @@ -13,5 +13,5 @@ - python-argparse - name: install tap2junit - raw: easy_install tap2junit + raw: easy_install --index-url https://pypi.python.org/pypi tap2junit diff --git a/ansible/roles/jenkins-worker/templates/centos.initd.j2 b/ansible/roles/jenkins-worker/templates/centos5.initd.j2 similarity index 92% rename from ansible/roles/jenkins-worker/templates/centos.initd.j2 rename to ansible/roles/jenkins-worker/templates/centos5.initd.j2 index f18b274d1..041c23f98 100644 --- a/ansible/roles/jenkins-worker/templates/centos.initd.j2 +++ b/ansible/roles/jenkins-worker/templates/centos5.initd.j2 @@ -17,7 +17,7 @@ PIDFILE=/var/run/jenkins/$NAME.pid JENKINS_SLAVE_USER="iojs" JENKINS_SLAVE_JAR="/home/{{ server_user }}/slave.jar" JENKINS_SLAVE_LOG="/home/{{ server_user }}/$NAME.log" -JENKINS_SLAVE_ARGS="-Xmx{{ server_ram|default('128m') }} -jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp -secret {{ secret }}" +JENKINS_SLAVE_ARGS="-jnlpUrl {{ jenkins_url }}/computer/{{ inventory_hostname }}/slave-agent.jnlp -secret {{ secret }}" JENKINS_ENV="JOBS={{ ansible_processor_vcpus }} \ HOME=/home/{{ server_user }} \ DESTCPU={{ ansible_architecture }} \ diff --git a/ansible/roles/jenkins-worker/templates/centos6.initd.j2 b/ansible/roles/jenkins-worker/templates/centos6.initd.j2 new file mode 100644 index 000000000..d5160483d --- /dev/null +++ b/ansible/roles/jenkins-worker/templates/centos6.initd.j2 @@ -0,0 +1,93 @@ +#!/bin/sh +# +# /etc/init.d/jenkins +# init script for a jenkins slave. +# +# chkconfig: 345 90 60 +# description: jenkins slave +# + +RETVAL=0 + +NAME=`basename "$0"` +JENKINS_CONFIG=/etc/sysconfig/$NAME +LOCK_FILE=/var/lock/$NAME +JAVA=/usr/bin/java +PIDFILE=/var/run/jenkins/$NAME.pid + +# Source function library. +. /etc/rc.d/init.d/functions + +# Read config +[ -f "$JENKINS_CONFIG" ] && . "$JENKINS_CONFIG" + +# Add scl-specific path as well as regular path. +# We add /usr/local/bin since that's where ccache symlinks live +JENKINS_PATH="/usr/local/bin:$JENKINS_PATH:$PATH" + +# Replace potentially double colons since they add cwd +JENKINS_PATH="${JENKINS_PATH//::/:}" + +slave_start() { + echo Starting $NAME... + + mkdir `dirname $PIDFILE` > /dev/null 2>&1 || true + chown $JENKINS_SLAVE_USER `dirname $PIDFILE` + + runuser -m -l $JENKINS_SLAVE_USER -c "$JENKINS_ENV PATH=$JENKINS_PATH $JAVA \ + -jar $JENKINS_SLAVE_JAR $JENKINS_SLAVE_ARGS > $JENKINS_SLAVE_LOG 2>&1 &" + pgrep -f -u $JENKINS_SLAVE_USER $JENKINS_SECRET > $PIDFILE + RETVAL=$? + [ $RETVAL -eq 0 ] && touch $LOCK_FILE +} + +slave_stop() { + echo Stopping $NAME... + pid=`cat $PIDFILE` + + killproc -p $PIDFILE + + # Wait until the monitor exits + while (checkpid $pid) + do + usleep 100000 + done + + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $LOCK_FILE +} + +slave_restart() { + echo Restarting $NAME... + slave_stop + slave_start + + RETVAL=$? + [ $RETVAL -eq 0 ] && touch $LOCK_FILE +} + +slave_status() { + status -p $PIDFILE $NAME + RETVAL=$? +} + +case "$1" in + start) + slave_start + ;; + stop) + slave_stop + ;; + restart) + slave_restart + ;; + status) + slave_status + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac + +exit $RETVAL diff --git a/ansible/roles/jenkins-worker/templates/centos6.sysconfig.j2 b/ansible/roles/jenkins-worker/templates/centos6.sysconfig.j2 new file mode 100644 index 000000000..85cfa1aee --- /dev/null +++ b/ansible/roles/jenkins-worker/templates/centos6.sysconfig.j2 @@ -0,0 +1,13 @@ +JENKINS_SLAVE_USER="iojs" +JENKINS_SLAVE_JAR="/home/iojs/slave.jar" +JENKINS_SLAVE_LOG="/home/iojs/$NAME.log" +JENKINS_SECRET="{{ secret }}" +JENKINS_SLAVE_ARGS="-jnlpUrl {{ jenkins_url }}/computer/{{ ansible_hostname }}/slave-agent.jnlp -secret $JENKINS_SECRET" +JENKINS_PATH="" +JENKINS_ENV="JOBS={{ jobs_env }} \ + HOME=/home/{{ server_user }} \ + NODE_TEST_DIR=$HOME/tmp \ + DESTCPU={{ server_arch | default(arch) }} \ + ARCH={{ server_arch | default(arch) }} \ + OSTYPE=linux-gnu \ + NODE_COMMON_PIPE=/home/iojs/test.pipe" diff --git a/ansible/roles/jenkins-worker/vars/main.yml b/ansible/roles/jenkins-worker/vars/main.yml index ef69a0f01..558989bf7 100644 --- a/ansible/roles/jenkins-worker/vars/main.yml +++ b/ansible/roles/jenkins-worker/vars/main.yml @@ -5,7 +5,8 @@ # init: { - centos: ['centos5', 'centos6','centos7'], + centos5: 'centos5', + centos6: 'centos6', debian: ['debian7', 'ubuntu1204'], freebsd: 'freebsd', rhel72: 'rhel72', @@ -16,9 +17,14 @@ init: { } jenkins_init: { - centos: { + centos5: { dest: '/etc/init.d/jenkins', - src: 'centos.initd.j2', + src: 'centos5.initd.j2', + mode: '0755' + }, + centos6: { + dest: '/etc/init.d/jenkins', + src: 'centos6.initd.j2', mode: '0755' }, debian: {