Skip to content

Commit 979cadd

Browse files
authored
Merge pull request #67 from linux-kdevops/cel/azure-cloud-config
Implement "make cloud-config-azure"
2 parents c7daa8c + 30f984c commit 979cadd

23 files changed

+2990
-160
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ terraform/aws/kconfigs/Kconfig.instance.generated
122122
terraform/aws/kconfigs/Kconfig.location.generated
123123
terraform/aws/scripts/__pycache__/
124124

125+
terraform/azure/kconfigs/Kconfig.image.generated
126+
terraform/azure/kconfigs/Kconfig.location.generated
127+
terraform/azure/kconfigs/Kconfig.size.generated
128+
terraform/azure/scripts/__pycache__/
129+
125130
terraform/oci/kconfigs/Kconfig.image.generated
126131
terraform/oci/kconfigs/Kconfig.location.generated
127132
terraform/oci/kconfigs/Kconfig.shape.generated

playbooks/roles/gen_tfvars/templates/azure/terraform.tfvars.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ azure_image_sku = "{{ terraform_azure_image_sku }}"
99
azure_managed_disks_per_instance = {{ terraform_azure_managed_disks_per_instance }}
1010
azure_managed_disks_size = {{ terraform_azure_managed_disks_size }}
1111
azure_managed_disks_tier = "{{ terraform_azure_managed_disks_tier }}"
12+
azure_accelerated_networking_enabled = {{ terraform_azure_accelerated_networking_enabled | lower }}
1213

1314
ssh_config_pubkey_file = "{{ kdevops_terraform_ssh_config_pubkey_file }}"
1415
ssh_config_user = "{{ kdevops_terraform_ssh_config_user }}"

scripts/dynamic-cloud-kconfig.Makefile

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ AWS_KCONFIG_LOCATION := $(AWS_KCONFIG_DIR)/Kconfig.location.generated
2020

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

23+
# Azure dynamic configuration
24+
AZURE_KCONFIG_DIR := terraform/azure/kconfigs
25+
AZURE_KCONFIG_IMAGE := $(AZURE_KCONFIG_DIR)/Kconfig.image.generated
26+
AZURE_KCONFIG_LOCATION := $(AZURE_KCONFIG_DIR)/Kconfig.location.generated
27+
AZURE_KCONFIG_SIZE := $(AZURE_KCONFIG_DIR)/Kconfig.size.generated
28+
29+
AZURE_KCONFIGS := $(AZURE_KCONFIG_LOCATION) $(AZURE_KCONFIG_SIZE) $(AZURE_KCONFIG_IMAGE)
30+
2331
# OCI dynamic configuration
2432
OCI_KCONFIG_DIR := terraform/oci/kconfigs
2533
OCI_KCONFIG_IMAGE := $(OCI_KCONFIG_DIR)/Kconfig.image.generated
@@ -29,7 +37,7 @@ OCI_KCONFIG_SHAPE := $(OCI_KCONFIG_DIR)/Kconfig.shape.generated
2937
OCI_KCONFIGS := $(OCI_KCONFIG_IMAGE) $(OCI_KCONFIG_LOCATION) $(OCI_KCONFIG_SHAPE)
3038

3139
# Add generated files to mrproper clean list
32-
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS) $(OCI_KCONFIGS)
40+
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS) $(AZURE_KCONFIGS) $(OCI_KCONFIGS)
3341

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

51+
# Touch Azure generated files so Kconfig can source them
52+
dynamic_azure_kconfig_touch:
53+
$(Q)touch $(AZURE_KCONFIGS)
54+
4355
# Touch OCI generated files so Kconfig can source them
4456
dynamic_oci_kconfig_touch:
4557
$(Q)touch $(OCI_KCONFIGS)
4658

47-
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_oci_kconfig_touch
59+
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_oci_kconfig_touch
4860

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

69+
# Azure targets use --provider argument for efficiency
70+
cloud-config-azure:
71+
$(Q)python3 scripts/generate_cloud_configs.py --provider azure
72+
5773
# OCI targets use --provider argument for efficiency
5874
cloud-config-oci:
5975
$(Q)python3 scripts/generate_cloud_configs.py --provider oci
@@ -66,17 +82,22 @@ clean-cloud-config-lambdalabs:
6682
clean-cloud-config-aws:
6783
$(Q)rm -f $(AWS_KCONFIGS)
6884

85+
# Clean Azure generated files
86+
clean-cloud-config-azure:
87+
$(Q)rm -f $(AZURE_KCONFIGS)
88+
6989
# Clean OCI generated files
7090
clean-cloud-config-oci:
7191
$(Q)rm -f $(OCI_KCONFIGS)
7292

73-
DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-oci
93+
DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-azure cloud-config-oci
7494

7595
cloud-config-help:
7696
@echo "Cloud-specific dynamic kconfig targets:"
7797
@echo "cloud-config - generates all cloud provider dynamic kconfig content"
7898
@echo "cloud-config-lambdalabs - generates Lambda Labs dynamic kconfig content"
7999
@echo "cloud-config-aws - generates AWS dynamic kconfig content"
100+
@echo "cloud-config-azure - generates Azure dynamic kconfig content"
80101
@echo "cloud-config-oci - generates OCI dynamic kconfig content"
81102
@echo "clean-cloud-config - removes all generated cloud kconfig files"
82103
@echo "cloud-list-all - list all cloud instances for configured provider"
@@ -86,7 +107,7 @@ HELP_TARGETS += cloud-config-help
86107
cloud-config:
87108
$(Q)python3 scripts/generate_cloud_configs.py
88109

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

92113
cloud-list-all:
@@ -95,5 +116,6 @@ cloud-list-all:
95116

96117
PHONY += cloud-config clean-cloud-config cloud-config-help cloud-list-all
97118
PHONY += cloud-config-aws clean-cloud-config-aws
119+
PHONY += cloud-config-azure clean-cloud-config-azure
98120
PHONY += cloud-config-lambdalabs clean-cloud-config-lambdalabs
99121
PHONY += cloud-config-oci clean-cloud-config-oci

scripts/generate_cloud_configs.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,52 @@ def generate_aws_kconfig() -> bool:
147147
return all_success
148148

149149

150+
def generate_azure_kconfig() -> bool:
151+
"""
152+
Generate Azure Kconfig files.
153+
Returns True on success, False on failure.
154+
"""
155+
script_dir = os.path.dirname(os.path.abspath(__file__))
156+
project_root = os.path.dirname(script_dir)
157+
azure_scripts_dir = os.path.join(project_root, "terraform", "azure", "scripts")
158+
azure_kconfigs_dir = os.path.join(project_root, "terraform", "azure", "kconfigs")
159+
160+
# Define the script-to-output mapping
161+
scripts_to_run = [
162+
("gen_kconfig_image", "Kconfig.image.generated"),
163+
("gen_kconfig_location", "Kconfig.location.generated"),
164+
("gen_kconfig_size", "Kconfig.size.generated"),
165+
]
166+
167+
all_success = True
168+
169+
for script_name, kconfig_file in scripts_to_run:
170+
script_path = os.path.join(azure_scripts_dir, script_name)
171+
output_path = os.path.join(azure_kconfigs_dir, kconfig_file)
172+
173+
# Run the script and capture its output
174+
result = subprocess.run(
175+
[script_path],
176+
capture_output=True,
177+
text=True,
178+
check=False,
179+
)
180+
181+
if result.returncode == 0:
182+
# Write the output to the corresponding Kconfig file
183+
try:
184+
with open(output_path, "w") as f:
185+
f.write(result.stdout)
186+
except IOError as e:
187+
print(f"Error writing {kconfig_file}: {e}", file=sys.stderr)
188+
all_success = False
189+
else:
190+
print(f"Error running {script_name}: {result.stderr}", file=sys.stderr)
191+
all_success = False
192+
193+
return all_success
194+
195+
150196
def generate_oci_kconfig() -> bool:
151197
"""
152198
Generate OCI Kconfig files.
@@ -222,8 +268,13 @@ def process_aws():
222268

223269

224270
def process_azure():
225-
"""Process Azure configuration (placeholder)."""
226-
print("⚠ Azure: Dynamic configuration not yet implemented")
271+
"""Process Azure configuration."""
272+
kconfig_generated = generate_azure_kconfig()
273+
if kconfig_generated:
274+
print("✓ Azure: Kconfig files generated successfully")
275+
else:
276+
print("⚠ Azure: Failed to generate Kconfig files - using defaults")
277+
print()
227278

228279

229280
def process_gce():

terraform/Kconfig.providers

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ config TERRAFORM_AWS
1616
Enabling this means you are going to use AWS for your cloud solution.
1717

1818
config TERRAFORM_AZURE
19-
bool "Azure"
19+
bool "Azure - Microsoft Azure"
2020
depends on TARGET_ARCH_X86_64
2121
select TERRAFORM_PRIVATE_NET
2222
help

terraform/azure/Kconfig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
if TERRAFORM_AZURE
22

33
menu "Resource Location"
4-
source "terraform/azure/kconfigs/Kconfig.location"
4+
source "terraform/azure/kconfigs/Kconfig.location.generated"
55
endmenu
66
menu "Compute"
7-
source "terraform/azure/kconfigs/Kconfig.compute"
7+
comment "Size selection"
8+
source "terraform/azure/kconfigs/Kconfig.size.generated"
9+
comment "OS image selection"
10+
source "terraform/azure/kconfigs/Kconfig.image.generated"
811
endmenu
912
menu "Storage"
1013
source "terraform/azure/kconfigs/Kconfig.storage"
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
choice
2+
prompt "Azure image publisher"
3+
default TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
4+
help
5+
This option specifies the publisher of the boot image used to
6+
create the kdevops target nodes.
7+
8+
config TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
9+
bool "Debian"
10+
help
11+
This option sets the boot image publisher to "Debian".
12+
13+
config TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT
14+
bool "Red Hat"
15+
help
16+
This option sets the boot image publisher to "RedHat".
17+
18+
endchoice
19+
20+
config TERRAFORM_AZURE_IMAGE_PUBLISHER
21+
string
22+
output yaml
23+
default "Debian" if TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
24+
default "RedHat" if TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT
25+
26+
if TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
27+
28+
if TARGET_ARCH_X86_64
29+
30+
choice
31+
prompt "Debian release"
32+
default TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
33+
help
34+
This option specifies which of a publisher's offers to use
35+
when creating kdevops compute instances.
36+
37+
config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_10
38+
bool "debian-10 (x86)"
39+
help
40+
This option sets the OS image to Debian 10 (Buster).
41+
42+
config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
43+
bool "debian-11 (x86)"
44+
help
45+
This option sets the OS image to Debian 11 (Bullseye).
46+
47+
config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_12
48+
bool "debian-12 (x86)"
49+
help
50+
This option sets the OS image to Debian 12 (Bookworm).
51+
52+
config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_13_DAILY
53+
bool "debian-13-daily (x86)"
54+
help
55+
This option sets the OS image to Debian 13's daily build.
56+
57+
config TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_SID_DAILY
58+
bool "debian-sid-daily (x86)"
59+
help
60+
This option sets the OS image to the Debian unstable daily
61+
build.
62+
63+
endchoice
64+
65+
config TERRAFORM_AZURE_IMAGE_OFFER
66+
string
67+
output yaml
68+
default "debian-10" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_10
69+
default "debian-11" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
70+
default "debian-12" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_12
71+
default "debian-13-daily" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_13_DAILY
72+
default "debian-sid-daily" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_SID_DAILY
73+
74+
config TERRAFORM_AZURE_IMAGE_SKU
75+
string
76+
output yaml
77+
default "10" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_10
78+
default "11" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_11
79+
default "12" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_12
80+
default "13" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_13_DAILY
81+
default "sid" if TERRAFORM_AZURE_IMAGE_LINUX_DEBIAN_SID_DAILY
82+
83+
endif # TARGET_ARCH_X86_64
84+
85+
endif # TERRAFORM_AZURE_IMAGE_PUBLISHER_DEBIAN
86+
87+
if TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT
88+
89+
if TARGET_ARCH_X86_64
90+
91+
choice
92+
prompt "Red Hat Enterprise Linux release"
93+
default TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6
94+
help
95+
This option specifies which of a publisher's offers to use
96+
when creating kdevops compute instances.
97+
98+
config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_7_9
99+
bool "RHEL 7.9 x64"
100+
help
101+
This option sets the OS image to Red Hat Enterprise Linux
102+
release 7 update 9.
103+
104+
config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_9
105+
bool "RHEL 8.9 x64"
106+
help
107+
This option sets the OS image to Red Hat Enterprise Linux
108+
release 8 update 9.
109+
110+
config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_10
111+
bool "RHEL 8.10 x64"
112+
help
113+
This option sets the OS image to Red Hat Enterprise Linux
114+
release 8 update 10.
115+
116+
config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_5
117+
bool "RHEL 9.5 x64"
118+
help
119+
This option sets the OS image to Red Hat Enterprise Linux
120+
release 9 update 5.
121+
122+
config TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6
123+
bool "RHEL 9.6 x64"
124+
help
125+
This option sets the OS image to Red Hat Enterprise Linux
126+
release 9 update 6.
127+
128+
endchoice
129+
130+
config TERRAFORM_AZURE_IMAGE_OFFER
131+
string
132+
output yaml
133+
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_7_9
134+
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_9
135+
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_10
136+
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_5
137+
default "RHEL" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6
138+
139+
config TERRAFORM_AZURE_IMAGE_SKU
140+
string
141+
output yaml
142+
default "7_9" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_7_9
143+
default "8_9" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_9
144+
default "8_10" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_8_10
145+
default "9_5" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_5
146+
default "9_6" if TERRAFORM_AZURE_IMAGE_LINUX_RHEL_9_6
147+
148+
endif # TARGET_ARCH_X86_64
149+
150+
endif # TERRAFORM_AZURE_IMAGE_PUBLISHER_REDHAT

0 commit comments

Comments
 (0)