Skip to content

Instantly share code, notes, and snippets.

@xsgordon
Last active June 5, 2017 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save xsgordon/a0c81d7f8debac1a9b1864c16fdb0946 to your computer and use it in GitHub Desktop.
Save xsgordon/a0c81d7f8debac1a9b1864c16fdb0946 to your computer and use it in GitHub Desktop.
Playbook to enable nested virtualization for Intel CPUs on RHEL 7
# E.g. ansible-playbook nested-virt.yaml --extra-vars target=127.0.0.1
---
- hosts: "{{target}}"
tasks:
- name: Disable reverse path filtering (default)
sysctl: >
name=net.ipv4.conf.default.rp_filter
value=0
state=present
- name: Disable reverse path filtering (all)
sysctl: >
name=net.ipv4.conf.all.rp_filter
value=0
state=present
- name: Set remote file path
set_fact: remote_file_path=/etc/modprobe.d/kvm_intel.conf
- name: Create file
file: path="{{ remote_file_path }}" state=touch
- stat: path="{{ remote_file_path }}"
register: file_path
- set_fact:
file_content: |
options kvm-intel nested=1
options kvm-intel enable_shadow_vmcs=1
options kvm-intel enable_apicv=1
options kvm-intel ept=1
- copy: content="{{ file_content }}" dest="{{ remote_file_path }}"
when: file_path.stat.exists == true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment