Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.2.2 #34

Merged
merged 2 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ocf/code/component_playbook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: "STAGE 1: Prepare to access a previous target component"
hosts: localhost
gather_facts: false
connection: local
connection: local
tasks:
- name: Load enviromental variables from different sources
ansible.builtin.include_tasks: "{{ workspace }}/.global/cac/load_variables.yaml"
Expand Down
13 changes: 6 additions & 7 deletions tn_bastion/code/one/iac/tn_bastion.tf.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# https://registry.terraform.io/providers/OpenNebula/opennebula/latest/docs/resources/virtual_machine
# https://docs.opennebula.io/6.8/management_and_operations/references/template.html#context-section
resource "opennebula_virtual_machine" "{{ entity_name }}" {
name = "{{ tn_id }}-{{ entity_name }}"
resource "opennebula_virtual_machine" "tn_bastion" {
name = "{{ tn_id }}-tn_bastion"
template_id = {{ site_available_components.tn_bastion.template_id }}
cpu = {{ one_bastion_cpu }}
vcpu = {{ one_bastion_cpu }}
Expand All @@ -23,7 +23,6 @@ resource "opennebula_virtual_machine" "{{ entity_name }}" {
driver = "qcow2"
} #}


nic {
model = "virtio"
network_id = "{{ site_networks_id.default }}"
Expand All @@ -38,12 +37,12 @@ resource "opennebula_virtual_machine" "{{ entity_name }}" {
depends_on = [ opennebula_virtual_network_address_range.tn_vxlan ]
}

output "{{ entity_name }}-id" {
output "tn_bastion-id" {
description = "OpenNebula VM ID"
value = opennebula_virtual_machine.{{ entity_name }}.id
value = opennebula_virtual_machine.tn_bastion.id
}

output "{{ entity_name }}-ips" {
output "tn_bastion-ips" {
description = "OpenNebula VM Network Assignments"
value = { for nic in opennebula_virtual_machine.{{ entity_name }}.nic[*] : nic.network_id => nic.computed_ip }
value = { for nic in opennebula_virtual_machine.tn_bastion.nic[*] : nic.network_id => nic.computed_ip }
}
2 changes: 0 additions & 2 deletions tn_bastion/variables/one/private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,5 @@ one_bastion_disk: 10240 # Size of the Image. Future plans to downsize it

one_bastion_wireguard_allowedips: "192.168.199.0/24"

# By default, In tn_bastion the first VNet is hardcoded to be the site default (site_networks_id.default)
# The following ones are appended here (tn_vxlan.id)
one_bastion_networks:
- tn_vxlan
4 changes: 3 additions & 1 deletion tn_init/code/one/iac/tn_bastion.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ resource "opennebula_virtual_machine" "tn_bastion" {
model = "virtio"
network_id = "{{ site_networks_id.default }}"
}
{% for network in one_bastion_networks %}
nic {
model = "virtio"
network_id = opennebula_virtual_network.tn_vxlan.id
network_id = opennebula_virtual_network.{{ network }}.id
}
{% endfor %}

depends_on = [ opennebula_virtual_network_address_range.tn_vxlan ]
}
Expand Down
3 changes: 3 additions & 0 deletions tn_init/variables/one/private.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ one_bastion_memory: 1024
one_bastion_disk: 10240 # Size of the Image. Future plans to downsize it

one_bastion_wireguard_allowedips: "192.168.199.0/24"

one_bastion_networks:
- tn_vxlan
12 changes: 6 additions & 6 deletions tn_vxlan/code/one/iac/tn_vxlan.tf.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# https://registry.terraform.io/providers/OpenNebula/opennebula/latest/docs/resources/virtual_network
resource "opennebula_virtual_network" "{{ entity_name }}" {
name = "{{ tn_id }}-{{ entity_name }}"
resource "opennebula_virtual_network" "tn_vxlan" {
name = "{{ tn_id }}-tn_vxlan"
physical_device = "{{ one_vxlan_physical_device }}"
cluster_ids = {{ site_clusters }}
type = "vxlan"
Expand All @@ -13,14 +13,14 @@ resource "opennebula_virtual_network" "{{ entity_name }}" {
dns = "{{ one_vxlan_dns }}"
}

resource "opennebula_virtual_network_address_range" "{{ entity_name }}" {
virtual_network_id = opennebula_virtual_network.{{ entity_name }}.id
resource "opennebula_virtual_network_address_range" "tn_vxlan" {
virtual_network_id = opennebula_virtual_network.tn_vxlan.id
ar_type = "IP4"
ip4 = "{{ one_vxlan_first_ip }}"
size = {{ one_vxlan_address_size }}
}

output "{{ entity_name }}-id" {
output "tn_vxlan-id" {
description = "OpenNebula Network ID"
value = opennebula_virtual_network.{{ entity_name }}.id
value = opennebula_virtual_network.tn_vxlan.id
}
7 changes: 6 additions & 1 deletion tn_vxlan/sample_input_file.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# THIS IS AN INPUT FILE EXAMPLE. Values may not be valid for your enviroment

# This component does not need any input file

#one_vxlan_gw: "192.168.199.1"
#one_vxlan_netmask: "255.255.255.0"
#one_vxlan_dns: "1.1.1.1 1.0.0.1"
#one_vxlan_first_ip: "192.168.199.1"
#one_vxlan_address_size: 254