Skip to content

Commit

Permalink
Feature #1 | Ionic, Cordova and Android SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbung committed Dec 24, 2016
1 parent d5ad2d8 commit 01c932f
Show file tree
Hide file tree
Showing 16 changed files with 321 additions and 7 deletions.
26 changes: 26 additions & 0 deletions android-provisioning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- hosts: hosts

vars_files: ["vars/default.yml"]

become: true

pre_tasks:
- name: Install node & npm
apt:
name: "{{item}}"
state: present
with_items:
- nodejs
- npm

- name: Install cordova and ionic globally
npm:
name: "{{item}}"
global: yes
with_items:
- ionic
- cordova

roles:
- { role: nickpack.android-sdk }
2 changes: 1 addition & 1 deletion environment-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
- phpcs
- devtools

- name: Install PHPCS via PEAR
- name: Install PHPCS 1.5.6 via PEAR
shell: "pear install -f PHP_CodeSniffer-1.5.6"
tags:
- devtools
Expand Down
26 changes: 26 additions & 0 deletions roles/nickp666.android-sdk/LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Copyright (c) 2015, Nikki James Pack
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The views and conclusions contained in the software and documentation are those
of the authors and should not be interpreted as representing official policies,
either expressed or implied, of the FreeBSD Project.
103 changes: 103 additions & 0 deletions roles/nickp666.android-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Ansible Role: Android SDK

An Ansible Role that installs the Android SDK tools, SDK packages and dependencies on Ubuntu and RedHat based OS'.

## Requirements

A recent version of Ubuntu.

## Role Variables

Available variables are listed below, along with default values (see `defaults/main.yml`):

android_sdk_download_location: http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz

The location to the Android SDK tools package to be installed.

android_sdk_install_location: /opt

The location on disk where you'd like to SDK to be installed.

ubuntu_dependency_packages:
- "libncurses5"
- "libstdc++6"
- "zlib1g"
- "imagemagick"
- "expect"
- "gradle"
- "ant"
- "ccache"
- "autoconf"
- "automake"
- "ant"
- "ccache"
- "python-dev"
- "zlibc"

A list of aptitude installable build dependency packages.

ubuntu_precise_dependency_packages:
- "libgd2-xpm"
- "libgphoto2-2"
- "libsane"
- "ia32-libs-multiarch"

A list of aptitude installable build dependencies for Ubuntu Precise.

rh_dependency_packages:
- expect
- libstdc++.i686
- mesa-libGL-devel
- ncurses-libs.i686
- zlib.i686

A list of yum installable build dependencies for RedHat based OS.

android_sdk_update_path: true

Whether or not the role should update the PATH in /etc/environment with the relevant android SDK locations

android_sdk_base_buildtools_version: 20.0.0

The main build tools version from the SDK to use, mainly useful for PATH updates.

android_sdk_tools_to_install:
- build-tools-20.0.0
- build-tools-19.1.0
- platform-tools
- tools
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
android_sdks_to_install:
- android-21
- android-20
- android-19
- android-18
- android-17
- android-16

The actual Android SDK packages to install using the SDK manager.

## Example Playbook

- hosts: appbuild
vars_files:
- vars/main.yml
roles:
- { role: nickp666.android-sdk }

## License

BSD

## Author Information

This role was created in 2015 by [Nick Pack](https://github.com/nickpack).

## Contributors

* @halkeye - Seperated SDK tools, fixed 64bit environment
* @edunham - Fixed 32bit support
* @peterjanes - Added RedHat family support
* @conorsch - Changed conditionals to allow > 14.04 support
54 changes: 54 additions & 0 deletions roles/nickp666.android-sdk/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
# defaults file for android-sdk

android_sdk_download_location: http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz
android_sdk_install_location: /opt

ubuntu_dependency_packages:
- "libncurses5:i386"
- "libstdc++6:i386"
- "zlib1g:i386"
- "imagemagick"
- "expect"
- "gradle"
- "ant"
- "ccache"
- "autoconf"
- "automake"
- "ant"
- "ccache"
- "python-dev"
- "zlibc"

ubuntu_precise_dependency_packages:
- "libgd2-xpm"
- "libgphoto2-2"
- "libsane"
- "ia32-libs-multiarch"

rh_dependency_packages:
- expect
- libstdc++.i686
- mesa-libGL-devel
- ncurses-libs.i686
- zlib.i686

android_sdk_update_path: true

android_sdk_base_buildtools_version: 23.0.2 # Used for PATH when android_sdk_update_path is true

android_sdk_tools_to_install:
- "build-tools-{{ android_sdk_base_buildtools_version }}"
- build-tools-19.1.0
- platform-tools
- tools
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
android_sdks_to_install:
- android-21
- android-20
- android-19
- android-18
- android-17
- android-16
2 changes: 2 additions & 0 deletions roles/nickp666.android-sdk/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# handlers file for android-sdk
1 change: 1 addition & 0 deletions roles/nickp666.android-sdk/meta/.galaxy_install_info
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{install_date: 'Sat Dec 24 10:47:01 2016', version: v0.0.7}
30 changes: 30 additions & 0 deletions roles/nickp666.android-sdk/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
galaxy_info:
author: Nick Pack
description: "Installs the Android SDK tools, SDKs themselves and applicable application build dependencies"
company: 0xDEADFA11 Ltd
license: BSD
min_ansible_version: 1.2
platforms:
- name: Ubuntu
versions:
- raring
- saucy
- trusty
- xenial
- name: Fedora
versions:
- 18
- 22
- 23
- name: EL
versions:
- 6
- 7
galaxy_tags:
- development
- system
- android
- android-sdk
- adb
dependencies: []
31 changes: 31 additions & 0 deletions roles/nickp666.android-sdk/tasks/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---

- name: Check if i386 is enabled
shell: dpkg --print-foreign-architectures | grep i386
register: result_i386_check
changed_when: result_i386_check.rc == 1
failed_when: result_i386_check.rc > 1
when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and ansible_distribution_version >= "14.04"

- name: Enable i386 arch in aptitude
command: dpkg --add-architecture i386
when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and ansible_distribution_version >= "14.04" and result_i386_check.rc == 1

- name: Ensure apt cache is up to date
apt: update_cache=yes
when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and result_i386_check.rc == 1

- name: Install ia32-libs on Ubuntu 12.04
apt: pkg={{ item }} state=latest
when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and ansible_distribution_version == "12.04"
with_items: ubuntu_precise_dependency_packages

- name: Install build dependencies on Ubuntu
apt: pkg={{ item }} state=latest
when: ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint"
with_items: "{{ubuntu_dependency_packages}}"

- name: Install i386 dependencies on RH family
yum: pkg={{ item }} state=latest
when: ansible_distribution == "Fedora" or ansible_distribution == "CentOS" or ansible_distribution == "RedHat"
with_items: rh_dependency_packages
5 changes: 5 additions & 0 deletions roles/nickp666.android-sdk/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# tasks file for android-sdk
- include: dependencies.yml
- include: sdktools.yml
- include: sdksinstall.yml
4 changes: 4 additions & 0 deletions roles/nickp666.android-sdk/tasks/sdksinstall.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---

- name: Install Android SDKs for applicable releases
command: "{{ android_sdk_install_location }}/sdk-install.expect"
23 changes: 23 additions & 0 deletions roles/nickp666.android-sdk/tasks/sdktools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---

- name: Ensure Android SDK tools directory exists
file: path={{ android_sdk_install_location }} state=directory

- name: Download Android SDK tools
get_url: url={{ android_sdk_download_location }} dest={{ android_sdk_install_location }}/sdk-download.tgz

- name: Extract Android SDK tools
unarchive: src={{ android_sdk_install_location }}/sdk-download.tgz dest={{ android_sdk_install_location }} copy=no

- name: Put the SDK install expect script in place
template: src=sdk-install.expect.j2 dest={{ android_sdk_install_location }}/sdk-install.expect mode=0755

- name: Change permissions on SDK tools
file: path={{ android_sdk_install_location }}/android-sdk-linux recurse=yes mode=0755

- name: Set system wide PATH to contain Android SDK tools
lineinfile: dest=/etc/environment regexp=^PATH line='PATH="/usr/local/sbin:/usr/local/bin:{{ android_sdk_install_location }}/android-sdk-linux/build-tools/{{ android_sdk_base_buildtools_version }}:{{ android_sdk_install_location }}/android-sdk-linux/tools/:{{ android_sdk_install_location }}/android-sdk-linux/build-tools/:{{ android_sdk_install_location }}/android-sdk-linux/platform-tools/:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"'
when: android_sdk_update_path

- name: Set system wide ANDROID_HOME environment variable
lineinfile: dest=/etc/environment regexp=^ANDROID_HOME line='ANDROID_HOME="{{ android_sdk_install_location }}/android-sdk-linux/"'
8 changes: 8 additions & 0 deletions roles/nickp666.android-sdk/templates/sdk-install.expect.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/expect

set timeout -1;
spawn {{ android_sdk_install_location }}/android-sdk-linux/tools/android update sdk --all -u -t "{{ (android_sdk_tools_to_install + android_sdks_to_install) | join(',') }}";
expect {
"Do you accept the license" { exp_send "y\r" ; exp_continue }
eof
}
2 changes: 2 additions & 0 deletions roles/nickp666.android-sdk/vars/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# vars file for android-sdk
1 change: 0 additions & 1 deletion roles/nickpack.android-sdk
Submodule nickpack.android-sdk deleted from f4a8de
10 changes: 5 additions & 5 deletions vars/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ fpm_port: 9000
sites_container: "/var/www"
nginx_vhosts_location: "/etc/nginx/sites-enabled"

# Site setup vars
site_ssl: 1
ssl_selfsigned: 1

# Start section - configuration variables for Apache, NGINX & FPM
fpm_pm: "ondemand"
fpm_pm_max_children: 20
Expand Down Expand Up @@ -64,8 +68,4 @@ android_sdks_to_install:
- android-22
- android-21

android_sdk_install_location: "/home/{{server_runs_as}}"

# Site setup vars
site_ssl: 1
ssl_selfsigned: 1
#android_sdk_install_location: "/home/{{server_runs_as}}"

0 comments on commit 01c932f

Please sign in to comment.