---
- hosts: localhost
tasks:
+ - yum:
+ name: "{{ item }}"
+ state: present
+ with_items:
+ - python-lxml
+ - libvirt-python
+ - libguestfs-tools
- sysctl:
name: net.ipv4.ip_forward
state: present
state: present
with_items: '{{ virsh_enabled_networks }}'
- virt_net:
- command: define
+ state: present
name: '{{ item }}'
xml: '{{ lookup("template", "virsh_network_ovs.xml.j2") }}'
- autostart: yes
with_items: '{{ virsh_enabled_networks }}'
- virt_net:
- command: create
+ state: active
name: '{{ item }}'
+ autostart: yes
with_items: '{{ virsh_enabled_networks }}'
- virt_pool:
name: default
- command: define
autostart: yes
- state: active
- xml: '{{ lookup("template", "virsh_pool.xml.j2") }}'
- - lineinfile:
- path: /etc/modprobe.d/kvm_intel.conf
- line: 'options kvm-intel nested=1'
- create: yes
- when: ansible_architecture == "x86_64"
- - modprobe:
- name: "{{ item }}"
state: present
- with_items:
- - kvm
- - kvm_intel
+ xml: '{{ lookup("template", "virsh_pool.xml.j2") }}'
+ - virt_pool:
+ name: default
+ autostart: yes
+ state: active
+ - shell: cat /sys/module/kvm_intel/parameters/nested || true
+ register: nested_result
when: ansible_architecture == "x86_64"
+ - name: reload kvm_intel
+ block:
+ - lineinfile:
+ path: /etc/modprobe.d/kvm_intel.conf
+ line: 'options kvm-intel nested=1'
+ create: yes
+ - modprobe:
+ name: kvm_intel
+ state: absent
+ - modprobe:
+ name: kvm_intel
+ state: present
+ when:
+ - ansible_architecture == "x86_64"
+ - "'Y' not in nested_result.stdout"
- name: Generate SSH key for root if missing
shell: test -e ~/.ssh/id_rsa || ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
- name: Check that /u/l/python3.4/site-packages/virtualbmc/vbmc.py exists
regexp: "tostring"
path: /usr/lib/python3.4/site-packages/virtualbmc/vbmc.py
when: vbmc_py.stat.exists == True
+ - name: Add ssh retry to Ansible config
+ ini_file:
+ path: /etc/ansible/ansible.cfg
+ section: ssh_connection
+ option: retries
+ value: 5