---

- name: install virtualization tools
  package: name={{ item }} state=present 
  with_items:
    - bridge-utils
    - qemu-kvm
    - qemu-img
    - libvirt
    - libvirt-python
    - libvirt-client
    - virt-install
    - libguestfs-tools
    - libguestfs-bash-completion
    - genisoimage

- name: ensure rhel template exists
  copy:
    src: "{{ rhel_image }}"
    dest: "/var/lib/libvirt/images/{{ rhel_image }}"
    owner: qemu
    group: qemu
    mode: 0644

- name: Ensure SSH key for root
  user:
    name: root
    generate_ssh_key: yes
    ssh_key_bits: 2048
    ssh_key_file: .ssh/id_rsa

---

- name: install virtualization tools
  package: name={{ item }} state=present
  with_items:
    - bridge-utils
    - qemu-kvm
    - qemu-img
    - libvirt
    - libvirt-python
    - libvirt-client
    - virt-install
    - libguestfs-tools
    - libguestfs-bash-completion
    - genisoimage

- name: enable virtualization service
  service:
    name: libvirtd
    state: started
    enabled: yes

- name: ensure rhel template exists
  copy:
    src: "{{ rhel_image }}"
    dest: "/var/lib/libvirt/images/{{ rhel_image }}"
    owner: qemu
    group: qemu
    mode: 0644

- name: Ensure SSH key for root
  user:
    name: root
    generate_ssh_key: yes
    ssh_key_bits: 2048
    ssh_key_file: .ssh/id_rsa

Enable virtualization service for host
Enable virtualization service for host
