]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
ansible: Support centos static libvirt slaves
authorDavid Galloway <dgallowa@redhat.com>
Tue, 10 Oct 2017 18:27:08 +0000 (14:27 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Tue, 10 Oct 2017 18:46:27 +0000 (14:46 -0400)
Signed-off-by: David Galloway <dgallowa@redhat.com>
ansible/examples/slave_libvirt_static.yml
scripts/build_utils.sh

index 2edd2279a4d9d0504ad8c426e9d5d7677016a9ae..58818f563ba5157c71f2c4a5e09473bb23ea71e0 100644 (file)
@@ -1,6 +1,6 @@
 ---
 # This playbook is used to configure static libvirt&&vagrant slaves.
-# Ubuntu Xenial or Yakkety are the only supported distros at this time
+# Ubuntu >= 16.04 and CentOS 7.3 are the only tested distros
 #
 # Example usage:
 # On a baremetal node already configured by the github.com/ceph/ceph-cm-ansible common role,
 
   tasks:
 
-    - name: Fail if slave is not running Xenial or Yakkety
-      fail:
-        msg: "Slave is not running Xenial or Yakkety"
-      when: ansible_distribution != "Ubuntu" or
-            (ansible_distribution == "Ubuntu" and ansible_distribution_major_version < 16)
-
+    ### REPO TASKS ###
     - name: Check for custom repos
       shell: "ls -1 /etc/apt/sources.list.d"
       register: custom_repos
+      when: ansible_os_family == "Debian"
 
     - name: Delete custom repos
       file:
         path: "/etc/apt/sources.list.d/{{ item }}"
         state: absent
       with_items: "{{ custom_repos.stdout_lines }}"
-      when: custom_repos|length > 0
+      when:
+        - custom_repos|length > 0
+        - custom_repos is defined
+        - ansible_os_family == "Debian"
 
     - name: Update apt cache
       apt:
         update_cache: yes
+      when: ansible_os_family == "Debian"
 
     # vagrant doesn't have repositories, this chacra repo will be better to have
     # around and can get updates as soon as a new vagrant version is published via
       apt_repository:
         repo: "deb [trusted=yes] https://chacra.ceph.com/r/vagrant/latest/HEAD/ubuntu/xenial/flavors/default/ xenial main"
         state: present
+      when: ansible_os_family == "Debian"
+
+    - name: add the vagrant repository
+      yum_repository:
+        name: vagrant
+        description: self-hosted vagrant repo
+        baseurl: https://chacra.ceph.com/r/vagrant/latest/HEAD/centos/7/flavors/default/x86_64/
+        enabled: yes
+        gpgcheck: no
+      when: ansible_os_family == "RedHat"
 
+    - name: disable epel
+      lineinfile:
+        path: "/etc/yum.repos.d/epel.repo"
+        regexp: '^enabled=.*'
+        line: 'enabled=0'
+      when: ansible_os_family == "RedHat"
+
+    ### PACKAGING TASKS ###
     - name: Update apt cache
       apt:
         update_cache: yes
+      when: ansible_os_family == "Debian"
 
     - name: Install required packages
       apt:
         - vagrant
         - default-jdk
         - default-jre
+      when: ansible_os_family == "Debian"
+
+    - name: install requirements without epel
+      yum:
+        name: "{{ item }}"
+        state: present
+        disablerepo: epel
+        update_cache: yes
+      with_items:
+        - git
+        - gcc
+        - python-devel
+        - libffi-devel
+        - java-1.8.0-openjdk-devel
+        - qemu-kvm
+        - libvirt-devel
+        - libguestfs
+        - libvirt
+        - libguestfs-tools
+        - vagrant
+        - wget
+        - curl
+        - python-virtualenv
+        - openssl-devel
+        - redhat-lsb-core
+      when: ansible_os_family == "RedHat"
 
+    - name: install packages from epel
+      yum:
+        name: "{{ item }}"
+        state: present
+        enablerepo: epel
+        update_cache: yes
+      with_items:
+        - jq
+        - python-pip
+      when: ansible_os_family == "RedHat"
+
+    ### COMMON TASKS ###
     - set_fact:
         jenkins_group: 'libvirtd'
       when: ansible_distribution_version == '16.04'
     - set_fact:
         jenkins_group: 'libvirt'
       when: (ansible_distribution_version == '16.10') or
-            (ansible_distribution_major_version >= 17)
+            (ansible_distribution_major_version >= 17) or
+            (ansible_os_family == "RedHat")
 
     - name: "create a {{ jenkins_user }} user"
       user:
         # github.com.pub is the output of `ssh-keyscan github.com`
         key: "{{ lookup('file', 'files/ssh/hostkeys/github.com.pub') }}"
 
-    - name: start the libvirt-bin service
+    ### LIBVIRT TASKS ###
+    - name: "configure libvirt permissions for {{ jenkins_user }}"
+      blockinfile:
+        dest: /etc/libvirt/qemu.conf
+        block: |
+          user = "{{ jenkins_user }}"
+          group = "{{ jenkins_user }}"
+      when: ansible_os_family == "RedHat"
+
+    - name: start DEB libvirt services
       service:
-        name: libvirt-bin
-        state: started
+        name: "{{ item }}"
+        state: restarted
+      with_items:
+        - libvirt-bin
+        - libvirt-guests
+      when: ansible_os_family == "Debian"
 
-    - name: start the libvirt-guests service
+    - name: start RPM libvirt services
       service:
-        name: libvirt-guests
-        state: started
+        name: "{{ item }}"
+        state: restarted
+      with_items:
+        - libvirtd
+        - libvirt-guests
+      when: ansible_os_family == "RedHat"
 
+    ### JENKINS TASKS ###
     - name: register the new slave to jenkins master with jnlp
       jenkins_node:
         username: "{{ api_user }}"
index 42984815b145eab474077e05280841edf003b171..06f717000648e6f55c7d349fbd0dbdce87667e03 100644 (file)
@@ -436,7 +436,12 @@ clear_libvirt_networks() {
 
 restart_libvirt_services() {
     # restart libvirt services
-    sudo service libvirt-bin restart
+    get_distro_and_target
+    if [ "$DISTRO" == "rhel" ] || [ "$DISTRO" == "centos" ]; then
+        sudo service libvirtd restart
+    else
+        sudo service libvirt-bin restart
+    fi
     sudo service libvirt-guests restart
 }