Commit 94dedd7c by stu

add role/packer-setup for jenkins android worker

parent af01848b
# Configure a Jenkins worker instance
# This has all the requirements to build, sign, and test the android
# client, but does not contain the platform
- name: Configure instance(s)
hosts: jenkins_worker
become: True
gather_facts: True
vars:
serial_count: 1
android_worker: True
serial: "{{ serial_count }}"
roles:
- aws
- jenkins_worker
---
# ppa for ubuntu-make (used to manage sdks)
ubuntu_make_ppa: "ppa:ubuntu-desktop/ubuntu-make"
# path to android sdk
android_home: "/opt/android-sdk"
# individual android build targets to be downloaded via the androind sdk manager
android_build_targets:
- android-23
---
#
# edX Configuration
#
# github: https://github.com/edx/configuration
# wiki: https://openedx.atlassian.net/wiki/display/OpenOPS
# code style: https://openedx.atlassian.net/wiki/display/OpenOPS/Ansible+Code+Conventions
# license: https://github.com/edx/configuration/blob/master/LICENSE.TXT
#
# The following dependencies are already met in playbooks/roles/jenkins_worker. However,
# keep this file in case the android process calls for a JDK that differs from the one
# used on other Jenkins workers
#dependencies:
# - common
# - role: oraclejdk
# oraclejdk_version: "8u60"
# oraclejdk_base: "jdk1.8.0_60"
# oraclejdk_build: "b27"
# oraclejdk_link: "/usr/lib/jvm/java-8-oracle"
---
# Configure the Jenkins worker system for building the edx android application
# Ubuntu 16 offers the android sdk in their apt repos, however it does not contain the sdk
# manager script. Instead, ubuntu is now managing sdks/ides via Ubuntu Make
# (see https://wiki.ubuntu.com/ubuntu-make).
- name: Add Ubuntu Make PPA
apt_repository:
repo: "{{ ubuntu_make_ppa }}"
state: present
become: yes
- name: Install Ubuntu Make
apt:
name: ubuntu-make
update_cache: yes
install_recommends: yes
become: yes
state: yes
# Use ubuntu-make to install the android sdk and developer tools.
- name: Install Android SDK
shell: "umake android android-studio --accept-license destdir {{ android_home }}"
# Use the android sdk manager to install the build targets necessary for the edx mobile app
# If needed, just add more targets to the with_items clause
- name: Install Android API levels
shell: "{{ android_home }}/tools/android sdk -f --no-ui --filter {{ ','.join(android_build_targets) }}"
......@@ -15,3 +15,7 @@ dependencies:
# dependencies for sitespeed worker
- role: sitespeedio
when: sitespeed_worker is defined
# dependencies for android worker
- role: android
when: android_worker is defined
......@@ -20,3 +20,5 @@
when: platform_worker is defined
- include: test_sitespeed_worker.yml
when: sitespeed_worker is defined
- include: test_android_worker.yml
when: android_worker is defined
---
# Test that ubuntu make has been installed and is at least at version
# 16.00
- name: Verify Ubuntu Make is installed
shell: umake --version
register: umake_version
- assert:
that:
- "float(umake_version.stdout) >= 16.00"
# Test that the Android sdk has been installed to the correct location
- name: Verify Android SDK is installed
shell: "stat {{ android_home }}/tools/android"
register: android_version
- assert:
that:
- "android_version.rc == 0"
# Test that the necessary build targets for building the edx app have
# been installed
- name: Verify correct Android build targets installed
shell: "{{ android_home }}/tools/android list target"
register: build_targets
- assert:
that:
- "'{{ android_build_targets }}' in build_target.stdout"
{
"variables": {
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"playbook_remote_dir": "/tmp/packer-edx-playbooks",
"ami": "{{env `JENKINS_WORKER_AMI`}}"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"ami_name": "jenkins_worker_android-{{isotime | clean_ami_name}}",
"instance_type": "m3.large",
"region": "us-east-1",
"source_ami": "{{user `ami`}}",
"ssh_username": "ubuntu",
"ami_description": "jenkins worker android",
"iam_instance_profile": "jenkins-worker",
"security_group_id": "sg-75af5e18"
}],
"provisioners": [{
"type": "shell",
"inline": ["rm -rf {{user `playbook_remote_dir`}}",
"mkdir {{user `playbook_remote_dir`}}"]
}, {
"type": "file",
"source": "../../playbooks/run_role.yml",
"destination": "{{user `playbook_remote_dir`}}/run_role.yml"
}, {
"type": "file",
"source": "../../playbooks/roles",
"destination": "{{user `playbook_remote_dir`}}/roles"
}, {
"type": "file",
"source": "../../playbooks/edx-east",
"destination": "{{user `playbook_remote_dir`}}/edx-east"
}, {
"type": "file",
"source": "../../requirements.txt",
"destination": "{{user `playbook_remote_dir`}}/requirements.txt"
}, {
"type": "shell",
"inline": ["sudo add-apt-repository ppa:git-core/ppa -y"]
}, {
"type": "shell",
"inline": ["sudo apt-get update"]
}, {
"type": "shell",
"inline": ["sudo apt-get -y install git-core"]
}, {
"type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}",
"virtualenv packer-venv",
". packer-venv/bin/activate",
"pip install -q -r requirements.txt",
"echo '[jenkins_worker]' > inventory.ini",
"echo 'localhost' >> inventory.ini",
"ansible-playbook edx-east/jenkins_worker_android.yml -i inventory.ini -c local -vvvv"]
}]
}
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