[libvirt-jenkins-ci PATCH 2/2] ansible: Use built-in init system detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ansible already exposes the type of init system in use through
the ansible_service_mgr fact, so we can drop our own detection.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 ansible/tasks/jenkins.yml | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/ansible/tasks/jenkins.yml b/ansible/tasks/jenkins.yml
index 563f220..9c8eda1 100644
--- a/ansible/tasks/jenkins.yml
+++ b/ansible/tasks/jenkins.yml
@@ -12,24 +12,6 @@
     owner: jenkins
     group: jenkins
 
-- name: Figure out how to start Jenkins agent
-  set_fact:
-    use_rc_local: true
-    use_systemd: false
-  when:
-    - ( os_name == 'FreeBSD' or
-        ( os_name == 'CentOS' and os_version == '6' ) or
-        ( os_name == 'Ubuntu' and os_version == '12' ) or
-        ( os_name == 'Ubuntu' and os_version == '14' ) )
-
-- name: Figure out how to start Jenkins agent
-  set_fact:
-    use_rc_local: false
-    use_systemd: true
-  when:
-    - use_rc_local is not defined
-    - use_systemd is not defined
-
 - name: Configure and enable Jenkins agent
   lineinfile:
     path: /etc/rc.local
@@ -39,14 +21,14 @@
     line: "nohup {{ sudo }} -u jenkins {{ bash }} -l -c '{{ java }} -jar /home/jenkins/slave.jar -jnlpUrl \"{{ jenkins_url }}\" -secret \"{{ jenkins_secret }}\"' >/var/log/jenkins.log 2>&1 &"
     insertbefore: '^exit .*$'
   when:
-    - use_rc_local
+    - ansible_service_mgr != 'systemd'
 
 - name: Configure Jenkins agent
   template:
     src: templates/jenkins.service.j2
     dest: /etc/systemd/system/jenkins.service
   when:
-    - use_systemd
+    - ansible_service_mgr == 'systemd'
 
 - name: Enable Jenkins agent
   systemd:
@@ -54,4 +36,4 @@
     enabled: yes
     daemon_reload: yes
   when:
-    - use_systemd
+    - ansible_service_mgr == 'systemd'
-- 
2.13.6

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux