This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
guide:cloud:advanced [2025/10/21 14:50] sfebruary [Single, generic, VM project] |
guide:cloud:advanced [2025/10/22 10:21] (current) sfebruary [Single, generic, VM project] |
||
|---|---|---|---|
| Line 144: | Line 144: | ||
| ==== Single, generic, VM project ==== | ==== Single, generic, VM project ==== | ||
| - | Now that we have some base resources defined, we can proceed to creating an OpenStack instance via the IAC approach. | + | Now that we have some base resources defined, we can proceed to creating an OpenStack instance via the IAC approach. |
| + | |||
| + | Begin by [[https:// | ||
| + | |||
| + | Next, we want to create a few files: | ||
| + | |||
| + | **main.tf**: | ||
| + | |||
| + | terraform { | ||
| + | backend " | ||
| + | } | ||
| + | required_providers { | ||
| + | openstack = { | ||
| + | source | ||
| + | version = " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | provider " | ||
| + | # Configuration options | ||
| + | } | ||
| + | module " | ||
| + | source = " | ||
| + | image_name | ||
| + | flavor_name | ||
| + | shortname | ||
| + | key_pair_name | ||
| + | volume_name | ||
| + | volume_size | ||
| + | volume_type | ||
| + | volume_device_path | ||
| + | enable_online_resize | ||
| + | public_network_name | ||
| + | private_network_name | ||
| + | private_subnet_name | ||
| + | server_private_port_name = var.server_private_port_name | ||
| + | server_private_ip | ||
| + | ssh_security_group_name | ||
| + | admin_username | ||
| + | } | ||
| + | |||
| + | **settings.tfvars**: | ||
| + | |||
| + | # general instance settings | ||
| + | image_name | ||
| + | flavor_name | ||
| + | shortname | ||
| + | volume_name | ||
| + | volume_size | ||
| + | volume_type | ||
| + | volume_device_path | ||
| + | enable_online_resize = " | ||
| + | admin_username | ||
| + | # network settings | ||
| + | public_network_name | ||
| + | private_network_name | ||
| + | private_subnet_name | ||
| + | server_private_port_name = " | ||
| + | server_private_ip | ||
| + | ssh_security_group_name | ||
| + | key_pair_name | ||
| + | |||
| + | **variables.tf**: | ||
| + | |||
| + | variable " | ||
| + | type = string | ||
| + | description = "The name of the public network" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The name of the private network" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The name of the private subnet" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The name of the private network port for the instance" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The fixed IP address of the instance on the private network" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The image to be used for the instance" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The admin username to be used for the instance" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The shortname to assign to the instance" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The flavor for the instance" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The volume name to assign to the device" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The volume size to assign to the device" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The volume type to assign to the device" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The path to the device associated with the volume" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = bool | ||
| + | description = " | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The name of the pre-defined key-pair to use for logging in to the nodes" | ||
| + | default | ||
| + | } | ||
| + | variable " | ||
| + | type = string | ||
| + | description = "The name of the security group to allow ssh access" | ||
| + | default | ||
| + | } | ||
| + | |||
| + | Finally, proceed to initialise Terraform, plan and apply as we did above in the case of the base project. | ||
| + | |||
| + | NB! In order to assign a publicly reachable IP address (i.e. a floating IP) to the above instance, you may either modify the above to include this to be done via code, or this may be done/ | ||