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/20 14:03] sfebruary [Base project] |
guide:cloud:advanced [2025/10/22 10:21] (current) sfebruary [Single, generic, VM project] |
||
|---|---|---|---|
| Line 45: | Line 45: | ||
| } | } | ||
| module " | module " | ||
| - | source = " | + | source = " |
| public_network_name | public_network_name | ||
| private_network_name | private_network_name | ||
| Line 135: | Line 135: | ||
| * Now we can proceed to initialising Terraform for this project. To do this, on GitLab navigate to " | * Now we can proceed to initialising Terraform for this project. To do this, on GitLab navigate to " | ||
| {{: | {{: | ||
| - | * Then click on "Copy Terraform init command" | + | * Then click on "Copy Terraform init command" |
| * After successfully initialising, | * After successfully initialising, | ||
| * Assuming everything looks good with the above (NB! you have the freedom to modify **settings.tfvars** to customise your specific environment), | * Assuming everything looks good with the above (NB! you have the freedom to modify **settings.tfvars** to customise your specific environment), | ||
| Once all of your base resources are in place, you may now proceed to creating virtual machines that make use of them. | Once all of your base resources are in place, you may now proceed to creating virtual machines that make use of them. | ||
| + | |||
| + | NB! Depending on one's workflow, additional resources such as SSH key-pairs and Security Group definitions might be good to define in this base setup too. Alternatively, | ||
| ==== 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. To illustrate the concept, we can again draw on a [[https:// | ||
| + | |||
| + | 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/ | ||