[libvirt] [libvirt-jenkins-ci PATCH 02/18] ansible: Add initial support for building projects

Andrea Bolognani abologna at redhat.com
Mon Oct 2 15:10:40 UTC 2017


Building projects is entirely controlled by Jenkins in a production
environment, but it can be useful to trigger builds via Ansible
during development to figure out build dependencies and for sanity
checking purposes.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 ansible/group_vars/all/main.yml |  8 ++++++++
 ansible/site.yml                | 12 ++++++++++++
 ansible/tasks/build.yml         | 14 ++++++++++++++
 3 files changed, 34 insertions(+)
 create mode 100644 ansible/tasks/build.yml

diff --git a/ansible/group_vars/all/main.yml b/ansible/group_vars/all/main.yml
index e8d3cb6..cd97458 100644
--- a/ansible/group_vars/all/main.yml
+++ b/ansible/group_vars/all/main.yml
@@ -6,3 +6,11 @@ bash: /bin/bash
 java: /usr/bin/java
 make: /usr/bin/make
 sudo: /usr/bin/sudo
+
+# Wether to build software. While this is useful for figuring out build
+# dependencies, it should not be turned on in production because it causes
+# extra packages to be installed, which can interfere with the CI jobs
+build: false
+
+# How many parallel jobs to use when building software
+smp: 3
diff --git a/ansible/site.yml b/ansible/site.yml
index 27af6de..4603a59 100644
--- a/ansible/site.yml
+++ b/ansible/site.yml
@@ -15,3 +15,15 @@
         loop_var: project
       when:
         - projects is defined
+
+    - include: tasks/build.yml
+      with_items:
+        '{{ projects }}'
+      loop_control:
+        loop_var: project
+      when:
+        - projects is defined
+        # base is a pseudo-projects
+        - project != 'base'
+        # Building can be turned on and off
+        - build
diff --git a/ansible/tasks/build.yml b/ansible/tasks/build.yml
new file mode 100644
index 0000000..edb0064
--- /dev/null
+++ b/ansible/tasks/build.yml
@@ -0,0 +1,14 @@
+---
+- name: '{{ project }}: Load variables'
+  include_vars:
+    file: 'vars/{{ project }}/{{ os_name }}-{{ os_version }}.yml'
+
+- name: '{{ project }}: Drop local changes'
+  command: git reset --hard
+  args:
+    chdir: '{{ project }}'
+
+- name: '{{ project }}: Clean up'
+  command: git clean -xdf
+  args:
+    chdir: '{{ project }}'
-- 
2.13.6




More information about the libvir-list mailing list