Skip to content

Commit 269a444

Browse files
committed
doc(baremetal): add cloud-init attribut and example
1 parent 7aa4f20 commit 269a444

File tree

2 files changed

+110
-0
lines changed

2 files changed

+110
-0
lines changed

docs/resources/baremetal_server.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ resource "scaleway_baremetal_server" "my_server" {
3232

3333
### With option
3434

35+
```
36+
3537
```terraform
3638
data "scaleway_iam_ssh_key" "my_ssh_key" {
3739
name = "main"
@@ -75,6 +77,56 @@ resource "scaleway_baremetal_server" "base" {
7577
}
7678
```
7779

80+
### With cloud-init
81+
82+
```terraform
83+
data "scaleway_iam_ssh_key" "my_ssh_key" {
84+
name = "main"
85+
}
86+
87+
data "scaleway_baremetal_offer" "my_offer" {
88+
zone = "fr-par-2"
89+
name = "EM-I220E-NVME"
90+
}
91+
92+
resource "scaleway_baremetal_server" "my_server_ci" {
93+
zone = "fr-par-2"
94+
offer = data.scaleway_baremetal_offer.my_offer.offer_id
95+
os = "d17d6872-0412-45d9-a198-af82c34d3c5c"
96+
ssh_key_ids = [data.scaleway_iam_ssh_key.my_ssh_key.id]
97+
98+
cloud_init = "cloud-init/userdata.yaml"
99+
}
100+
```
101+
102+
```terraform
103+
data "scaleway_iam_ssh_key" "my_ssh_key" {
104+
name = "main"
105+
}
106+
107+
data "scaleway_baremetal_offer" "my_offer" {
108+
zone = "fr-par-2"
109+
name = "EM-I220E-NVME"
110+
}
111+
112+
resource "scaleway_baremetal_server" "my_server_ci" {
113+
zone = "fr-par-2"
114+
offer = data.scaleway_baremetal_offer.my_offer.offer_id
115+
os = "d17d6872-0412-45d9-a198-af82c34d3c5c"
116+
ssh_key_ids = [data.scaleway_iam_ssh_key.my_ssh_key.id]
117+
118+
cloud_init = <<EOF
119+
#cloud-config
120+
packages:
121+
- htop
122+
- curl
123+
124+
runcmd:
125+
- echo "Hello from raw cloud-init!" > /home/ubuntu/message.txt
126+
EOF
127+
}
128+
```
129+
78130
### With private network
79131

80132
```terraform
@@ -305,6 +357,8 @@ The following arguments are supported:
305357
- `ipam_ip_ids` - (Optional) List of IPAM IP IDs to assign to the server in the requested private network.
306358
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the server should be created.
307359
- `partitioning` (Optional) The partitioning schema in JSON format
360+
- `cloud_init` - (Optional) Configuration data to pass to cloud-init such as a YAML cloud config or a user-data script. Accepts either a string containing the content or a path to a file (for example `file("cloud-init.yml")`). Max length: 127998 characters. Updates to `cloud_init` will update the server user-data via the API and do not trigger a reinstall; however, a reboot of the server is required for the OS to re-run cloud-init and apply the changes. Only supported for OSes that have cloud-init enabled.
361+
- `cloud_init` - (Optional) Configuration data to pass to cloud-init such as a YAML cloud config or a user-data script. Accepts either a string containing the content or a path to a file (for example `file("cloud-init.yml")`). Max length: 127998 characters. Updates to `cloud_init` will update the server user-data via the API and do not trigger a reinstall; however, a reboot of the server is required for the OS to re-run cloud-init and apply the changes. Not all BareMetal offers and OS images support cloud-init — check the OS/offer metadata (for example `cloud_init_supported`) before use.
308362
- `protected` - (Optional) Set to true to activate server protection option.
309363
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the server is associated with.
310364

@@ -320,6 +374,7 @@ In addition to all arguments above, the following attributes are exported:
320374
- `offer_id` - The ID of the offer.
321375
- `offer_name` - The name of the offer.
322376
- `os_name` - The name of the os.
377+
- `cloud_init` - The cloud-init user-data associated with the server. This value can be either a path to a file containing the user-data or the raw user-data content itself. Updating this field requires a server reboot for the changes to take effect. Only available for OS and offers that support cloud-init.
323378
- `private_network` - The private networks attached to the server.
324379
- `id` - The ID of the private network.
325380
- `mapping_id` - The ID of the Server-to-Private Network mapping.

templates/resources/baremetal_server.md.tmpl

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ resource "scaleway_baremetal_server" "my_server" {
3333

3434
### With option
3535

36+
```
37+
3638
```terraform
3739
data "scaleway_iam_ssh_key" "my_ssh_key" {
3840
name = "main"
@@ -76,6 +78,56 @@ resource "scaleway_baremetal_server" "base" {
7678
}
7779
```
7880

81+
### With cloud-init
82+
83+
```terraform
84+
data "scaleway_iam_ssh_key" "my_ssh_key" {
85+
name = "main"
86+
}
87+
88+
data "scaleway_baremetal_offer" "my_offer" {
89+
zone = "fr-par-2"
90+
name = "EM-I220E-NVME"
91+
}
92+
93+
resource "scaleway_baremetal_server" "my_server_ci" {
94+
zone = "fr-par-2"
95+
offer = data.scaleway_baremetal_offer.my_offer.offer_id
96+
os = "d17d6872-0412-45d9-a198-af82c34d3c5c"
97+
ssh_key_ids = [data.scaleway_iam_ssh_key.my_ssh_key.id]
98+
99+
cloud_init = "cloud-init/userdata.yaml"
100+
}
101+
```
102+
103+
```terraform
104+
data "scaleway_iam_ssh_key" "my_ssh_key" {
105+
name = "main"
106+
}
107+
108+
data "scaleway_baremetal_offer" "my_offer" {
109+
zone = "fr-par-2"
110+
name = "EM-I220E-NVME"
111+
}
112+
113+
resource "scaleway_baremetal_server" "my_server_ci" {
114+
zone = "fr-par-2"
115+
offer = data.scaleway_baremetal_offer.my_offer.offer_id
116+
os = "d17d6872-0412-45d9-a198-af82c34d3c5c"
117+
ssh_key_ids = [data.scaleway_iam_ssh_key.my_ssh_key.id]
118+
119+
cloud_init = <<EOF
120+
#cloud-config
121+
packages:
122+
- htop
123+
- curl
124+
125+
runcmd:
126+
- echo "Hello from raw cloud-init!" > /home/ubuntu/message.txt
127+
EOF
128+
}
129+
```
130+
79131
### With private network
80132

81133
```terraform
@@ -306,6 +358,8 @@ The following arguments are supported:
306358
- `ipam_ip_ids` - (Optional) List of IPAM IP IDs to assign to the server in the requested private network.
307359
- `zone` - (Defaults to [provider](../index.md#zone) `zone`) The [zone](../guides/regions_and_zones.md#zones) in which the server should be created.
308360
- `partitioning` (Optional) The partitioning schema in JSON format
361+
- `cloud_init` - (Optional) Configuration data to pass to cloud-init such as a YAML cloud config or a user-data script. Accepts either a string containing the content or a path to a file (for example `file("cloud-init.yml")`). Max length: 127998 characters. Updates to `cloud_init` will update the server user-data via the API and do not trigger a reinstall; however, a reboot of the server is required for the OS to re-run cloud-init and apply the changes. Only supported for OSes that have cloud-init enabled.
362+
- `cloud_init` - (Optional) Configuration data to pass to cloud-init such as a YAML cloud config or a user-data script. Accepts either a string containing the content or a path to a file (for example `file("cloud-init.yml")`). Max length: 127998 characters. Updates to `cloud_init` will update the server user-data via the API and do not trigger a reinstall; however, a reboot of the server is required for the OS to re-run cloud-init and apply the changes. Not all BareMetal offers and OS images support cloud-init — check the OS/offer metadata (for example `cloud_init_supported`) before use.
309363
- `protected` - (Optional) Set to true to activate server protection option.
310364
- `project_id` - (Defaults to [provider](../index.md#project_id) `project_id`) The ID of the project the server is associated with.
311365

@@ -321,6 +375,7 @@ In addition to all arguments above, the following attributes are exported:
321375
- `offer_id` - The ID of the offer.
322376
- `offer_name` - The name of the offer.
323377
- `os_name` - The name of the os.
378+
- `cloud_init` - The cloud-init user-data associated with the server. This value can be either a path to a file containing the user-data or the raw user-data content itself. Updating this field requires a server reboot for the changes to take effect. Only available for OS and offers that support cloud-init.
324379
- `private_network` - The private networks attached to the server.
325380
- `id` - The ID of the private network.
326381
- `mapping_id` - The ID of the Server-to-Private Network mapping.

0 commit comments

Comments
 (0)