aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/infra_create_vms/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/infra_create_vms/tasks')
-rw-r--r--ansible/roles/infra_create_vms/tasks/configure_vm.yml18
-rw-r--r--ansible/roles/infra_create_vms/tasks/create_interfaces.yml10
-rw-r--r--ansible/roles/infra_create_vms/tasks/main.yml8
3 files changed, 33 insertions, 3 deletions
diff --git a/ansible/roles/infra_create_vms/tasks/configure_vm.yml b/ansible/roles/infra_create_vms/tasks/configure_vm.yml
index 5685e634f..c20a0b175 100644
--- a/ansible/roles/infra_create_vms/tasks/configure_vm.yml
+++ b/ansible/roles/infra_create_vms/tasks/configure_vm.yml
@@ -222,6 +222,10 @@
- console:
type: pty
tty: '/dev/pts/14'
+ - graphics:
+ type: vnc
+ port: '-1'
+ autoport: 'yes'
pretty_print: yes
- name: Add new children nodes to "disk" node
@@ -241,6 +245,16 @@
name: virtio-disk0
pretty_print: yes
+- name: Add new children nodes to "graphics" node
+ xml:
+ path: "{{ xml_file }}"
+ xpath: /domain/devices/graphics
+ add_children:
+ - listen:
+ type: address
+ address: 0.0.0.0
+ pretty_print: yes
+
- name: Add new children nodes to "devices" node
xml:
path: "{{ xml_file }}"
@@ -305,7 +319,7 @@
- name: Populate network-config and add interface to xml file
include_tasks: create_interfaces.yml
- extra_vars: "{{ network_config, xml_file , slot_address, mac_address_counter }}"
+ extra_vars: "{{ network_config xml_file slot_address mac_address_counter }}"
loop_control:
loop_var: interface_item
with_items: "{{ node_item.interfaces }}"
@@ -326,7 +340,7 @@
shell: >
qemu-img convert -O qcow2 {{ node_item.image }} {{ image_dir+node_item.hostname+'.qcow2' }}
-- name: Copy and convert the ubuntu image
+- name: Resize image
shell: >
qemu-img resize {{ image_dir+node_item.hostname+'.qcow2' }} {{ node_item.disk }}M
diff --git a/ansible/roles/infra_create_vms/tasks/create_interfaces.yml b/ansible/roles/infra_create_vms/tasks/create_interfaces.yml
index 124421b56..34bfd1b71 100644
--- a/ansible/roles/infra_create_vms/tasks/create_interfaces.yml
+++ b/ansible/roles/infra_create_vms/tasks/create_interfaces.yml
@@ -24,6 +24,16 @@
addresses:
- {{ interface_item.ip }}/{{ interface_item.netmask }}
+- name: Add default gateway
+ blockinfile:
+ path: "{{ network_config }}"
+ insertafter: "{{ interface_item.ip }}"
+ marker: "MARKER"
+ block: |2
+ gateway4: {{ default_bridge.host_ip }}
+ when:
+ - default_bridge is defined
+ - default_bridge.name == interface_item.network
- name: Remove the marker introduced in network-data
lineinfile:
diff --git a/ansible/roles/infra_create_vms/tasks/main.yml b/ansible/roles/infra_create_vms/tasks/main.yml
index 62a023e7e..4d47f44ff 100644
--- a/ansible/roles/infra_create_vms/tasks/main.yml
+++ b/ansible/roles/infra_create_vms/tasks/main.yml
@@ -20,9 +20,15 @@
- set_fact:
mac_address_counter: 0
+- set_fact:
+ default_bridge: "{{ item }}"
+ when:
+ - item.default_gateway is defined
+ - item.default_gateway == True
+ with_items: "{{ infra_deploy_vars.networks }}"
+
- name: Create XML file
include_tasks: configure_vm.yml
- extra_vars: "{{ mac_address_counter }}"
loop_control:
loop_var: node_item
with_items: "{{ infra_deploy_vars.nodes }}"