Externalize role
This commit is contained in:
commit
dde75d6597
13 changed files with 207 additions and 0 deletions
4
tasks/RedHat.yml
Normal file
4
tasks/RedHat.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
- name: Define libvirt-latest CentOS repo
|
||||
template: src=CentOS-libvirt-latest.repo.j2 dest=/etc/yum.repos.d/CentOS-libvirt-latest.repo owner=root group=root mode=0644
|
||||
|
||||
93
tasks/main.yml
Normal file
93
tasks/main.yml
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
---
|
||||
- name: Include vars for {{ ansible_os_family }}
|
||||
include_vars: "{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: "Ensure system is x86_64"
|
||||
fail: msg="qemu-kvm requires a 64bit system architecture for now"
|
||||
when: "ansible_architecture != 'x86_64'"
|
||||
|
||||
- name: "Ensure system is hardware virtualization capability"
|
||||
fail: msg="qemu-kvm requires hypervisor capability"
|
||||
when: "ansible_virtualization_type != 'kvm'"
|
||||
|
||||
- name: Include tasks for {{ ansible_os_family }}
|
||||
include_tasks: "{{ ansible_os_family }}.yml"
|
||||
|
||||
- name: install packages
|
||||
package: name="{{ libvirt_kvm_packages }}" state=latest update_cache=yes
|
||||
notify: Restart libvirt
|
||||
|
||||
- name: Allow hypervisor in VM
|
||||
template: src=kvm.conf.j2 dest=/etc/modprobe.d/kvm.conf owner=root group=root mode=0644
|
||||
|
||||
- name: Install Openvswitch
|
||||
include_role:
|
||||
name: openvswitch
|
||||
# vars:
|
||||
# openvswitch_brname: "{{ libvirt_brname }}"
|
||||
when:
|
||||
- libvirt_openvswitch == true
|
||||
notify: Restart openswitch
|
||||
|
||||
#- name: Add Openvswitch bridge
|
||||
# openvswitch_bridge:
|
||||
# bridge: '{{ qemu_default_network_interface }}'
|
||||
# parent: '{{ openvswitch_interface }}'
|
||||
# state: present
|
||||
|
||||
- name: Enable libvirt deamon
|
||||
service: name="{{ libvirt_service }}" state=started enabled=yes
|
||||
|
||||
- name: Add defaults networks
|
||||
virt_net:
|
||||
command: define
|
||||
name: '{{ item }}'
|
||||
xml: '{{ lookup ("template", "networks/{{ item }}.xml.j2") }}'
|
||||
with_items:
|
||||
- default
|
||||
- private
|
||||
|
||||
- name: Enable defaults networks on boot
|
||||
virt_net:
|
||||
name: '{{ item }}'
|
||||
autostart: yes
|
||||
with_items:
|
||||
- default
|
||||
- private
|
||||
|
||||
- name: Activate defaults networks now if it doesn't already up
|
||||
virt_net:
|
||||
name: '{{ item }}'
|
||||
state: active
|
||||
with_items:
|
||||
- default
|
||||
- private
|
||||
|
||||
- name: Add OpenVswitch networks
|
||||
virt_net:
|
||||
command: define
|
||||
name: '{{ item.name }}'
|
||||
xml: '{{ lookup ("template", "networks/openvswitch.xml.j2") }}'
|
||||
with_items:
|
||||
- '{{ virtual_network }}'
|
||||
when:
|
||||
- virtual_network is defined
|
||||
|
||||
- name: Activate OpenVSwitch networks now if it doesn't already up
|
||||
virt_net:
|
||||
name: '{{ item.name }}'
|
||||
state: active
|
||||
with_items:
|
||||
- '{{ virtual_network }}'
|
||||
when:
|
||||
- virtual_network is defined
|
||||
|
||||
- name: Enable OpenVSwitch networks on boot
|
||||
virt_net:
|
||||
name: '{{ item.name }}'
|
||||
autostart: yes
|
||||
with_items:
|
||||
- '{{ virtual_network }}'
|
||||
when:
|
||||
- virtual_network is defined
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue