rewrite the tasks using YAML syntax

parent 8cd7d0c5
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
- name: Download packer - name: Download packer
shell: "curl -L {{ packer_url }} -o /var/tmp/packer.zip" shell: "curl -L {{ packer_url }} -o /var/tmp/packer.zip"
args: args:
creates: /var/tmp/packer.zip creates: /var/tmp/packer.zip
- name: Unzip packer - name: Unzip packer
unarchive: src=/var/tmp/packer.zip dest=/usr/local/bin copy=no unarchive:
src: /var/tmp/packer.zip
dest: /usr/local/bin
copy: no
--- ---
# Requests library is required for both the github status # Requests library is required for both the github status
# script, as well as the sitespeed cookie script. # script, as well as the sitespeed cookie script.
- name: Install requests Python library - name: Install requests Python library
pip: name=requests state=present pip:
name: requests
state: present
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
# refers to the --depth-setting of git clone. A value of 1 # refers to the --depth-setting of git clone. A value of 1
# will truncate all history prior to the last revision. # will truncate all history prior to the last revision.
- name: Create shallow clone of edx-platform - name: Create shallow clone of edx-platform
git_2_0_1: > git_2_0_1:
repo=https://github.com/edx/edx-platform.git repo: "https://github.com/edx/edx-platform.git"
dest={{ jenkins_home }}/shallow-clone dest: "{{ jenkins_home }}/shallow-clone"
version={{ jenkins_edx_platform_version }} version: "{{ jenkins_edx_platform_version }}"
depth=1 depth: 1
become_user: "{{ jenkins_user }}" become_user: "{{ jenkins_user }}"
# pip-accel skipped due to conflicting versions of pip required # pip-accel skipped due to conflicting versions of pip required
...@@ -31,12 +31,12 @@ ...@@ -31,12 +31,12 @@
# (0.22.4) is only compatible with pip >= 1.4, < 1.5 and the current # (0.22.4) is only compatible with pip >= 1.4, < 1.5 and the current
# version of pip in edx-platform is 6.0.8. # version of pip in edx-platform is 6.0.8.
- name: Install edx-platform requirements using pip - name: Install edx-platform requirements using pip
pip: > pip:
requirements={{ jenkins_home }}/shallow-clone/requirements/edx/{{ item }} requirements: "{{ jenkins_home }}/shallow-clone/requirements/edx/{{ item }}"
extra_args="--exists-action=w" extra_args: "--exists-action=w"
virtualenv={{ jenkins_home }}/edx-venv virtualenv: "{{ jenkins_home }}/edx-venv"
virtualenv_command=virtualenv virtualenv_command: virtualenv
executable=pip executable: pip
with_items: with_items:
- pre.txt - pre.txt
- github.txt - github.txt
...@@ -44,21 +44,21 @@ ...@@ -44,21 +44,21 @@
- paver.txt - paver.txt
become_user: "{{ jenkins_user }}" become_user: "{{ jenkins_user }}"
# These and the pip install below it can be removed some time after # These and the pip install below it can be removed some time after
# https://github.com/edx/edx-platform/pull/7465 has merged. # https://github.com/edx/edx-platform/pull/7465 has merged.
# This will keep us from breaking after that gets merged. # This will keep us from breaking after that gets merged.
- stat: path="{{ jenkins_home }}/shallow-clone/requirements/edx/post.txt" - stat:
path: "{{ jenkins_home }}/shallow-clone/requirements/edx/post.txt"
register: post_requirements register: post_requirements
become_user: "{{ jenkins_user }}" become_user: "{{ jenkins_user }}"
- name: Install edx-platform post requirements using pip - name: Install edx-platform post requirements using pip
pip: > pip:
requirements={{ jenkins_home }}/shallow-clone/requirements/edx/{{ item }} requirements: "{{ jenkins_home }}/shallow-clone/requirements/edx/{{ item }}"
extra_args="--exists-action=w" extra_args: "--exists-action=w"
virtualenv={{ jenkins_home }}/edx-venv virtualenv: "{{ jenkins_home }}/edx-venv"
virtualenv_command=virtualenv virtualenv_command: virtualenv
executable=pip executable: pip
with_items: with_items:
- post.txt - post.txt
become_user: "{{ jenkins_user }}" become_user: "{{ jenkins_user }}"
...@@ -69,15 +69,17 @@ ...@@ -69,15 +69,17 @@
# The edx-venv directory is deleted and then recreated # The edx-venv directory is deleted and then recreated
# cleanly from the archive by the jenkins build scripts. # cleanly from the archive by the jenkins build scripts.
- name: Create a clean virtualenv archive - name: Create a clean virtualenv archive
command: > command: "tar -cpzf edx-venv_clean.tar.gz edx-venv"
tar -cpzf edx-venv_clean.tar.gz edx-venv args:
chdir={{ jenkins_home }} chdir: "{{ jenkins_home }}"
become_user: "{{ jenkins_user }}" become_user: "{{ jenkins_user }}"
# Remove the shallow-clone directory now that we are # Remove the shallow-clone directory now that we are
# done with it # done with it
- name: Remove shallow-clone - name: Remove shallow-clone
file: path={{ jenkins_home }}/shallow-clone state=absent file:
path: "{{ jenkins_home }}/shallow-clone"
state: absent
# Although firefox is installed through the browsers role, install # Although firefox is installed through the browsers role, install
# a newer copy under the jenkins home directory. This will allow # a newer copy under the jenkins home directory. This will allow
...@@ -88,7 +90,7 @@ ...@@ -88,7 +90,7 @@
url: "{{ custom_firefox_url }}" url: "{{ custom_firefox_url }}"
dest: "{{ jenkins_home }}/firefox-{{ custom_firefox_version }}.tar.bz2" dest: "{{ jenkins_home }}/firefox-{{ custom_firefox_version }}.tar.bz2"
- name: unpack custom firefox version - name: Unpack custom firefox version
unarchive: unarchive:
src: "{{ jenkins_home }}/firefox-{{ custom_firefox_version }}.tar.bz2" src: "{{ jenkins_home }}/firefox-{{ custom_firefox_version }}.tar.bz2"
dest: "{{ jenkins_home }}" dest: "{{ jenkins_home }}"
......
--- ---
- name: Create jenkins group - name: Create jenkins group
group: name={{ jenkins_group }} state=present group:
name: "{{ jenkins_group }}"
state: present
# The Jenkins account needs a login shell because Jenkins uses scp # The Jenkins account needs a login shell because Jenkins uses scp
- name: Add the jenkins user to the group and configure shell - name: Add the jenkins user to the group and configure shell
user: name={{ jenkins_user }} append=yes group={{ jenkins_group }} shell=/bin/bash user:
name: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
append: yes
shell: /bin/bash
# Because of a bug in the latest release of the EC2 plugin # Because of a bug in the latest release of the EC2 plugin
# we need to use a key generated by Amazon (not imported) # we need to use a key generated by Amazon (not imported)
...@@ -12,43 +18,59 @@ ...@@ -12,43 +18,59 @@
# using the same keypair the instance was started with. # using the same keypair the instance was started with.
- name: Create .ssh directory - name: Create .ssh directory
file: file:
path={{ jenkins_home }}/.ssh state=directory path: "{{ jenkins_home }}/.ssh"
owner={{ jenkins_user }} group={{ jenkins_group }} state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
ignore_errors: yes ignore_errors: yes
- name: Copy ssh keys for jenkins - name: Copy ssh keys for jenkins
command: cp /home/ubuntu/.ssh/authorized_keys /home/{{ jenkins_user }}/.ssh/authorized_keys command: "cp /home/ubuntu/.ssh/authorized_keys /home/{{ jenkins_user }}/.ssh/authorized_keys"
ignore_errors: yes ignore_errors: yes
- name: Set key permissions - name: Set key permissions
file: file:
path={{ jenkins_home }}/.ssh/authorized_keys path: "{{ jenkins_home }}/.ssh/authorized_keys"
owner={{ jenkins_user }} group={{ jenkins_group }} mode=400 owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: "0400"
ignore_errors: yes ignore_errors: yes
# adding chris-lea nodejs repo # adding chris-lea nodejs repo
- name: add ppas for current versions of nodejs - name: Add ppas for current versions of nodejs
apt_repository: repo="{{ jenkins_chrislea_ppa }}" apt_repository:
repo: "{{ jenkins_chrislea_ppa }}"
state: present
- name: Install system packages - name: Install system packages
apt: pkg={{','.join(jenkins_debian_pkgs)}} apt:
state=present update_cache=yes name: "{{ item }}"
state: present
update_cache: yes
with_items: "{{ jenkins_debian_pkgs }}"
- name: Add script to set up environment variables - name: Add script to set up environment variables
template: template:
src=jenkins_env.j2 dest={{ jenkins_home }}/jenkins_env src: jenkins_env.j2
owner={{ jenkins_user }} group={{ jenkins_group }} mode=0500 dest: "{{ jenkins_home }}/jenkins_env"
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: "0500"
when: platform_worker is defined when: platform_worker is defined
# Need to add Github to known_hosts to avoid # Need to add Github to known_hosts to avoid
# being prompted when using git through ssh # being prompted when using git through ssh
- name: Add github.com to known_hosts if it does not exist - name: Add github.com to known_hosts if it does not exist
shell: > shell: >
ssh-keygen -f {{ jenkins_home }}/.ssh/known_hosts -H -F github.com | grep -q found || ssh-keyscan -H github.com > {{ jenkins_home }}/.ssh/known_hosts "ssh-keygen -f {{ jenkins_home }}/.ssh/known_hosts -H -F github.com | grep -q found || ssh-keyscan -H github.com > {{ jenkins_home }}/.ssh/known_hosts"
# Edit the /etc/hosts file so that the Preview button will work in Studio # Edit the /etc/hosts file so that the Preview button will work in Studio
- name: add preview.localhost to /etc/hosts - name: Add preview.localhost to /etc/hosts
shell: sed -i -r 's/^127.0.0.1\s+.*$/127.0.0.1 localhost preview.localhost/' /etc/hosts lineinfile:
dest: /etc/hosts
regexp: "^127.0.0.1"
line: "127.0.0.1 localhost preview.localhost"
state: present
become: yes become: yes
# Npm registry must be pre-loaded or else setting it # Npm registry must be pre-loaded or else setting it
...@@ -56,17 +78,28 @@ ...@@ -56,17 +78,28 @@
# See https://github.com/npm/npm/issues/3565 # See https://github.com/npm/npm/issues/3565
- name: Set npm registry - name: Set npm registry
template: template:
src=.npmrc.j2 dest={{ jenkins_home }}/.npmrc src: ".npmrc.j2"
owner={{ jenkins_user }} group={{ jenkins_group }} mode=0664 dest: "{{ jenkins_home }}/.npmrc"
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: "0664"
# Set up configuration for pip-accel for caching python requirements # Set up configuration for pip-accel for caching python requirements
- name: Create directory for pip-accel config file - name: Create directory for pip-accel config file
file: path={{ jenkins_home }}/.pip-accel state=directory file:
owner={{ jenkins_user }} group={{ jenkins_group }} mode=0777 recurse=yes path: "{{ jenkins_home }}/.pip-accel"
state: directory
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: "0777"
recurse: yes
when: platform_worker is defined when: platform_worker is defined
- name: Create pip-accel config file - name: Create pip-accel config file
template: template:
src=pip-accel.conf.j2 dest={{ jenkins_home }}/.pip-accel/pip-accel.conf src: "pip-accel.conf.j2"
owner={{ jenkins_user }} group={{ jenkins_group }} mode=0664 dest: "{{ jenkins_home }}/.pip-accel/pip-accel.conf"
owner: "{{ jenkins_user }}"
group: "{{ jenkins_group }}"
mode: "0664"
when: platform_worker is defined when: platform_worker is defined
...@@ -7,9 +7,13 @@ ...@@ -7,9 +7,13 @@
# To get a baseline comparison for timestamp comparisons # To get a baseline comparison for timestamp comparisons
# create a testfile and register its stat info # create a testfile and register its stat info
- name: Create test file - name: Create test file
file: path=testfile state=touch file:
path: testfile
state: touch
- name: Stat test file - name: Stat test file
stat: path=testfile stat:
path: testfile
register: testfile register: testfile
...@@ -27,7 +31,8 @@ ...@@ -27,7 +31,8 @@
# Verify the virtualenv tar is newly-built # Verify the virtualenv tar is newly-built
- name: Get info on virtualenv tar - name: Get info on virtualenv tar
stat: path={{ jenkins_home }}/edx-venv_clean.tar.gz stat:
path: "{{ jenkins_home }}/edx-venv_clean.tar.gz"
register: edxvenv register: edxvenv
- assert: - assert:
that: that:
...@@ -35,9 +40,13 @@ ...@@ -35,9 +40,13 @@
- "{{ testfile.stat.mtime }} - {{ edxvenv.stat.mtime }} < 3600" - "{{ testfile.stat.mtime }} - {{ edxvenv.stat.mtime }} < 3600"
# Verify that postfix (mail server) is listening # Verify that postfix (mail server) is listening
- wait_for: host={{ inventory_hostname }} port=25 - wait_for:
host: "{{ inventory_hostname }}"
port: 25
delegate_to: localhost delegate_to: localhost
# Tear Down # # Tear Down #
- name: Remove test file - name: Remove test file
file: path=testfile state=absent file:
path: testfile
state: absent
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