From 2eb3dea4c112f6bd0110377f420b2a369797d862 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Thu, 28 Sep 2017 22:47:16 +0300
Subject: [PATCH] - Use flathub in Skype playbook. - Added Slack playbook
 (using flatpak from flathub). - Updated README accordingly.

---
 README.rst | 13 +++++--------
 skype.yml  |  8 +++++++-
 slack.yml  | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 9 deletions(-)
 create mode 100644 slack.yml

diff --git a/README.rst b/README.rst
index e77f3d9..dc43865 100644
--- a/README.rst
+++ b/README.rst
@@ -37,23 +37,20 @@ Configures development tools (includes the desktop and packages playbooks).
 Skype
 =====
 
-Installs the Skype Debian package since there's no repository.
+Install Skype flatpak from flathub..
 
 .. code:: shell
 
     ansible-playbook --ask-become-pass --connection local --inventory-file localhost, --verbose skype.yml
 
-Can be added as a Cron job under root for updates.
-
-.. code:: shell
-
-    ansible-playbook --connection local --inventory-file localhost, --verbose skype.yml | logger
+Slack
+=====
 
-Or maybe even (always downloads the newest version from the Git repo).
+Install Slack desktop flatpak from flathub..
 
 .. code:: shell
 
-    ansible-pull --url https://www.shore.co.il/git/ansible-desktop-playbooks --verbose skype.yml | logger
+    ansible-playbook --ask-become-pass --connection local --inventory-file localhost, --verbose slack.yml
 
 Dropbox
 =======
diff --git a/skype.yml b/skype.yml
index 0a94a96..4dc83b2 100644
--- a/skype.yml
+++ b/skype.yml
@@ -16,10 +16,16 @@
             update_cache: yes
             cache_valid_time: 3600
 
+      - name: Add Flathub repo
+        become: False
+        command: |
+            flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user
+        changed_when: False
+
       - name: Install
         become: False
         command: |
-            flatpak install --user --from https://s3.amazonaws.com/alexlarsson/skype-repo/skype.flatpakref
+            flatpak install --user flathub com.skype.Client
         register: skype_flatpak_install
         changed_when: |
             'Installing' in skype_flatpak_install.stdout
diff --git a/slack.yml b/slack.yml
new file mode 100644
index 0000000..5da5699
--- /dev/null
+++ b/slack.yml
@@ -0,0 +1,32 @@
+---
+- hosts: all
+  become: yes
+  become_user: root
+  tasks:
+      - name: Assertions
+        assert:
+          that:
+              - ansible_architecture in [ 'x86_64', 'x86' ]
+              - ansible_pkg_mgr == 'apt'
+
+      - name: APT install Flatpak
+        apt:
+            name: flatpak
+            state: present
+            update_cache: yes
+            cache_valid_time: 3600
+
+      - name: Add Flathub repo
+        become: False
+        command: |
+            flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo --user
+        changed_when: False
+
+      - name: Install
+        become: False
+        command: |
+            flatpak install --user flathub com.slack.Slack
+        register: slack_flatpak_install
+        changed_when: |
+            'Installing' in slack_flatpak_install.stdout
+        failed_when: slack_flatpak_install.rc|int > 0 and 'already installed' not in slack_flatpak_install.stderr
-- 
GitLab