Commit 05dc40b2 by Will Daly

Simplified env variable setting

Removed dependency on rbenv and common roles
Fixed permission issue with python .egg cache
parent 65f07b98
......@@ -7,8 +7,4 @@
sudo: True
gather_facts: True
roles:
- role: rbenv
rbenv_user: "{{ jenkins_user }}"
rbenv_user_home: "{{ jenkins_user_home }}"
rbenv_ruby_version: "{{ jenkins_ruby_version }}"
- jenkins_worker
......@@ -36,6 +36,11 @@ if [ -e $VENV/bin/activate ]; then
echo "$VENV already exists; skipping installation..."
else
# Create python egg cache and set correct permissions
PYTHON_EGG_CACHE=$HOME/.python-eggs
mkdir -p $PYTHON_EGG_CACHE
chmod 600 $PYTHON_EGG_CACHE
# Create and activate the virtualenv
echo "No virtualenv found; creating it..."
mkdir -p $VENV
......
......@@ -16,13 +16,3 @@
- name: JSCover | Set JSCover permissions
file: path="/usr/local/bin/JSCover-all.jar" state=file
owner=root group=root mode=0755
- name: JSCover | Configure environment variables
template: src=jscover.sh.j2 dest=/etc/profile.d/jscover.sh
owner=root group=root mode=0755
- name: JSCover | Configure bash to load env variables
lineinfile:
dest="{{ jenkins_user_home }}/.bashrc"
regexp='. /etc/profile.d/jscover.sh'
line='. /etc/profile.d/jscover.sh'
......@@ -7,10 +7,11 @@
# `jenkins_user`: jenkins
# `jenkins_home`: /var/lib/jenkins
# `jenkins_user_home`: /home/jenkins
# `jenkins_debian_pkgs`: List of Jenkins-specific Debian packages to install
- include: system.yml
- include: python.yml
- include: ruby.yml
- include: mongo.yml
- include: xvfb.yml
- include: browsers.yml
- include: jscover.yml
- include: secure_home.yml
---
# Configure Mongo to use /mnt so we don't
# run out of disk space
- name: jenkins | Stop mongo service
service: name=mongodb state=stopped
- name: jenkins | Configure Mongo
template: src=mongodb_conf.j2
dest=/etc/mongodb.conf
owner=root
group=root
- name: jenkins | Configure Mongo upstart script
template: src=mongodb_upstart.j2
dest=/etc/init/mongodb.conf
owner=root
group=root
- name: jenkins | Start the mongo service
service: name=mongodb state=stopped
---
- name: jenkins | Install virtualenv
pip: name=virtualenv state=present
- name: jenkins | Install virtualenv wrapper
pip: name=virtualenvwrapper state=present
# Install bash scripts
- name: jenkins | Install Python packages scripts
copy: src="${item}" dest="/usr/local/bin/${item}"
force=yes
owner=root group=root
mode=755
with_items:
- download_python_pkgs.sh
- install_python_pkgs.sh
# Install upstart script to download Python packages from S3
- name: jenkins | Install Python packages upstart script
template: src="python_pkgs.conf.j2" dest="/etc/init/python_pkgs.conf"
---
- name: jenkins | Install rbenv
git: repo=https://github.com/sstephenson/rbenv.git
dest={{ rbenv_root }}
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Install ruby-build
git: repo=https://github.com/sstephenson/ruby-build.git
dest={{ rbenv_root }}/plugins/ruby-build
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Install ruby
command: "{{ rbenv_root }}/bin/rbenv install {{ ruby_version }}
creates={{ rbenv_root }}/versions/{{ ruby_version }}"
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Set global ruby
command: "{{ rbenv_root }}/bin/rbenv global {{ ruby_version }}"
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Install bundler
command: "{{ rbenv_root }}/shims/gem install bundler"
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Rbenv rehash
command: "{{ rbenv_root }}/bin/rbenv rehash"
sudo_user: "{{ jenkins_user }}"
---
# Ensure that code executed by the worker can't be
# installed to execute on login.
- name: Set permissions on .bash_profile
file: path="{{ jenkins_user_home }}/.bash_profile" state=file
owner="{{ jenkins_user }}" group="{{ jenkins_group }}"
mode=0500
- name: Set permissions on .bashrc
file: path="{{ jenkins_user_home }}/.bashrc" state=file
owner="{{ jenkins_user }}" group="{{ jenkins_group }}"
mode=0500
- name: Set permissions on rbenv config
file: path="{{ jenkins_user_home }}/ruby_env" state=file
owner="{{ jenkins_user }}" group="{{ jenkins_group }}"
mode=0500
ignore_errors: yes
......@@ -5,10 +5,6 @@
- name: jenkins | Add the jenkins user to the group
user: name={{ jenkins_user }} append=yes group={{ jenkins_group }}
- name: jenkins | ensure .bashrc exists
shell: touch {{ jenkins_user_home }}/.bashrc
sudo_user: "{{ jenkins_user }}"
# We need the upstart script to create the build directory
# so that (a) it will be run when a new instance is created
......@@ -35,7 +31,7 @@
owner={{ jenkins_user }} group={{ jenkins_group }}
mode=400
- name: jenkins | Install jenkins-specific system packages
- name: jenkins | Install system packages
apt: pkg=${item} update_cache=yes state=present
with_items:
- ack-grep
......@@ -54,41 +50,38 @@
- mongodb
- npm
- pkg-config
- python2.7
- python-pip
- python2.7-dev
- unzip
- xml-twig-tools
- name: jenkins | Configure environment variables
template: src=jenkins_env.sh.j2 dest=/usr/local/bin/jenkins_env.sh
owner=root group=root mode=0555
# Configure Mongo to use /mnt so we don't
# run out of disk space
- name: jenkins | Stop mongo service
service: name=mongodb state=stopped
- name: jenkins | Configure Mongo
template: src=mongodb_conf.j2
dest=/etc/mongodb.conf
owner=root
group=root
- name: jenkins | ensure .bash_profile exists
shell: touch {{ jenkins_user_home }}/.bash_profile
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Configure Mongo upstart script
template: src=mongodb_upstart.j2
dest=/etc/init/mongodb.conf
owner=root
group=root
- name: jenkins | ensure .bashrc exists
shell: touch {{ jenkins_user_home }}/.bashrc
sudo_user: "{{ jenkins_user }}"
- name: jenkins | Start the mongo service
service: name=mongodb state=stopped
- name: jenkins | Configure bashrc
lineinfile: dest={{ jenkins_user_home }}/.bashrc
regexp="source /usr/local/bin/jenkins_env.sh"
line="source /usr/local/bin/jenkins_env.sh"
# Install bash scripts
- name: jenkins | Install Python packages scripts
copy: src="${item}" dest="/usr/local/bin/${item}"
force=yes
owner=root group=root
mode=755
with_items:
- download_python_pkgs.sh
- install_python_pkgs.sh
# Ensure that code executed by the worker can't be
# installed to execute on login.
- name: Set permissions on .bash_profile
file: path="{{ jenkins_user_home }}/.bash_profile" state=file
owner="{{ jenkins_user }}" group="{{ jenkins_group }}"
mode=0500
# Install upstart script to download Python packages from S3
- name: jenkins | Install Python packages upstart script
template: src="python_pkgs.conf.j2" dest="/etc/init/python_pkgs.conf"
- name: Set permissions on .bashrc
file: path="{{ jenkins_user_home }}/.bashrc" state=file
owner="{{ jenkins_user }}" group="{{ jenkins_group }}"
mode=0500
......@@ -2,15 +2,6 @@
- name: xvfb | install xvfb
apt: pkg=xvfb state=present
- name: xvfb | configure display
template: src=xvfb.sh.j2 dest=/etc/profile.d/xvfb.sh owner=root group=root mode=0755
- name: xvfb | Configure bash to load env variables
lineinfile:
dest="{{ jenkins_user_home }}/.bashrc"
regexp='. /etc/profile.d/xvfb.sh'
line='. /etc/profile.d/xvfb.sh'
- name: xvfb | create xvfb upstart script
template: src=xvfb.conf.j2 dest=/etc/init/xvfb.conf owner=root group=root
......
# Configure Ruby
export RBENV_ROOT="{{ rbenv_root }}"
export PATH=$RBENV_ROOT/bin/:$PATH
eval "$(rbenv init -)"
# Configure JavaScript coverage
export JSCOVER_JAR=/usr/local/bin/JSCover-all.jar
# Set the display to the virtual frame buffer (Xvfb)
export DISPLAY=:1
export JSCOVER_JAR=/usr/local/bin/JSCover-all.jar
......@@ -12,7 +12,10 @@ script
download_python_pkgs.sh {{ python_pkg_url }} {{ python_download_dir }}
# Give the Jenkins user access
chown {{ jenkins_user }}:{{ jenkins_group }} -R 600 {{ python_download_dir }}
chown {{ jenkins_user }}:{{ jenkins_group }} -R 600 {{ python_virtualenv }}
chown {{ jenkins_user }}:{{ jenkins_group }} -R {{ python_download_dir }}
chmod 500 -R {{ python_download_dir }}
chown {{ jenkins_user }}:{{ jenkins_group }} -R {{ python_virtualenv }}
chmod 700 -R {{ python_virtualenv }}
end script
# Set the display to the virtual frame buffer (Xvfb)
export DISPLAY=:1
......@@ -6,13 +6,10 @@ jenkins_phantomjs_folder: phantomjs-1.9.1-linux-x86_64
jenkins_user: "jenkins"
jenkins_group: "jenkins"
jenkins_user_home: /home/jenkins
jenkins_ruby_version: "1.9.3-p374"
# Ruby Specific Vars
ruby_base: "{{ jenkins_user_home }}"
rbenv_root: "{{ ruby_base }}/.rbenv"
ruby_version: "{{ jenkins_ruby_version }}"
gem_home: "{{ ruby_base }}/.gem"
rbenv_root: "{{ jenkins_user_home }}/.rbenv"
ruby_version: "1.9.3-p374"
# JSCover direct download URL
jscover_url: "http://superb-dca2.dl.sourceforge.net/project/jscover/JSCover-1.0.2.zip"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment