From 227a49fdf7eb6028f5397544c89e5e2f7cb7292a Mon Sep 17 00:00:00 2001 From: edgewood Date: Mon, 10 Sep 2018 05:36:05 -0400 Subject: [PATCH] Use Dropbox's repo to install on Debian-family distributions (#1) * Remove trailing whitespace * Use ansible_os_family for Debian/Ubuntu detection Use ansible_os_family == "Debian" instead of testing ansible_distribution against "Debian" and "Ubuntu". * Use Dropbox's repo to install on Debian-family distributions Dropbox provides an apt repository for Debian and Ubuntu. Use it to install dropbox instead. Fall back to curl pipeline install for everything else. Name the control script 'dropbox' on non-apt installs to match the name of the script installed through apt. --- defaults/main.yml | 3 +++ tasks/dropbox.yml | 38 ++++++++++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index ecd8399..047bd98 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -14,6 +14,9 @@ dropbox_user_directory: "{{ dropbox_owner_home }}/Dropbox" dropbox_user_host : "1234567890" dropbox_utilities_enabled : yes +dropbox_apt_repo: ubuntu +dropbox_apt_release: xenial + docker_files_generated_directory: "./" docker_files_enable: no docker_volume_directory: "{{ dropbox_owner_home }}" diff --git a/tasks/dropbox.yml b/tasks/dropbox.yml index 1ad0acc..61c1d55 100644 --- a/tasks/dropbox.yml +++ b/tasks/dropbox.yml @@ -28,7 +28,7 @@ group="{{ dropbox_group }}" tags: dropbox_setup ignore_errors: true - + - name: dropbox | Add dropbox configuration. template: src: "info.json.j2" @@ -39,12 +39,34 @@ ignore_errors: true # notify: restart dropbox -- name: dropbox | Install Dropbox control script - get_url: dest=/usr/local/bin/dropbox.py url=https://www.dropbox.com/download?dl=packages/dropbox.py mode=0755 validate_certs=no +- block: # block for installing on Debian derivitives + - name: dropbox | Install Dropbox key + apt_key: + keyserver: pgp.mit.edu + id: 1C61A2656FB57B7E4DE0F4C1FC918B335044912E + + - name: dropbox | Install Dropbox repository + apt_repository: + repo: deb [arch=i386,amd64] http://linux.dropbox.com/{{ dropbox_apt_repo }} {{ dropbox_apt_release }} main + state: present + filename: dropbox + + - name: dropbox | Install Dropbox + apt: + name: dropbox + state: present + become: yes + when: ansible_os_family == 'Debian' + +- block: # block for installing on other Linux + - name: dropbox | Install Dropbox control script + get_url: dest=/usr/local/bin/dropbox url=https://www.dropbox.com/download?dl=packages/dropbox.py mode=0755 validate_certs=no + become: yes -- name: dropbox | Install Dropbox - shell: curl -L "https://www.dropbox.com/download?plat=lnx.{{ ansible_architecture }}" | tar -C $HOME -xzf - creates={{ dropbox_owner_home }}/.dropbox-dist/dropboxd + - name: dropbox | Install Dropbox + shell: curl -L "https://www.dropbox.com/download?plat=lnx.{{ ansible_architecture }}" | tar -C $HOME -xzf - creates={{ dropbox_owner_home }}/.dropbox-dist/dropboxd + when: ansible_os_family != 'Debian' - name: dropbox | Configure KDE to autostart dropboxd file: path={{ dropbox_owner_home }}/.kde/Autostart/dropboxd src={{ dropbox_owner_home }}/.dropbox-dist/dropboxd state=link @@ -53,16 +75,16 @@ - name: dropbox | Install dropbox utilities apt: pkg={{ item }} state=present update_cache=yes become: yes - when: (ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu') and dropbox_utilities_enabled + when: ansible_os_family == 'Debian' and dropbox_utilities_enabled tags: package with_items: - nautilus-dropbox - libappindicator1 - name: dropbox | Check dropboxd status - command: /usr/local/bin/dropbox.py status + command: dropbox status register: status - name: dropbox | Start dropboxd - shell: /usr/local/bin/dropbox.py start >/dev/null 2>&1 + shell: dropbox start >/dev/null 2>&1 when: status.stdout == "Dropbox isn't running!"