From 63212acd45ae7f392bec7ede9e19f2689cacba3d Mon Sep 17 00:00:00 2001 From: 89luca89 Date: Thu, 14 Jan 2021 20:07:00 +0100 Subject: [PATCH 1/3] Add vm_autoboot support --- README.md | 1 + inventory-example.yml | 5 +++++ roles/terrible/defaults/main.yml | 1 + roles/terrible/templates/terraform-vm.tf.j2 | 2 ++ 4 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 9e83dc9..9d5aba4 100644 --- a/README.md +++ b/README.md @@ -252,6 +252,7 @@ These variable are optional, there are sensible defaults set up, most of them ca * **cpu:** `optional`. Specify the cpu number for the VM. If not specified, the default value is taken. Default: `1` * **memory:** `optional`. Specify the memory ram for the VM. If not specified, the default value is taken. Default: `1024` * **set_new_password:** `optional`. Specify a new password to access the Vm. If not specified, the default value (**ssh_password**) is taken. +* **vm_autoboot**: `optional`. Specify if the VM should be automatically started together with the hypervisor. Default: `false` ### Terraform Node, Bastions & Jumphosts diff --git a/inventory-example.yml b/inventory-example.yml index ee1dfc6..bd823ad 100644 --- a/inventory-example.yml +++ b/inventory-example.yml @@ -87,6 +87,10 @@ all: cpu: 4 memory: 1024 + # Whether to autostart the VM with the hypervisor or not. + # Defaults to false + vm_autostart: True + ## Hypervisor # this variable is required and decides on which hypervisor # the VM should be deployed, this value should be the inventory_hostname @@ -278,6 +282,7 @@ all: host-vm-2: os_family: RedHat hypervisor: hypervisor_1 + vm_autostart: False ansible_host: 192.168.122.200 network_interfaces: iface_1: diff --git a/roles/terrible/defaults/main.yml b/roles/terrible/defaults/main.yml index 8c07e19..ba22121 100644 --- a/roles/terrible/defaults/main.yml +++ b/roles/terrible/defaults/main.yml @@ -6,6 +6,7 @@ cpu: 1 memory: 1024 network_name: "default" +autostart: False terraform_version: 0.12 diff --git a/roles/terrible/templates/terraform-vm.tf.j2 b/roles/terrible/templates/terraform-vm.tf.j2 index 9b19dbc..961c950 100644 --- a/roles/terrible/templates/terraform-vm.tf.j2 +++ b/roles/terrible/templates/terraform-vm.tf.j2 @@ -38,6 +38,8 @@ resource "libvirt_domain" "domain_{{ inventory_hostname }}" { memory = {{ memory }} vcpu = {{ cpu }} + autostart = {% if vm_autostart %}true{% else %}false{% endif %} + cpu = { mode = "host-passthrough" } From 7c1428569ba5c8a8538da1eb1268d56f8e2ee7fe Mon Sep 17 00:00:00 2001 From: 89luca89 Date: Thu, 14 Jan 2021 20:42:40 +0100 Subject: [PATCH 2/3] Fix default name variable --- roles/terrible/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/terrible/defaults/main.yml b/roles/terrible/defaults/main.yml index ba22121..88c3111 100644 --- a/roles/terrible/defaults/main.yml +++ b/roles/terrible/defaults/main.yml @@ -6,7 +6,7 @@ cpu: 1 memory: 1024 network_name: "default" -autostart: False +vm_autostart: False terraform_version: 0.12 From c54b72dd04f91ba874f54eb2840fb2fd0e91491a Mon Sep 17 00:00:00 2001 From: alegrey91 Date: Fri, 15 Jan 2021 22:09:07 +0100 Subject: [PATCH 3/3] Improved parameter description --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9d5aba4..8a6bd6c 100644 --- a/README.md +++ b/README.md @@ -252,7 +252,7 @@ These variable are optional, there are sensible defaults set up, most of them ca * **cpu:** `optional`. Specify the cpu number for the VM. If not specified, the default value is taken. Default: `1` * **memory:** `optional`. Specify the memory ram for the VM. If not specified, the default value is taken. Default: `1024` * **set_new_password:** `optional`. Specify a new password to access the Vm. If not specified, the default value (**ssh_password**) is taken. -* **vm_autoboot**: `optional`. Specify if the VM should be automatically started together with the hypervisor. Default: `false` +* **vm_autoboot**: `optional`. Specify if the VM should be automatically started at boot. Default: `False` ### Terraform Node, Bastions & Jumphosts @@ -651,4 +651,4 @@ will be restored and saved on each run. - GNU GPLv3, See LICENSE file. -[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2F89luca89%2Fterrible.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2F89luca89%2Fterrible?ref=badge_large) \ No newline at end of file +[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2F89luca89%2Fterrible.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2F89luca89%2Fterrible?ref=badge_large)