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

Andrea Bolognani abologna at redhat.com
Wed Oct 11 08:52:18 UTC 2017


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 at redhat.com>
---
 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




More information about the libvir-list mailing list