Skip to content

Commit

Permalink
Merge pull request #60 from 89luca89/55_autostart_vm
Browse files Browse the repository at this point in the history
Add vm_autoboot support
  • Loading branch information
alegrey91 authored Jan 16, 2021
2 parents 564d909 + c54b72d commit 4c79c9a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 at boot. Default: `False`

### Terraform Node, Bastions & Jumphosts

Expand Down Expand Up @@ -650,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)
[![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)
5 changes: 5 additions & 0 deletions inventory-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions roles/terrible/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
cpu: 1
memory: 1024
network_name: "default"
vm_autostart: False

terraform_version: 0.12

Expand Down
2 changes: 2 additions & 0 deletions roles/terrible/templates/terraform-vm.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 4c79c9a

Please sign in to comment.