From aebe90cc655ce84c69ac3be8457bf660f6a6cf8e Mon Sep 17 00:00:00 2001 From: Kevin Fenzi Date: Thu, 10 Dec 2015 22:36:13 +0000 Subject: [PATCH] Move virthost from a task to a role. Setup a variable for hosts we want nested virt enabled on (default false) add task to setup that on ones we want --- inventory/group_vars/all | 3 +++ inventory/host_vars/virthost-comm03.qa.fedoraproject.org | 1 + inventory/host_vars/virthost-comm04.qa.fedoraproject.org | 1 + playbooks/groups/virthost.yml | 2 +- roles/virthost/files/kvm_intel.conf | 1 + tasks/virthost.yml => roles/virthost/tasks/main.yml | 8 ++++++++ 6 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 roles/virthost/files/kvm_intel.conf rename tasks/virthost.yml => roles/virthost/tasks/main.yml (82%) diff --git a/inventory/group_vars/all b/inventory/group_vars/all index feff99fec2..39942c2bbc 100644 --- a/inventory/group_vars/all +++ b/inventory/group_vars/all @@ -3,6 +3,9 @@ freezes: true # most of our systems are in phx2 datacenter: phx2 +# usually we do not want to enable nested virt, only on some virthosts +nested: false + # most of our systems are 64bit. # Used to install various nagios scripts and the like. libdir: /usr/lib64 diff --git a/inventory/host_vars/virthost-comm03.qa.fedoraproject.org b/inventory/host_vars/virthost-comm03.qa.fedoraproject.org index 9342178f79..0d48fc83ec 100644 --- a/inventory/host_vars/virthost-comm03.qa.fedoraproject.org +++ b/inventory/host_vars/virthost-comm03.qa.fedoraproject.org @@ -1,3 +1,4 @@ --- # This virthost only has non release critical instances, so it doesn't freeze freezes: false +nested: true diff --git a/inventory/host_vars/virthost-comm04.qa.fedoraproject.org b/inventory/host_vars/virthost-comm04.qa.fedoraproject.org index 9342178f79..0d48fc83ec 100644 --- a/inventory/host_vars/virthost-comm04.qa.fedoraproject.org +++ b/inventory/host_vars/virthost-comm04.qa.fedoraproject.org @@ -1,3 +1,4 @@ --- # This virthost only has non release critical instances, so it doesn't freeze freezes: false +nested: true diff --git a/playbooks/groups/virthost.yml b/playbooks/groups/virthost.yml index 2fd42d28d1..5bf08ed3db 100644 --- a/playbooks/groups/virthost.yml +++ b/playbooks/groups/virthost.yml @@ -23,12 +23,12 @@ - { role: iscsi_client, when: datacenter == "phx2" } - sudo - { role: openvpn/client, when: datacenter != "phx2" } + - virthost tasks: - include: "{{ tasks }}/yumrepos.yml" - include: "{{ tasks }}/2fa_client.yml" - include: "{{ tasks }}/motd.yml" - - include: "{{ tasks }}/virthost.yml" handlers: - include: "{{ handlers }}/restart_services.yml" diff --git a/roles/virthost/files/kvm_intel.conf b/roles/virthost/files/kvm_intel.conf new file mode 100644 index 0000000000..381abf577d --- /dev/null +++ b/roles/virthost/files/kvm_intel.conf @@ -0,0 +1 @@ +nested=1 diff --git a/tasks/virthost.yml b/roles/virthost/tasks/main.yml similarity index 82% rename from tasks/virthost.yml rename to roles/virthost/tasks/main.yml index 6dc7e36723..c33018394d 100644 --- a/tasks/virthost.yml +++ b/roles/virthost/tasks/main.yml @@ -51,3 +51,11 @@ tags: - config when: ansible_distribution == 'RedHat' and ansible_distribution_major_version|int == 7 + +# +# Some virthosts we want to use nested virt (a tech preview in rhel 7.2) +# We need this module option set and then need to tweak the libvirt xml to enable it +# +- name: setup nested virt on virthosts with nested=true variable + copy: src=kvm_intel.conf dest=/etc/modprobe.d/kvm_intel.conf + when: nested is true