Skip to content
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ terraform/aws/kconfigs/Kconfig.instance.generated
terraform/aws/kconfigs/Kconfig.location.generated
terraform/aws/scripts/__pycache__/

terraform/azure/kconfigs/Kconfig.image.generated
terraform/azure/kconfigs/Kconfig.location.generated
terraform/azure/kconfigs/Kconfig.size.generated
terraform/azure/scripts/__pycache__/

terraform/oci/kconfigs/Kconfig.image.generated
terraform/oci/kconfigs/Kconfig.location.generated
terraform/oci/kconfigs/Kconfig.shape.generated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ azure_image_sku = "{{ terraform_azure_image_sku }}"
azure_managed_disks_per_instance = {{ terraform_azure_managed_disks_per_instance }}
azure_managed_disks_size = {{ terraform_azure_managed_disks_size }}
azure_managed_disks_tier = "{{ terraform_azure_managed_disks_tier }}"
azure_accelerated_networking_enabled = {{ terraform_azure_accelerated_networking_enabled | lower }}

ssh_config_pubkey_file = "{{ kdevops_terraform_ssh_config_pubkey_file }}"
ssh_config_user = "{{ kdevops_terraform_ssh_config_user }}"
Expand Down
30 changes: 26 additions & 4 deletions scripts/dynamic-cloud-kconfig.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ AWS_KCONFIG_LOCATION := $(AWS_KCONFIG_DIR)/Kconfig.location.generated

AWS_KCONFIGS := $(AWS_KCONFIG_AMI) $(AWS_KCONFIG_INSTANCE) $(AWS_KCONFIG_LOCATION)

# Azure dynamic configuration
AZURE_KCONFIG_DIR := terraform/azure/kconfigs
AZURE_KCONFIG_IMAGE := $(AZURE_KCONFIG_DIR)/Kconfig.image.generated
AZURE_KCONFIG_LOCATION := $(AZURE_KCONFIG_DIR)/Kconfig.location.generated
AZURE_KCONFIG_SIZE := $(AZURE_KCONFIG_DIR)/Kconfig.size.generated

AZURE_KCONFIGS := $(AZURE_KCONFIG_LOCATION) $(AZURE_KCONFIG_SIZE) $(AZURE_KCONFIG_IMAGE)

# OCI dynamic configuration
OCI_KCONFIG_DIR := terraform/oci/kconfigs
OCI_KCONFIG_IMAGE := $(OCI_KCONFIG_DIR)/Kconfig.image.generated
Expand All @@ -29,7 +37,7 @@ OCI_KCONFIG_SHAPE := $(OCI_KCONFIG_DIR)/Kconfig.shape.generated
OCI_KCONFIGS := $(OCI_KCONFIG_IMAGE) $(OCI_KCONFIG_LOCATION) $(OCI_KCONFIG_SHAPE)

# Add generated files to mrproper clean list
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS) $(OCI_KCONFIGS)
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS) $(AZURE_KCONFIGS) $(OCI_KCONFIGS)

# Touch Lambda Labs generated files so Kconfig can source them
# This ensures the files exist (even if empty) before Kconfig runs
Expand All @@ -40,11 +48,15 @@ dynamic_lambdalabs_kconfig_touch:
dynamic_aws_kconfig_touch:
$(Q)touch $(AWS_KCONFIGS)

# Touch Azure generated files so Kconfig can source them
dynamic_azure_kconfig_touch:
$(Q)touch $(AZURE_KCONFIGS)

# Touch OCI generated files so Kconfig can source them
dynamic_oci_kconfig_touch:
$(Q)touch $(OCI_KCONFIGS)

DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_oci_kconfig_touch
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_oci_kconfig_touch

# Lambda Labs targets use --provider argument for efficiency
cloud-config-lambdalabs:
Expand All @@ -54,6 +66,10 @@ cloud-config-lambdalabs:
cloud-config-aws:
$(Q)python3 scripts/generate_cloud_configs.py --provider aws

# Azure targets use --provider argument for efficiency
cloud-config-azure:
$(Q)python3 scripts/generate_cloud_configs.py --provider azure

# OCI targets use --provider argument for efficiency
cloud-config-oci:
$(Q)python3 scripts/generate_cloud_configs.py --provider oci
Expand All @@ -66,17 +82,22 @@ clean-cloud-config-lambdalabs:
clean-cloud-config-aws:
$(Q)rm -f $(AWS_KCONFIGS)

# Clean Azure generated files
clean-cloud-config-azure:
$(Q)rm -f $(AZURE_KCONFIGS)

# Clean OCI generated files
clean-cloud-config-oci:
$(Q)rm -f $(OCI_KCONFIGS)

DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-oci
DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-azure cloud-config-oci

cloud-config-help:
@echo "Cloud-specific dynamic kconfig targets:"
@echo "cloud-config - generates all cloud provider dynamic kconfig content"
@echo "cloud-config-lambdalabs - generates Lambda Labs dynamic kconfig content"
@echo "cloud-config-aws - generates AWS dynamic kconfig content"
@echo "cloud-config-azure - generates Azure dynamic kconfig content"
@echo "cloud-config-oci - generates OCI dynamic kconfig content"
@echo "clean-cloud-config - removes all generated cloud kconfig files"
@echo "cloud-list-all - list all cloud instances for configured provider"
Expand All @@ -86,7 +107,7 @@ HELP_TARGETS += cloud-config-help
cloud-config:
$(Q)python3 scripts/generate_cloud_configs.py

clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws clean-cloud-config-oci
clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws clean-cloud-config-azure clean-cloud-config-oci
$(Q)echo "Cleaned all cloud provider dynamic Kconfig files."

cloud-list-all:
Expand All @@ -95,5 +116,6 @@ cloud-list-all:

PHONY += cloud-config clean-cloud-config cloud-config-help cloud-list-all
PHONY += cloud-config-aws clean-cloud-config-aws
PHONY += cloud-config-azure clean-cloud-config-azure
PHONY += cloud-config-lambdalabs clean-cloud-config-lambdalabs
PHONY += cloud-config-oci clean-cloud-config-oci
55 changes: 53 additions & 2 deletions scripts/generate_cloud_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,52 @@ def generate_aws_kconfig() -> bool:
return all_success


def generate_azure_kconfig() -> bool:
"""
Generate Azure Kconfig files.
Returns True on success, False on failure.
"""
script_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(script_dir)
azure_scripts_dir = os.path.join(project_root, "terraform", "azure", "scripts")
azure_kconfigs_dir = os.path.join(project_root, "terraform", "azure", "kconfigs")

# Define the script-to-output mapping
scripts_to_run = [
("gen_kconfig_image", "Kconfig.image.generated"),
("gen_kconfig_location", "Kconfig.location.generated"),
("gen_kconfig_size", "Kconfig.size.generated"),
]

all_success = True

for script_name, kconfig_file in scripts_to_run:
script_path = os.path.join(azure_scripts_dir, script_name)
output_path = os.path.join(azure_kconfigs_dir, kconfig_file)

# Run the script and capture its output
result = subprocess.run(
[script_path],
capture_output=True,
text=True,
check=False,
)

if result.returncode == 0:
# Write the output to the corresponding Kconfig file
try:
with open(output_path, "w") as f:
f.write(result.stdout)
except IOError as e:
print(f"Error writing {kconfig_file}: {e}", file=sys.stderr)
all_success = False
else:
print(f"Error running {script_name}: {result.stderr}", file=sys.stderr)
all_success = False

return all_success


def generate_oci_kconfig() -> bool:
"""
Generate OCI Kconfig files.
Expand Down Expand Up @@ -222,8 +268,13 @@ def process_aws():


def process_azure():
"""Process Azure configuration (placeholder)."""
print("⚠ Azure: Dynamic configuration not yet implemented")
"""Process Azure configuration."""
kconfig_generated = generate_azure_kconfig()
if kconfig_generated:
print("✓ Azure: Kconfig files generated successfully")
else:
print("⚠ Azure: Failed to generate Kconfig files - using defaults")
print()


def process_gce():
Expand Down
2 changes: 1 addition & 1 deletion terraform/Kconfig.providers
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ config TERRAFORM_AWS
Enabling this means you are going to use AWS for your cloud solution.

config TERRAFORM_AZURE
bool "Azure"
bool "Azure - Microsoft Azure"
depends on TARGET_ARCH_X86_64
select TERRAFORM_PRIVATE_NET
help
Expand Down
7 changes: 5 additions & 2 deletions terraform/azure/Kconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
if TERRAFORM_AZURE

menu "Resource Location"
source "terraform/azure/kconfigs/Kconfig.location"
source "terraform/azure/kconfigs/Kconfig.location.generated"
endmenu
menu "Compute"
source "terraform/azure/kconfigs/Kconfig.compute"
comment "Size selection"
source "terraform/azure/kconfigs/Kconfig.size.generated"
comment "OS image selection"
source "terraform/azure/kconfigs/Kconfig.image.generated"
endmenu
menu "Storage"
source "terraform/azure/kconfigs/Kconfig.storage"
Expand Down
150 changes: 150 additions & 0 deletions terraform/azure/kconfigs/Kconfig.image
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
choice
prompt "Azure image publisher"
default TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
help
This option specifies the publisher of the boot image used to
create the kdevops target nodes.

config TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
bool "Debian"
help
This option sets the boot image publisher to "Debian".

config TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT
bool "Red Hat"
help
This option sets the boot image publisher to "RedHat".

endchoice

config TERRAFORM_AZURE_IMAGE_PUBLISHER
string
output yaml
default "Debian" if TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
default "RedHat" if TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT

if TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN

if TARGET_ARCH_X86_64

choice
prompt "Debian release"
default TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
help
This option specifies which of a publisher's offers to use
when creating kdevops compute instances.

config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_10
bool "debian-10 (x86)"
help
This option sets the OS image to Debian 10 (Buster).

config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
bool "debian-11 (x86)"
help
This option sets the OS image to Debian 11 (Bullseye).

config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_12
bool "debian-12 (x86)"
help
This option sets the OS image to Debian 12 (Bookworm).

config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_13_DAILY
bool "debian-13-daily (x86)"
help
This option sets the OS image to Debian 13's daily build.

config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_SID_DAILY
bool "debian-sid-daily (x86)"
help
This option sets the OS image to the Debian unstable daily
build.

endchoice

config TERRAFORM_AZURE_IMAGE_OFFER
string
output yaml
default "debian-10" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_10
default "debian-11" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
default "debian-12" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_12
default "debian-13-daily" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_13_DAILY
default "debian-sid-daily" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_SID_DAILY

config TERRAFORM_AZURE_IMAGE_SKU
string
output yaml
default "10" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_10
default "11" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
default "12" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_12
default "13" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_13_DAILY
default "sid" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_SID_DAILY

endif # TARGET_ARCH_X86_64

endif # TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN

if TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT

if TARGET_ARCH_X86_64

choice
prompt "Red Hat Enterprise Linux release"
default TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6
help
This option specifies which of a publisher's offers to use
when creating kdevops compute instances.

config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_7_9
bool "RHEL 7.9 x64"
help
This option sets the OS image to Red Hat Enterprise Linux
release 7 update 9.

config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_9
bool "RHEL 8.9 x64"
help
This option sets the OS image to Red Hat Enterprise Linux
release 8 update 9.

config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_10
bool "RHEL 8.10 x64"
help
This option sets the OS image to Red Hat Enterprise Linux
release 8 update 10.

config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_5
bool "RHEL 9.5 x64"
help
This option sets the OS image to Red Hat Enterprise Linux
release 9 update 5.

config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6
bool "RHEL 9.6 x64"
help
This option sets the OS image to Red Hat Enterprise Linux
release 9 update 6.

endchoice

config TERRAFORM_AZURE_IMAGE_OFFER
string
output yaml
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_7_9
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_9
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_10
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_5
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6

config TERRAFORM_AZURE_IMAGE_SKU
string
output yaml
default "7_9" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_7_9
default "8_9" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_9
default "8_10" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_10
default "9_5" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_5
default "9_6" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6

endif # TARGET_ARCH_X86_64

endif # TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT
Loading
Loading