Skip to content

Instantly share code, notes, and snippets.

@varunchopra
Created February 19, 2018 15:41
Show Gist options
  • Save varunchopra/928e2dd0c58e5fdfeee967a67c08cb24 to your computer and use it in GitHub Desktop.
Save varunchopra/928e2dd0c58e5fdfeee967a67c08cb24 to your computer and use it in GitHub Desktop.
gcloud-qbittorrent
[defaults]
inventory=inventory
host_key_checking=false
[local]
localhost
[local:vars]
ansible_connection=local
---
- hosts: local
vars_files:
- /workspace/auth
tasks:
- name: "Create qbittorrent instance."
gce:
credentials_file: "{{ path_to_credentials }}"
disk_size: 200
image: ubuntu-1604
instance_names: qbittorrent-01
machine_type: f1-micro
preemptible: true
project_id: "{{ project_id }}"
service_account_email: "{{ service_account_email }}"
state: present
tags:
- http-server
zone: us-east1-b
register: qbt
- name: "Add instance to hosts."
add_host:
ansible_ssh_host: "{{ item.public_ip }}"
groups: qbittorrent
hostname: "{{ item.public_ip }}"
with_items: "{{ qbt.instance_data }}"
- name: "Wait for new VM to come up."
wait_for:
delay: 10
host: "{{ item.public_ip }}"
port: 22
timeout: 60
with_items: "{{ qbt.instance_data }}"
- become: true
hosts: qbittorrent
vars:
ansible_private_key_file: ~/.ssh/id_rsa
ansible_user: vchopra051
collect_facts: false
tasks:
- name: "Add qbittorrent ppa."
apt_repository:
repo: "ppa:qbittorrent-team/qbittorrent-stable"
update_cache: true
- name: "Update and install packages."
apt:
name: "{{ item }}"
with_items:
- apache2
- qbittorrent-nox
- screen
- name: "Copying gdrive-cli to qbt instance."
copy:
src: ./files/gdrive-linux-x64
dest: /usr/bin/gdrive
mode: +x
group: "{{ ansible_user }}"
owner: "{{ ansible_user }}"
- debug:
msg: |
"apache2, qbittorrent-nox, screen installed successfully.
qbittorrent-nox needs to be launched manually after agreeing to terms & conditions!
screen -d -m S qbt qbittorrent-nox --webui-port=52625"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment