├── .travis.yml ├── CHANGELOG.md ├── LICENCE ├── README.md ├── defaults └── main.yml ├── handlers └── main.yml ├── meta └── main.yml ├── tasks ├── dependencies-Darwin.yml ├── dependencies-Debian.yml ├── dependencies-RedHat.yml ├── main.yml ├── sdksinstall-Darwin.yml ├── sdksinstall-Linux.yml ├── sdktools-Darwin.yml ├── sdktools-Linux.yml ├── setup-Darwin.yml ├── setup-Debian.yml └── setup-RedHat.yml ├── templates └── sdk-install.expect.j2 ├── tests ├── inventory └── test.yml └── vars ├── Darwin.yml ├── default.yml └── main.yml /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | language: python 3 | python: "2.7" 4 | 5 | # Use the new container infrastructure 6 | sudo: false 7 | 8 | # Install ansible 9 | addons: 10 | apt: 11 | packages: 12 | - python-pip 13 | 14 | install: 15 | # Install ansible 16 | - pip install ansible 17 | 18 | # Install ansible-lint 19 | - pip install ansible-lint 20 | 21 | # Check ansible version 22 | - ansible --version 23 | 24 | # Create ansible.cfg with correct roles_path 25 | - printf '[defaults]\nroles_path=../' >ansible.cfg 26 | 27 | script: 28 | # Basic role syntax check 29 | - ansible-playbook tests/test.yml -i tests/inventory --syntax-check 30 | - ansible-lint . 31 | 32 | notifications: 33 | webhooks: https://galaxy.ansible.com/api/v1/notifications/ -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [v0.0.11](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.11) (2017-07-14) 4 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.10...v0.0.11) 5 | 6 | ## [v0.0.10](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.10) (2017-06-16) 7 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.9...v0.0.10) 8 | 9 | **Merged pull requests:** 10 | 11 | - Added support for OSX \(Darwin\) [\#13](https://github.com/nickpack/ansible-role-android-sdk/pull/13) ([ojechev-broadsoft](https://github.com/ojechev-broadsoft)) 12 | 13 | ## [v0.0.9](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.9) (2017-02-09) 14 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.8...v0.0.9) 15 | 16 | **Closed issues:** 17 | 18 | - Getting error installing dependencies [\#10](https://github.com/nickpack/ansible-role-android-sdk/issues/10) 19 | 20 | ## [v0.0.8](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.8) (2017-02-09) 21 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.7...v0.0.8) 22 | 23 | **Closed issues:** 24 | 25 | - Latest releases not on Ansible Galaxy [\#9](https://github.com/nickpack/ansible-role-android-sdk/issues/9) 26 | 27 | **Merged pull requests:** 28 | 29 | - Fixed with\_items for dependencies [\#11](https://github.com/nickpack/ansible-role-android-sdk/pull/11) ([rodrigdav](https://github.com/rodrigdav)) 30 | 31 | ## [v0.0.7](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.7) (2016-11-07) 32 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.6...v0.0.7) 33 | 34 | ## [v0.0.6](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.6) (2016-09-01) 35 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.5...v0.0.6) 36 | 37 | **Merged pull requests:** 38 | 39 | - Supports versions of Ubuntu greater than 14.04 [\#8](https://github.com/nickpack/ansible-role-android-sdk/pull/8) ([conorsch](https://github.com/conorsch)) 40 | 41 | ## [v0.0.5](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.5) (2016-03-14) 42 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.4...v0.0.5) 43 | 44 | **Merged pull requests:** 45 | 46 | - Sdk tools to array [\#6](https://github.com/nickpack/ansible-role-android-sdk/pull/6) ([halkeye](https://github.com/halkeye)) 47 | - Fix 64 [\#5](https://github.com/nickpack/ansible-role-android-sdk/pull/5) ([halkeye](https://github.com/halkeye)) 48 | 49 | ## [v0.0.4](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.4) (2015-11-30) 50 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.3...v0.0.4) 51 | 52 | **Merged pull requests:** 53 | 54 | - Add support for RedHat family [\#4](https://github.com/nickpack/ansible-role-android-sdk/pull/4) ([peterjanes](https://github.com/peterjanes)) 55 | 56 | ## [v0.0.3](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.3) (2015-10-29) 57 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.2...v0.0.3) 58 | 59 | ## [v0.0.2](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.2) (2015-10-29) 60 | [Full Changelog](https://github.com/nickpack/ansible-role-android-sdk/compare/v0.0.1...v0.0.2) 61 | 62 | **Closed issues:** 63 | 64 | - No package matching 'libncurses5:i386' is available error [\#1](https://github.com/nickpack/ansible-role-android-sdk/issues/1) 65 | 66 | **Merged pull requests:** 67 | 68 | - Make installation Just Work on 32-bit Ubuntu in Vagrant [\#2](https://github.com/nickpack/ansible-role-android-sdk/pull/2) ([edunham](https://github.com/edunham)) 69 | 70 | ## [v0.0.1](https://github.com/nickpack/ansible-role-android-sdk/tree/v0.0.1) (2015-01-08) 71 | -------------------------------------------------------------------------------- /LICENCE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Nikki James Pack 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | 1. Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 14 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 17 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 22 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | The views and conclusions contained in the software and documentation are those 25 | of the authors and should not be interpreted as representing official policies, 26 | either expressed or implied, of the FreeBSD Project. 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ansible Role: Android SDK 2 | 3 | [![Build Status](https://travis-ci.org/nickpack/ansible-role-android-sdk.svg?branch=master)](https://travis-ci.org/nickpack/ansible-role-android-sdk) 4 | 5 | An Ansible Role that installs the Android SDK tools, SDK packages and dependencies on Ubuntu and RedHat based OS'. 6 | 7 | ## Requirements 8 | 9 | A recent version of Ubuntu. 10 | 11 | ## Role Variables 12 | 13 | Available variables are listed below, along with default values (see `defaults/main.yml`): 14 | 15 | android_sdk_download_location: http://dl.google.com/android/android-sdk_r23.0.2-linux.tgz 16 | 17 | The location to the Android SDK tools package to be installed. 18 | 19 | android_sdk_install_location: /opt 20 | 21 | The location on disk where you'd like to SDK to be installed. 22 | 23 | ubuntu_dependency_packages: 24 | - "libncurses5" 25 | - "libstdc++6" 26 | - "zlib1g" 27 | - "imagemagick" 28 | - "expect" 29 | - "gradle" 30 | - "ant" 31 | - "ccache" 32 | - "autoconf" 33 | - "automake" 34 | - "ant" 35 | - "ccache" 36 | - "python-dev" 37 | - "zlibc" 38 | 39 | A list of aptitude installable build dependency packages. 40 | 41 | ubuntu_precise_dependency_packages: 42 | - "libgd2-xpm" 43 | - "libgphoto2-2" 44 | - "libsane" 45 | - "ia32-libs-multiarch" 46 | 47 | A list of aptitude installable build dependencies for Ubuntu Precise. 48 | 49 | rh_dependency_packages: 50 | - expect 51 | - libstdc++.i686 52 | - mesa-libGL-devel 53 | - ncurses-libs.i686 54 | - zlib.i686 55 | 56 | A list of yum installable build dependencies for RedHat based OS. 57 | 58 | android_sdk_update_path: true 59 | 60 | Whether or not the role should update the PATH in /etc/environment with the relevant android SDK locations 61 | 62 | android_sdk_base_buildtools_version: 20.0.0 63 | 64 | The main build tools version from the SDK to use, mainly useful for PATH updates. 65 | 66 | android_sdk_tools_to_install: 67 | - build-tools-20.0.0 68 | - build-tools-19.1.0 69 | - platform-tools 70 | - tools 71 | - extra-android-support 72 | - extra-google-m2repository 73 | - extra-android-m2repository 74 | android_sdks_to_install: 75 | - android-21 76 | - android-20 77 | - android-19 78 | - android-18 79 | - android-17 80 | - android-16 81 | 82 | The actual Android SDK packages to install using the SDK manager. 83 | 84 | ## Example Playbook 85 | 86 | - hosts: appbuild 87 | vars_files: 88 | - vars/main.yml 89 | roles: 90 | - { role: nickpack.android_sdk } 91 | 92 | ## License 93 | 94 | BSD 95 | 96 | ## Author Information 97 | 98 | This role was created in 2015 by [Nick Pack](https://github.com/nickpack). 99 | 100 | ## Contributors 101 | 102 | * @timdaman - Fixed defect in variable loading 103 | * @ojechev-broadsoft - OSX Support 104 | * @rodrigdav - Fixed bare variables that broke 2.2 compatibility 105 | * @halkeye - Seperated SDK tools, fixed 64bit environment 106 | * @edunham - Fixed 32bit support 107 | * @peterjanes - Added RedHat family support 108 | * @conorsch - Changed conditionals to allow > 14.04 support 109 | -------------------------------------------------------------------------------- /defaults/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # defaults file for android-sdk 3 | 4 | android_sdk_download_location: http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz 5 | android_sdk_install_location: /opt 6 | 7 | ubuntu_dependency_packages: 8 | - "libncurses5:i386" 9 | - "libstdc++6:i386" 10 | - "zlib1g:i386" 11 | - "imagemagick" 12 | - "expect" 13 | - "gradle" 14 | - "ant" 15 | - "ccache" 16 | - "autoconf" 17 | - "automake" 18 | - "ant" 19 | - "ccache" 20 | - "python-dev" 21 | - "zlibc" 22 | 23 | ubuntu_precise_dependency_packages: 24 | - "libgd2-xpm" 25 | - "libgphoto2-2" 26 | - "libsane" 27 | - "ia32-libs-multiarch" 28 | 29 | rh_dependency_packages: 30 | - expect 31 | - libstdc++.i686 32 | - mesa-libGL-devel 33 | - ncurses-libs.i686 34 | - zlib.i686 35 | 36 | android_sdk_update_path: true 37 | 38 | android_sdk_base_buildtools_version: 23.0.2 # Used for PATH when android_sdk_update_path is true 39 | 40 | android_sdk_tools_to_install: 41 | - "build-tools-{{ android_sdk_base_buildtools_version }}" 42 | - build-tools-19.1.0 43 | - platform-tools 44 | - tools 45 | - extra-android-support 46 | - extra-google-m2repository 47 | - extra-android-m2repository 48 | android_sdks_to_install: 49 | - android-21 50 | - android-20 51 | - android-19 52 | - android-18 53 | - android-17 54 | - android-16 55 | -------------------------------------------------------------------------------- /handlers/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # handlers file for android-sdk 3 | -------------------------------------------------------------------------------- /meta/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | galaxy_info: 3 | author: Nick Pack 4 | description: "Installs the Android SDK tools, SDKs themselves and applicable application build dependencies" 5 | company: 0xDEADFA11 Ltd 6 | license: BSD 7 | min_ansible_version: 1.2 8 | platforms: 9 | - name: Ubuntu 10 | versions: 11 | - raring 12 | - saucy 13 | - trusty 14 | - xenial 15 | - name: Fedora 16 | versions: 17 | - 18 18 | - 22 19 | - 23 20 | - name: EL 21 | versions: 22 | - 6 23 | - 7 24 | - name: MacOSX 25 | versions: 26 | - '10.11' 27 | - '10.12' 28 | galaxy_tags: 29 | - development 30 | - system 31 | - android 32 | - adb 33 | dependencies: [] 34 | -------------------------------------------------------------------------------- /tasks/dependencies-Darwin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: Install dependencies (Darwin) 3 | homebrew_cask: name={{item}} update_homebrew=yes state=present 4 | with_items: 5 | - android-sdk 6 | -------------------------------------------------------------------------------- /tasks/dependencies-Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Check if i386 is enabled 4 | shell: dpkg --print-foreign-architectures | grep i386 5 | register: result_i386_check 6 | changed_when: result_i386_check.rc == 1 7 | failed_when: result_i386_check.rc > 1 8 | when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and ansible_distribution_version >= "14.04" 9 | 10 | - name: Enable i386 arch in aptitude 11 | command: dpkg --add-architecture i386 12 | when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and ansible_distribution_version >= "14.04" and result_i386_check.rc == 1 13 | 14 | - name: Ensure apt cache is up to date 15 | apt: update_cache=yes 16 | when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and result_i386_check.rc == 1 17 | 18 | - name: Install ia32-libs on Ubuntu 12.04 19 | apt: pkg={{ item }} state=present 20 | when: (ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint") and ansible_distribution_version == "12.04" 21 | with_items: "{{ ubuntu_precise_dependency_packages }}" 22 | 23 | - name: Install build dependencies on Ubuntu 24 | apt: pkg={{ item }} state=present 25 | when: ansible_distribution == "Ubuntu" or ansible_distribution == "Linuxmint" 26 | with_items: "{{ ubuntu_dependency_packages }}" 27 | -------------------------------------------------------------------------------- /tasks/dependencies-RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install i386 dependencies on RH family 4 | yum: pkg={{ item }} state=present 5 | when: ansible_distribution == "Fedora" or ansible_distribution == "CentOS" or ansible_distribution == "RedHat" 6 | with_items: "{{ rh_dependency_packages }}" 7 | -------------------------------------------------------------------------------- /tasks/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - name: "Include vars for current OS family" 3 | include_vars: "{{ item }}" 4 | with_first_found: 5 | - "{{ ansible_distribution }}.yml" 6 | - "{{ ansible_os_family }}.yml" 7 | - "default.yml" 8 | 9 | # This is risky if run on a non-supported platform, but the include module does not support with_first_found 10 | - include: setup-{{ ansible_os_family }}.yml 11 | -------------------------------------------------------------------------------- /tasks/sdksinstall-Darwin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install Android SDKs for applicable releases 4 | command: "{{ ansible_env.HOME }}/sdk-install.expect" 5 | # Skip linting here, because I need to implement something more sane for checking pre-installed SDKs 6 | tags: 7 | - skip_ansible_lint 8 | -------------------------------------------------------------------------------- /tasks/sdksinstall-Linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Install Android SDKs for applicable releases 4 | command: "{{ android_sdk_install_location }}/sdk-install.expect" 5 | # Skip linting here, because I need to implement something more sane for checking pre-installed SDKs 6 | tags: 7 | - skip_ansible_lint 8 | -------------------------------------------------------------------------------- /tasks/sdktools-Darwin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Put the SDK install expect script in place 4 | template: src=sdk-install.expect.j2 dest={{ ansible_env.HOME }}/sdk-install.expect mode=0755 5 | -------------------------------------------------------------------------------- /tasks/sdktools-Linux.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | - name: Ensure Android SDK tools directory exists 4 | file: path={{ android_sdk_install_location }} state=directory 5 | 6 | - name: Download Android SDK tools 7 | get_url: url={{ android_sdk_download_location }} dest={{ android_sdk_install_location }}/sdk-download.tgz 8 | 9 | - name: Extract Android SDK tools 10 | unarchive: src={{ android_sdk_install_location }}/sdk-download.tgz dest={{ android_sdk_install_location }} copy=no 11 | 12 | - name: Put the SDK install expect script in place 13 | template: src=sdk-install.expect.j2 dest={{ android_sdk_install_location }}/sdk-install.expect mode=0755 14 | 15 | - name: Change permissions on SDK tools 16 | file: path={{ android_sdk_install_location }}/android-sdk-linux recurse=yes mode=0755 17 | 18 | - name: Set system wide PATH to contain Android SDK tools 19 | 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"' 20 | when: android_sdk_update_path 21 | 22 | - name: Set system wide ANDROID_HOME environment variable 23 | lineinfile: dest=/etc/environment regexp=^ANDROID_HOME line='ANDROID_HOME="{{ android_sdk_install_location }}/android-sdk-linux/"' 24 | -------------------------------------------------------------------------------- /tasks/setup-Darwin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include: dependencies-Darwin.yml 3 | - include: sdktools-Darwin.yml 4 | - include: sdksinstall-Darwin.yml 5 | -------------------------------------------------------------------------------- /tasks/setup-Debian.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include: dependencies-Debian.yml 3 | - include: sdktools-Linux.yml 4 | - include: sdksinstall-Linux.yml 5 | -------------------------------------------------------------------------------- /tasks/setup-RedHat.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - include: dependencies-RedHat.yml 3 | - include: sdktools-Linux.yml 4 | - include: sdksinstall-Linux.yml 5 | -------------------------------------------------------------------------------- /templates/sdk-install.expect.j2: -------------------------------------------------------------------------------- 1 | #!/usr/bin/expect 2 | 3 | set timeout -1; 4 | spawn {{ android_executable }} update sdk --all -u -t "{{ (android_sdk_tools_to_install + android_sdks_to_install) | join(',') }}"; 5 | expect { 6 | "Do you accept the license" { exp_send "y\r" ; exp_continue } 7 | eof 8 | } 9 | -------------------------------------------------------------------------------- /tests/inventory: -------------------------------------------------------------------------------- 1 | localhost -------------------------------------------------------------------------------- /tests/test.yml: -------------------------------------------------------------------------------- 1 | --- 2 | - hosts: localhost 3 | remote_user: root 4 | roles: 5 | - ansible-role-android-sdk -------------------------------------------------------------------------------- /vars/Darwin.yml: -------------------------------------------------------------------------------- 1 | --- 2 | android_sdk_install_location: /usr/local/bin 3 | android_executable: "{{ android_sdk_install_location }}/android" 4 | -------------------------------------------------------------------------------- /vars/default.yml: -------------------------------------------------------------------------------- 1 | --- 2 | android_executable: "{{ android_sdk_install_location }}/android-sdk-linux/tools/android" 3 | -------------------------------------------------------------------------------- /vars/main.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # vars file for android-sdk 3 | --------------------------------------------------------------------------------