Commit 9c7fc649 by Stu Young Committed by GitHub

Merge pull request #3319 from edx/estute/create-jenkins-android-worker

add role for configuring android worker
parents 7a15d020 f3066893
# 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
---
# User/group to manage Android SDK
android_user: "android"
android_group: "android"
# Tarball to download
android_download: "android-sdk_r24.4.1-linux.tgz"
# Checksum of Android SDK (from: https://developer.android.com/studio/index.html#downloads)
android_checksum: "725bb360f0f7d04eaccff5a2d57abdd49061326d"
# path to installed android sdk
android_home: "/opt/android-sdk-linux"
# individual android build targets to be downloaded via the androind sdk manager
android_build_targets:
- android-23
---
# Configure a system for building the edx android application
# Configure a user/group to own/run the android sdk
- name: Create group for the user of the sdk
group: name={{ android_group }} state=present
- name: Add the user to the group and configure shell
user: name={{ android_user }} append=yes group={{ android_group }} shell=/bin/bash
# Download the Android SDK/tools tarball from Google's download site.
# NOTE: while it is the general policy to use repositories/ppas as much as possible
# it did not seem reliable for this work. Other avenues were explored:
# - pre-Ubuntu 16 releases do not contain the android sdk in their apt repos
# - the existing ppas containing the sdk are questionable
# - ubuntu-make did not seem reliable at the time of writing this
- name: Download the Android SDK tarball
get_url:
url: "https://dl.google.com/android/{{ android_download }}"
dest: /tmp/android-sdk.tgz
- name: Verify checksum of Android SDK
shell: "sha1sum /tmp/android-sdk.tgz"
register: sdk_checksum
- assert:
that:
"'{{ android_checksum }}' in sdk_checksum.stdout"
- name: Unarchive tarball to /opt/android-sdk
unarchive:
copy: no
src: /tmp/android-sdk.tgz
dest: /opt
creates: "{{ android_home }}"
owner: "{{ android_user }}"
group: "{{ android_group }}"
become: yes
# Use the android sdk manager to install the build targets necessary for the edx mobile app
- name: Install Android API levels
shell: "echo 'y' | {{ android_home }}/tools/android update sdk --no-ui --filter {{ ','.join(android_build_targets) }}"
become: yes
become_user: "{{ android_user }}"
......@@ -15,3 +15,19 @@ dependencies:
# dependencies for sitespeed worker
- role: sitespeedio
when: sitespeed_worker is defined
# dependencies for android worker
- role: android_sdk
when: android_worker is defined
# User/group to manage Android SDK
android_user: "jenkins"
android_group: "jenkins"
# Tarball to download
android_download: "android-sdk_r24.4.1-linux.tgz"
# Checksum of Android SDK (from: https://developer.android.com/studio/index.html#downloads)
android_checksum: "725bb360f0f7d04eaccff5a2d57abdd49061326d"
# path to installed android sdk
android_home: "/opt/android-sdk-linux"
# individual android build targets to be downloaded via the androind sdk manager
android_build_targets:
- android-23
......@@ -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 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 |tr '\n' ' '"
register: build_targets
- with_items: "{{ android_build_targets }}"
assert:
that:
- "'{{ item }}' in build_targets.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`}}",
"delete_or_keep": "{{env `DELETE_OR_KEEP_AMI`}}",
"remote_branch": "{{env `REMOTE_BRANCH`}}"
},
"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",
"tags": {
"delete_or_keep": "{{user `delete_or_keep`}}"
}
}],
"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": "../../util/install/ansible-bootstrap.sh",
"destination": "{{user `playbook_remote_dir`}}/ansible-bootstrap.sh"
}, {
"type": "shell",
"inline": ["cd {{user `playbook_remote_dir`}}",
"export CONFIGURATION_VERSION='{{user `remote_branch`}}'",
"sudo bash ./ansible-bootstrap.sh" ]
}, {
"type": "ansible-local",
"playbook_file": "../../playbooks/edx-east/jenkins_worker_android.yml",
"playbook_dir": "../../playbooks",
"command": "source /edx/app/edx_ansible/venvs/edx_ansible/bin/activate && ansible-playbook",
"inventory_groups": "jenkins_worker",
"extra_arguments": [ "-vvv" ]
}]
}
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