From 287a26ccfa0bf86f17e60edee5d2efa76a28a57c Mon Sep 17 00:00:00 2001
From: Feanil Patel <feanil@edx.org>
Date: Tue, 8 Nov 2016 13:58:11 -0500
Subject: [PATCH] Make the retire-hosts job be compatible with systemd.

- Systemctl doesn't have a no-wait parameter.
- Shell instead of command to send logs to s3, command was failing on
  '||'
---
 playbooks/edx-east/retire_host.yml                   | 10 ++++++----
 playbooks/roles/edxapp/tasks/main.yml                |  2 +-
 playbooks/roles/stop_all_edx_services/tasks/main.yml |  8 ++++++++
 3 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/playbooks/edx-east/retire_host.yml b/playbooks/edx-east/retire_host.yml
index f5d7489..b6e98b5 100644
--- a/playbooks/edx-east/retire_host.yml
+++ b/playbooks/edx-east/retire_host.yml
@@ -11,9 +11,11 @@
 - name: Stop all services
   hosts: "{{TARGET}}"
   become: True
-  gather_facts: False
-  vars:
-    STOP_ALL_EDX_SERVICES_EXTRA_ARGS: "--no-wait"
+  gather_facts: True
+  pre_tasks:
+    - set_fact:
+        STOP_ALL_EDX_SERVICES_EXTRA_ARGS: "--no-wait"
+      when: ansible_distribution_release == 'precise' or ansible_distribution_release == 'trusty'
   roles:
     - stop_all_edx_services
 
@@ -23,7 +25,7 @@
   gather_facts: False
   tasks:
     - name: Terminate existing object store log sync
-      command: /usr/bin/pkill send-logs-to-object-store || true
+      shell: /usr/bin/pkill send-logs-to-object-store || true
     - name: "Ensure send-logs-to-object-store script is in the logrotate file"
       shell: grep send-logs-to-object-store /etc/logrotate.d/hourly/tracking.log
     # We only force a rotation of edx logs.
diff --git a/playbooks/roles/edxapp/tasks/main.yml b/playbooks/roles/edxapp/tasks/main.yml
index a28babf..07ffc1c 100644
--- a/playbooks/roles/edxapp/tasks/main.yml
+++ b/playbooks/roles/edxapp/tasks/main.yml
@@ -81,10 +81,10 @@
 - name: add ppas for current versions of nodejs
   apt_repository:
     repo: "{{ edxapp_chrislea_ppa }}"
+  when: ansible_distribution_release == 'precise'
   tags:
     - install
     - install:base
-  when: ansible_distribution_release == 'precise' 
     
 - name: install system packages on which LMS and CMS rely
   apt:
diff --git a/playbooks/roles/stop_all_edx_services/tasks/main.yml b/playbooks/roles/stop_all_edx_services/tasks/main.yml
index 7a8743e..814aca3 100644
--- a/playbooks/roles/stop_all_edx_services/tasks/main.yml
+++ b/playbooks/roles/stop_all_edx_services/tasks/main.yml
@@ -62,5 +62,13 @@
   notify:
     - stop mongodb
 
+- name: Stop supervisor systemd
+  stat:
+    path: /etc/systemd/system/supervisor.service
+  register: stat_out
+  changed_when: stat_out is defined and stat_out.stat.exists
+  notify:
+    - stop supervisor
+
 - shell: "true"
   notify: kill processes by user
--
libgit2 0.26.0