This commit adds just enough to bootstrap Jenkins workers and install packages required to build any project, such as gcc and make. Ubuntu 12-16 are supported, even though they're not actually used in libvirt CI, because there's a lot of overlap between this and Travis CI, which only supports Ubuntu instead. Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- ansible/.gitignore | 3 + ansible/Makefile | 12 ++++ ansible/ansible.cfg | 8 +++ ansible/bootstrap.yml | 17 +++++ ansible/group_vars/all/main.yml | 8 +++ ansible/host_vars/libvirt-centos-6/main.yml | 3 + ansible/host_vars/libvirt-centos-7/main.yml | 3 + ansible/host_vars/libvirt-debian-8/main.yml | 3 + ansible/host_vars/libvirt-debian-9/main.yml | 3 + ansible/host_vars/libvirt-fedora-25/main.yml | 3 + ansible/host_vars/libvirt-fedora-26/main.yml | 3 + ansible/host_vars/libvirt-fedora-rawhide/main.yml | 3 + ansible/host_vars/libvirt-freebsd-11/main.yml | 10 +++ ansible/host_vars/libvirt-ubuntu-12/main.yml | 3 + ansible/host_vars/libvirt-ubuntu-14/main.yml | 3 + ansible/host_vars/libvirt-ubuntu-16/main.yml | 3 + ansible/inventory | 8 +++ ansible/site.yml | 17 +++++ ansible/tasks/base.yml | 77 +++++++++++++++++++++++ ansible/tasks/bootstrap.yml | 22 +++++++ ansible/tasks/facts.yml | 14 +++++ ansible/tasks/packages.yml | 11 ++++ ansible/vars/base/CentOS-6.yml | 13 ++++ ansible/vars/base/CentOS-7.yml | 13 ++++ ansible/vars/base/Debian-8.yml | 14 +++++ ansible/vars/base/Debian-9.yml | 14 +++++ ansible/vars/base/Fedora-25.yml | 15 +++++ ansible/vars/base/Fedora-26.yml | 15 +++++ ansible/vars/base/Fedora-Rawhide.yml | 15 +++++ ansible/vars/base/FreeBSD-11.yml | 11 ++++ ansible/vars/base/Ubuntu-12.yml | 13 ++++ ansible/vars/base/Ubuntu-14.yml | 13 ++++ ansible/vars/base/Ubuntu-16.yml | 14 +++++ 33 files changed, 387 insertions(+) create mode 100644 ansible/.gitignore create mode 100644 ansible/Makefile create mode 100644 ansible/ansible.cfg create mode 100644 ansible/bootstrap.yml create mode 100644 ansible/group_vars/all/main.yml create mode 100644 ansible/host_vars/libvirt-centos-6/main.yml create mode 100644 ansible/host_vars/libvirt-centos-7/main.yml create mode 100644 ansible/host_vars/libvirt-debian-8/main.yml create mode 100644 ansible/host_vars/libvirt-debian-9/main.yml create mode 100644 ansible/host_vars/libvirt-fedora-25/main.yml create mode 100644 ansible/host_vars/libvirt-fedora-26/main.yml create mode 100644 ansible/host_vars/libvirt-fedora-rawhide/main.yml create mode 100644 ansible/host_vars/libvirt-freebsd-11/main.yml create mode 100644 ansible/host_vars/libvirt-ubuntu-12/main.yml create mode 100644 ansible/host_vars/libvirt-ubuntu-14/main.yml create mode 100644 ansible/host_vars/libvirt-ubuntu-16/main.yml create mode 100644 ansible/inventory create mode 100644 ansible/site.yml create mode 100644 ansible/tasks/base.yml create mode 100644 ansible/tasks/bootstrap.yml create mode 100644 ansible/tasks/facts.yml create mode 100644 ansible/tasks/packages.yml create mode 100644 ansible/vars/base/CentOS-6.yml create mode 100644 ansible/vars/base/CentOS-7.yml create mode 100644 ansible/vars/base/Debian-8.yml create mode 100644 ansible/vars/base/Debian-9.yml create mode 100644 ansible/vars/base/Fedora-25.yml create mode 100644 ansible/vars/base/Fedora-26.yml create mode 100644 ansible/vars/base/Fedora-Rawhide.yml create mode 100644 ansible/vars/base/FreeBSD-11.yml create mode 100644 ansible/vars/base/Ubuntu-12.yml create mode 100644 ansible/vars/base/Ubuntu-14.yml create mode 100644 ansible/vars/base/Ubuntu-16.yml diff --git a/ansible/.gitignore b/ansible/.gitignore new file mode 100644 index 0000000..4a271f2 --- /dev/null +++ b/ansible/.gitignore @@ -0,0 +1,3 @@ +*.retry +*.swp +log diff --git a/ansible/Makefile b/ansible/Makefile new file mode 100644 index 0000000..39ebe52 --- /dev/null +++ b/ansible/Makefile @@ -0,0 +1,12 @@ +all: + +site: + @ansible-playbook site.yml + +bootstrap: + @ansible-playbook --ask-pass bootstrap.yml + +clean: + @rm -f *.retry log + +.PHONY: all site bootstrap clean diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..ca02677 --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,8 @@ +[defaults] +display_skipped_hosts = False +forks = 16 +inventory = ./inventory +log_path = ./log +nocows = 1 +pipelining = True +squash_actions = package diff --git a/ansible/bootstrap.yml b/ansible/bootstrap.yml new file mode 100644 index 0000000..67c359d --- /dev/null +++ b/ansible/bootstrap.yml @@ -0,0 +1,17 @@ +--- +- hosts: all + gather_facts: no + + tasks: + + # Bootstrap Ansible itself + - include: tasks/bootstrap.yml + + +- hosts: all + + tasks: + + # Prepare the base environment + - include: tasks/facts.yml + - include: tasks/base.yml diff --git a/ansible/group_vars/all/main.yml b/ansible/group_vars/all/main.yml new file mode 100644 index 0000000..e8d3cb6 --- /dev/null +++ b/ansible/group_vars/all/main.yml @@ -0,0 +1,8 @@ +--- +ansible_user: root + +# Paths to various command. Can be overridden on a per-host basis +bash: /bin/bash +java: /usr/bin/java +make: /usr/bin/make +sudo: /usr/bin/sudo diff --git a/ansible/host_vars/libvirt-centos-6/main.yml b/ansible/host_vars/libvirt-centos-6/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-centos-6/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-centos-7/main.yml b/ansible/host_vars/libvirt-centos-7/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-centos-7/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-debian-8/main.yml b/ansible/host_vars/libvirt-debian-8/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-debian-8/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-debian-9/main.yml b/ansible/host_vars/libvirt-debian-9/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-debian-9/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-fedora-25/main.yml b/ansible/host_vars/libvirt-fedora-25/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-fedora-25/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-fedora-26/main.yml b/ansible/host_vars/libvirt-fedora-26/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-fedora-26/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-fedora-rawhide/main.yml b/ansible/host_vars/libvirt-fedora-rawhide/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-fedora-rawhide/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-freebsd-11/main.yml b/ansible/host_vars/libvirt-freebsd-11/main.yml new file mode 100644 index 0000000..d405d58 --- /dev/null +++ b/ansible/host_vars/libvirt-freebsd-11/main.yml @@ -0,0 +1,10 @@ +--- +ansible_python_interpreter: /usr/local/bin/python2 + +bash: /usr/local/bin/bash +java: /usr/local/bin/java +make: /usr/local/bin/gmake +sudo: /usr/local/bin/sudo + +projects: + - base diff --git a/ansible/host_vars/libvirt-ubuntu-12/main.yml b/ansible/host_vars/libvirt-ubuntu-12/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-ubuntu-12/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-ubuntu-14/main.yml b/ansible/host_vars/libvirt-ubuntu-14/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-ubuntu-14/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/host_vars/libvirt-ubuntu-16/main.yml b/ansible/host_vars/libvirt-ubuntu-16/main.yml new file mode 100644 index 0000000..1602406 --- /dev/null +++ b/ansible/host_vars/libvirt-ubuntu-16/main.yml @@ -0,0 +1,3 @@ +--- +projects: + - base diff --git a/ansible/inventory b/ansible/inventory new file mode 100644 index 0000000..3becfa0 --- /dev/null +++ b/ansible/inventory @@ -0,0 +1,8 @@ +libvirt-centos-7 +libvirt-centos-6 +libvirt-debian-9 +libvirt-debian-8 +libvirt-fedora-rawhide +libvirt-fedora-26 +libvirt-fedora-25 +libvirt-freebsd-11 diff --git a/ansible/site.yml b/ansible/site.yml new file mode 100644 index 0000000..27af6de --- /dev/null +++ b/ansible/site.yml @@ -0,0 +1,17 @@ +--- +- hosts: all + + tasks: + + # Prepare the base environment + - include: tasks/facts.yml + - include: tasks/base.yml + + # Install build dependencies for each project + - include: tasks/packages.yml + with_items: + '{{ projects }}' + loop_control: + loop_var: project + when: + - projects is defined diff --git a/ansible/tasks/base.yml b/ansible/tasks/base.yml new file mode 100644 index 0000000..989c5a6 --- /dev/null +++ b/ansible/tasks/base.yml @@ -0,0 +1,77 @@ +--- +- name: Bootstrap the package module + command: dnf install -y python2-dnf + args: + creates: /usr/lib*/python2*/*-packages/dnf + when: + - os_name == 'Fedora' + +- name: Bootstrap the package module + command: apt-get install -y python-apt + args: + creates: /usr/lib/python2*/*-packages/apt + when: + - ( os_name == 'Debian' or + os_name == 'Ubuntu' ) + +- name: Update installed packages + package: + name: '*' + state: latest + when: + - ( os_name == 'CentOS' or + os_name == 'Fedora' ) + +- name: Update installed packages + apt: + upgrade: dist + update_cache: yes + when: + - ( os_name == 'Debian' or + os_name == 'Ubuntu' ) + +- name: Update installed packages + shell: pkg update && pkg upgrade -y + when: + - os_name == 'FreeBSD' + +- name: Install base packages + package: + name: '{{ item }}' + state: present + with_items: + - bash + - git + - screen + - sudo + - vim + +- name: Remove unwanted packages + package: + name: '{{ item }}' + state: absent + with_items: + - nano + +- name: Permit file editing on SELinux-enabled systems + package: + name: libselinux-python + state: present + when: + - ( os_name == 'CentOS' or + os_name == 'Fedora' ) + +- name: Configure hostname + hostname: + name: '{{ inventory_hostname }}' + +- name: Configure root shell + user: + name: root + shell: '{{ bash }}' + +- name: Configure ssh access for the root user + authorized_key: + user: root + key: '{{ lookup("file", lookup("env", "HOME") + "/.ssh/id_rsa.pub") }}' + state: present diff --git a/ansible/tasks/bootstrap.yml b/ansible/tasks/bootstrap.yml new file mode 100644 index 0000000..24848c8 --- /dev/null +++ b/ansible/tasks/bootstrap.yml @@ -0,0 +1,22 @@ +--- +- name: Bootstrap the pkgng package manager + raw: env ASSUME_ALWAYS_YES=YES pkg bootstrap + when: + - inventory_hostname|search('freebsd') + +- name: Bootstrap Ansible + raw: yum install -y python2 + when: + - ( inventory_hostname|search('centos') or + inventory_hostname|search('fedora') ) + +- name: Bootstrap Ansible + raw: apt-get install -y python + when: + - ( inventory_hostname|search('debian') or + inventory_hostname|search('ubuntu') ) + +- name: Bootstrap Ansible + raw: pkg install -y python2 + when: + - inventory_hostname|search('freebsd') diff --git a/ansible/tasks/facts.yml b/ansible/tasks/facts.yml new file mode 100644 index 0000000..223aa1e --- /dev/null +++ b/ansible/tasks/facts.yml @@ -0,0 +1,14 @@ +--- +- name: Set additional facts + set_fact: + os_name: '{{ ansible_distribution }}' + os_version: '{{ ansible_distribution_major_version }}' + when: + - ansible_distribution_release != 'Rawhide' + +- name: Set additional facts + set_fact: + os_name: '{{ ansible_distribution }}' + os_version: Rawhide + when: + - ansible_distribution_release == 'Rawhide' diff --git a/ansible/tasks/packages.yml b/ansible/tasks/packages.yml new file mode 100644 index 0000000..630d794 --- /dev/null +++ b/ansible/tasks/packages.yml @@ -0,0 +1,11 @@ +--- +- name: '{{ project }}: Load variables' + include_vars: + file: 'vars/{{ project }}/{{ os_name }}-{{ os_version }}.yml' + +- name: '{{ project }}: Install packages' + package: + name: '{{ item }}' + state: present + with_items: + '{{ packages }}' diff --git a/ansible/vars/base/CentOS-6.yml b/ansible/vars/base/CentOS-6.yml new file mode 100644 index 0000000..b107a8f --- /dev/null +++ b/ansible/vars/base/CentOS-6.yml @@ -0,0 +1,13 @@ +--- +packages: + - autoconf + - automake + - gcc + - gettext + - gettext-devel + - glibc-devel + - libtool + - make + - patch + - pkgconfig + - rpm-build diff --git a/ansible/vars/base/CentOS-7.yml b/ansible/vars/base/CentOS-7.yml new file mode 100644 index 0000000..b107a8f --- /dev/null +++ b/ansible/vars/base/CentOS-7.yml @@ -0,0 +1,13 @@ +--- +packages: + - autoconf + - automake + - gcc + - gettext + - gettext-devel + - glibc-devel + - libtool + - make + - patch + - pkgconfig + - rpm-build diff --git a/ansible/vars/base/Debian-8.yml b/ansible/vars/base/Debian-8.yml new file mode 100644 index 0000000..b36ade7 --- /dev/null +++ b/ansible/vars/base/Debian-8.yml @@ -0,0 +1,14 @@ +--- +packages: + - autoconf + - automake + - autopoint + - ccache + - gcc + - gettext + - libc6-dev + - libtool + - libtool-bin + - make + - patch + - pkgconf diff --git a/ansible/vars/base/Debian-9.yml b/ansible/vars/base/Debian-9.yml new file mode 100644 index 0000000..b36ade7 --- /dev/null +++ b/ansible/vars/base/Debian-9.yml @@ -0,0 +1,14 @@ +--- +packages: + - autoconf + - automake + - autopoint + - ccache + - gcc + - gettext + - libc6-dev + - libtool + - libtool-bin + - make + - patch + - pkgconf diff --git a/ansible/vars/base/Fedora-25.yml b/ansible/vars/base/Fedora-25.yml new file mode 100644 index 0000000..733efa8 --- /dev/null +++ b/ansible/vars/base/Fedora-25.yml @@ -0,0 +1,15 @@ +--- +packages: + - autoconf + - automake + - ccache + - cppi + - gcc + - gettext + - gettext-devel + - glibc-devel + - libtool + - make + - patch + - pkgconfig + - rpm-build diff --git a/ansible/vars/base/Fedora-26.yml b/ansible/vars/base/Fedora-26.yml new file mode 100644 index 0000000..733efa8 --- /dev/null +++ b/ansible/vars/base/Fedora-26.yml @@ -0,0 +1,15 @@ +--- +packages: + - autoconf + - automake + - ccache + - cppi + - gcc + - gettext + - gettext-devel + - glibc-devel + - libtool + - make + - patch + - pkgconfig + - rpm-build diff --git a/ansible/vars/base/Fedora-Rawhide.yml b/ansible/vars/base/Fedora-Rawhide.yml new file mode 100644 index 0000000..733efa8 --- /dev/null +++ b/ansible/vars/base/Fedora-Rawhide.yml @@ -0,0 +1,15 @@ +--- +packages: + - autoconf + - automake + - ccache + - cppi + - gcc + - gettext + - gettext-devel + - glibc-devel + - libtool + - make + - patch + - pkgconfig + - rpm-build diff --git a/ansible/vars/base/FreeBSD-11.yml b/ansible/vars/base/FreeBSD-11.yml new file mode 100644 index 0000000..e8c6315 --- /dev/null +++ b/ansible/vars/base/FreeBSD-11.yml @@ -0,0 +1,11 @@ +--- +packages: + - autoconf + - automake + - ccache + - cppi + - gettext + - gettext-tools + - gmake + - libtool + - pkgconf diff --git a/ansible/vars/base/Ubuntu-12.yml b/ansible/vars/base/Ubuntu-12.yml new file mode 100644 index 0000000..3b87b33 --- /dev/null +++ b/ansible/vars/base/Ubuntu-12.yml @@ -0,0 +1,13 @@ +--- +packages: + - autoconf + - automake + - autopoint + - ccache + - gcc + - gettext + - libc6-dev + - libtool + - make + - patch + - pkg-config diff --git a/ansible/vars/base/Ubuntu-14.yml b/ansible/vars/base/Ubuntu-14.yml new file mode 100644 index 0000000..da5a6ff --- /dev/null +++ b/ansible/vars/base/Ubuntu-14.yml @@ -0,0 +1,13 @@ +--- +packages: + - autoconf + - automake + - autopoint + - ccache + - gcc + - gettext + - libc6-dev + - libtool + - make + - patch + - pkgconf diff --git a/ansible/vars/base/Ubuntu-16.yml b/ansible/vars/base/Ubuntu-16.yml new file mode 100644 index 0000000..b36ade7 --- /dev/null +++ b/ansible/vars/base/Ubuntu-16.yml @@ -0,0 +1,14 @@ +--- +packages: + - autoconf + - automake + - autopoint + - ccache + - gcc + - gettext + - libc6-dev + - libtool + - libtool-bin + - make + - patch + - pkgconf -- 2.13.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list