Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support python3, smaller fixes, work on Fedora for casl #311

Merged
merged 8 commits into from
Jan 18, 2019
4 changes: 4 additions & 0 deletions roles/virt-install/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
---

# consider that this role isn't run against the created VMs but against the virtualization host,
# i.e. you can only overwrite these variables in the inventory by defining them at the host level.
# Use the libvirt_... variables to overwrite them at the VM level.

default_http_dir: "/var/www/html"
default_http_host: "192.168.122.1"

Expand Down
5 changes: 2 additions & 3 deletions roles/virt-install/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

- name: 'Unmount install ISO'
mount:
path: "{{ mounted_iso[item] }}"
path: "{{ item.value }}"
state: absent
with_items:
- "{{ mounted_iso.keys() }}"
loop: "{{ mounted_iso | dict2items }}"

- name: 'Remove authorized_keys'
file:
Expand Down
1 change: 1 addition & 0 deletions roles/virt-install/tasks/create_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- name: 'Gather the list of existing VMs'
command: virsh list --name
register: existing_vms
check_mode: false
ericzolf marked this conversation as resolved.
Show resolved Hide resolved

- name: 'Compose Command for new VM provisioning'
include_tasks: 'virt-install.yml'
Expand Down
5 changes: 2 additions & 3 deletions roles/virt-install/tasks/prereq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@
with_items:
- virt-install
- httpd
- libselinux-python
- "{{ ((ansible_python_interpreter | default('somepython'))[-1] == '3') | ternary('python3-libselinux','libselinux-python') }}"

- name: 'Enable and start libvirtd'
service:
name: libvirtd
enabled: yes
state: started

- name: 'Enable and start httpd'
- name: 'Start httpd (leave enabled as-is)'
service:
name: httpd
enabled: no
state: started

- name: 'Enable and start firewalld'
Expand Down
20 changes: 19 additions & 1 deletion roles/virt-install/tasks/virt-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
opts: loop
fstype: iso9660
state: mounted
boot: false # avoids that a dangling mount blocks boot process
notify: 'Unmount install ISO'
when:
- mounted_iso[virtinstall_iso] is not defined
Expand All @@ -76,4 +77,21 @@

- name: "Set Fact for VM command"
set_fact:
virt_install_commands: "{{ virt_install_commands | default([]) + [ ('virt-install' + ' --connect ' + virtinstall_connect + ' --virt-type ' + virtinstall_virt_type + ' --name ' + virtinstall_name + ' --metadata \"title=' + virtinstall_title + ',description=' + virtinstall_description + ',name=' + virtinstall_name + '\"' + virt_install_network_string + ' --memory ' + virtinstall_memory + ' --vcpus ' + virtinstall_vcpus + virt_install_disk_string + ' --os-variant ' + virtinstall_os_variant + ' --location http://' + virtinstall_http_host + '/' + mounted_iso[virtinstall_iso] | basename + ' --initrd-inject=/tmp/' + virtinstall_ksfile | basename + ' --extra-args \"inst.repo=http://' + virtinstall_http_host + '/' + mounted_iso[virtinstall_iso] | basename + ' inst.ks=file:/' + virtinstall_ksfile | basename + '\"' + ' --graphics spice ' + ' --video qxl ' + ' --channel spicevmc ' + ' --autostart ') ] }}"
virt_install_commands: >
{{ virt_install_commands | default([]) + [ ('virt-install'
+ ' --connect ' + virtinstall_connect
+ ' --virt-type ' + virtinstall_virt_type
+ ' --name ' + virtinstall_name
+ ' --metadata "title=' + virtinstall_title + ',description=' + virtinstall_description + ',name=' + virtinstall_name + '"'
+ virt_install_network_string
+ virt_install_disk_string
+ ' --os-variant ' + virtinstall_os_variant
+ ' --memory ' + virtinstall_memory
+ ' --vcpus ' + virtinstall_vcpus
+ ' --location http://' + virtinstall_http_host + '/' + mounted_iso[virtinstall_iso] | basename
+ ' --initrd-inject=/tmp/' + virtinstall_ksfile | basename
+ ' --extra-args "inst.repo=http://' + virtinstall_http_host + '/' + mounted_iso[virtinstall_iso] | basename + ' inst.ks=file:/' + virtinstall_ksfile | basename + '"'
+ ' --graphics spice '
+ ' --video qxl '
+ ' --channel spicevmc '
+ ' --autostart ') ] }}