Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ A web-based UI for running playbooks is available via [Ansible Semaphore](https:
├── list.yml # Main playbook for listing VMs
├── install-engine.yml # Main playbook for installing Orka Engine
├── install_android_sdk.yml # Main playbook for installing Android SDK
├── uninstall_android_sdk.yml # Main playbook for uninstalling Android SDK and tooling
├── sdkmanager_install.yml # Main playbook for installing Android SDK platforms and system images
├── sdkmanager_uninstall.yml # Main playbook for uninstalling Android SDK platforms and system images
├── deploy_avd.yml # Main playbook for creating and running Android Virtual Devices
Expand Down Expand Up @@ -90,22 +91,60 @@ where:

#### Install Android SDK

To install the Android SDK (including Java JDK, command-line tools, and platform-tools) on target hosts:
To install the Android SDK and AVD runtime tooling on target hosts:

```bash
ansible-playbook install_android_sdk.yml -i dev/inventory
```

This will:

- Install Homebrew (if not already present) and ensure `brew shellenv` is loaded in `.zprofile`
- Install Eclipse Temurin JDK 21 (if not already present)
- Download and set up Android command-line tools
- Download and set up Android command-line tools at `/opt/android-sdk/cmdline-tools/latest/`
- Accept Android SDK licenses
- Install base SDK packages
- Install base SDK packages (`platform-tools`, `emulator`)
- Configure `JAVA_HOME`, `ANDROID_HOME`, and `PATH` in the user's `.zshrc`
- Install `socat` via Homebrew (used to relay ADB connections to AVDs)
- Create `/opt/orka/bin/` and `/opt/orka/logs/avd/` directories
- Install the `run-avd` script at `/opt/orka/bin/run-avd`

**Note** - To force reinstallation pass `-e "install_android_sdk_force=true"`.

#### Uninstall Android SDK

To remove the Android SDK and AVD runtime tooling from target hosts. This is the inverse of `install_android_sdk.yml`:

```bash
ansible-playbook uninstall_android_sdk.yml -i dev/inventory
```

By default this will:

- Remove the `run-avd` script at `/opt/orka/bin/run-avd`
- Remove the AVD log directory at `/opt/orka/logs/avd/`
- Remove the Android SDK directory at `/opt/android-sdk` along with the `JAVA_HOME` / `ANDROID_HOME` / `PATH` block from the user's `.zshrc`
- Remove the Eclipse Temurin JDK 21 installation

`socat` and Homebrew are left in place by default since both may be used by other tooling on the host. Pass the relevant variables to remove them as well (see below).

Optional variables (all booleans):

- `uninstall_android_sdk_run_avd` (default `true`) — remove the `run-avd` script
- `uninstall_android_sdk_orka_dirs` (default `true`) — remove `/opt/orka/logs/avd/`
- `uninstall_android_sdk_sdk_directory` (default `true`) — remove `/opt/android-sdk` and the `ANDROID SDK` block from `.zshrc`
- `uninstall_android_sdk_java` (default `true`) — remove the Temurin JDK 21 installation
- `uninstall_android_sdk_socat` (default `false`) — uninstall `socat` via Homebrew
- `uninstall_android_sdk_homebrew` (default `false`) — uninstall Homebrew itself

Example removing everything including shared tooling:

```bash
ansible-playbook uninstall_android_sdk.yml -i dev/inventory \
-e "uninstall_android_sdk_socat=true" \
-e "uninstall_android_sdk_homebrew=true"
```

#### Install Android SDK Platforms and System Images

To install an Android SDK platform and its system images on target hosts:
Expand Down
11 changes: 11 additions & 0 deletions roles/uninstall_android_sdk/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
uninstall_android_sdk_run_avd: true
uninstall_android_sdk_orka_dirs: true
uninstall_android_sdk_sdk_directory: true
uninstall_android_sdk_java: true
uninstall_android_sdk_socat: false
uninstall_android_sdk_homebrew: false
uninstall_android_sdk_run_avd_path: "/opt/orka/bin/run-avd"
uninstall_android_sdk_orka_log_path: "/opt/orka/logs/avd"
uninstall_android_sdk_home: "/opt/android-sdk"
uninstall_android_sdk_java_home: "/Library/Java/JavaVirtualMachines/temurin-21.jre"
57 changes: 57 additions & 0 deletions roles/uninstall_android_sdk/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
- name: Remove run-avd script
become: true
ansible.builtin.file:
path: "{{ uninstall_android_sdk_run_avd_path }}"
state: absent
when: uninstall_android_sdk_run_avd | bool

- name: Remove orka log directory
become: true
ansible.builtin.file:
path: "{{ uninstall_android_sdk_orka_log_path }}"
state: absent
when: uninstall_android_sdk_orka_dirs | bool

- name: Uninstall socat
community.general.homebrew:
path: /opt/homebrew/bin
name: socat
state: absent
when: uninstall_android_sdk_socat | bool

- name: Remove Android SDK directory
become: true
ansible.builtin.file:
path: "{{ uninstall_android_sdk_home }}"
state: absent
when: uninstall_android_sdk_sdk_directory | bool

- name: Remove ANDROID SDK block from shell profile
ansible.builtin.blockinfile:
path: "/Users/{{ ansible_user }}/.zshrc"
marker: "# {mark} ANDROID SDK"
state: absent
when: uninstall_android_sdk_sdk_directory | bool

- name: Remove Java JDK
become: true
ansible.builtin.file:
path: "{{ uninstall_android_sdk_java_home }}"
state: absent
when: uninstall_android_sdk_java | bool

- name: Uninstall Homebrew
ansible.builtin.shell:
cmd: |
NONINTERACTIVE=1 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
args:
removes: /opt/homebrew/bin/brew
when: uninstall_android_sdk_homebrew | bool

- name: Remove brew shellenv from zprofile
ansible.builtin.lineinfile:
path: "{{ ansible_env.HOME }}/.zprofile"
line: 'eval "$(/opt/homebrew/bin/brew shellenv)"'
state: absent
when: uninstall_android_sdk_homebrew | bool
17 changes: 17 additions & 0 deletions uninstall_android_sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Uninstall Android SDK and tools from target hosts
hosts: hosts
gather_facts: false
module_defaults:
ansible.builtin.setup:
gather_timeout: 20
pre_tasks:
- name: Gather minimal facts
ansible.builtin.setup:
filter:
- "ansible_env"
- "ansible_user_gid"
tags:
- always
roles:
- role: uninstall_android_sdk
Loading