File tree Expand file tree Collapse file tree 4 files changed +115
-32
lines changed
modules/libvirt/bootstrap Expand file tree Collapse file tree 4 files changed +115
-32
lines changed Original file line number Diff line number Diff line change
1
+ # Bootstrap Module
2
+
3
+ This [ Terraform] [ ] [ module] [ ] manages [ libvirt] [ ] resources only needed during cluster bootstrapping.
4
+ It uses [ implicit provider inheritance] [ implicit-provider-inheritance ] to access the [ libvirt provider] [ libvirt-provider ] .
5
+
6
+ ## Example
7
+
8
+ Set up a ` main.tf ` with:
9
+
10
+ ``` hcl
11
+ provider "libvirt" {
12
+ uri = "qemu:///system"
13
+ }
14
+
15
+ resource "libvirt_network" "example" {
16
+ name = "example"
17
+ mode = "none"
18
+ domain = "example.com"
19
+ addresses = ["192.168.0.0/24"]
20
+ }
21
+
22
+ resource "libvirt_volume" "example" {
23
+ name = "example"
24
+ source = "file:///path/to/example.qcow2"
25
+ }
26
+
27
+ module "bootstrap" {
28
+ source = "github.com/openshift/installer//modules/libvirt/bootstrap"
29
+
30
+ addresses = ["192.168.0.1"]
31
+ base_volume_id = "${libvirt_volume.example.id}"
32
+ cluster_name = "my-cluster"
33
+ ignition = "{\"ignition\": {\"version\": \"2.2.0\"}}",
34
+ network_id = "${libvirt_network.example.id}"
35
+ }
36
+ ```
37
+
38
+ Then run:
39
+
40
+ ``` console
41
+ $ terraform init
42
+ $ terraform plan
43
+ ```
44
+
45
+ [ libvirt ] : https://libvirt.org/
46
+ [ libvirt-provider ] : https://github.com/dmacvicar/terraform-provider-libvirt
47
+ [ implicit-provider-inheritance ] : https://www.terraform.io/docs/modules/usage.html#implicit-provider-inheritance
48
+ [ module ] : https://www.terraform.io/docs/modules/
49
+ [ Terraform ] : https://www.terraform.io/
Original file line number Diff line number Diff line change
1
+ resource "libvirt_volume" "bootstrap" {
2
+ name = " bootstrap"
3
+ base_volume_id = " ${ var . base_volume_id } "
4
+ }
5
+
6
+ resource "libvirt_ignition" "bootstrap" {
7
+ name = " bootstrap.ign"
8
+ content = " ${ var . ignition } "
9
+ }
10
+
11
+ resource "libvirt_domain" "bootstrap" {
12
+ name = " bootstrap"
13
+
14
+ memory = " 2048"
15
+
16
+ vcpu = " 2"
17
+
18
+ coreos_ignition = " ${ libvirt_ignition . bootstrap . id } "
19
+
20
+ disk {
21
+ volume_id = " ${ libvirt_volume . bootstrap . id } "
22
+ }
23
+
24
+ console {
25
+ type = " pty"
26
+ target_port = 0
27
+ }
28
+
29
+ network_interface {
30
+ network_id = " ${ var . network_id } "
31
+ hostname = " ${ var . cluster_name } -bootstrap"
32
+ addresses = " ${ var . addresses } "
33
+ }
34
+ }
Original file line number Diff line number Diff line change
1
+ variable "addresses" {
2
+ type = " list"
3
+ default = []
4
+ description = " IP addresses to assign to the boostrap node."
5
+ }
6
+
7
+ variable "base_volume_id" {
8
+ type = " string"
9
+ description = " The ID of the base volume for the bootstrap node."
10
+ }
11
+
12
+ variable "cluster_name" {
13
+ type = " string"
14
+ description = " The name of the cluster."
15
+ }
16
+
17
+ variable "ignition" {
18
+ type = " string"
19
+ description = " The content of the bootstrap ignition file."
20
+ }
21
+
22
+ variable "network_id" {
23
+ type = " string"
24
+ description = " The ID of a network resource containing the bootstrap node's addresses."
25
+ }
Original file line number Diff line number Diff line change @@ -2,37 +2,12 @@ provider "libvirt" {
2
2
uri = " ${ var . tectonic_libvirt_uri } "
3
3
}
4
4
5
- resource "libvirt_volume" "bootstrap" {
6
- name = " bootstrap"
7
- base_volume_id = " ${ local . libvirt_base_volume_id } "
8
- }
9
-
10
- resource "libvirt_ignition" "bootstrap" {
11
- name = " bootstrap.ign"
12
- content = " ${ local . ignition_bootstrap } "
13
- }
14
-
15
- resource "libvirt_domain" "bootstrap" {
16
- name = " bootstrap"
17
-
18
- memory = " 2048"
5
+ module "bootstrap" {
6
+ source = " ../../../modules/libvirt/bootstrap"
19
7
20
- vcpu = " 2"
21
-
22
- coreos_ignition = " ${ libvirt_ignition . bootstrap . id } "
23
-
24
- disk {
25
- volume_id = " ${ libvirt_volume . bootstrap . id } "
26
- }
27
-
28
- console {
29
- type = " pty"
30
- target_port = 0
31
- }
32
-
33
- network_interface {
34
- network_id = " ${ local . libvirt_network_id } "
35
- hostname = " ${ var . tectonic_cluster_name } -bootstrap"
36
- addresses = [" ${ var . tectonic_libvirt_bootstrap_ip } " ]
37
- }
8
+ addresses = [" ${ var . tectonic_libvirt_bootstrap_ip } " ]
9
+ base_volume_id = " ${ local . libvirt_base_volume_id } "
10
+ cluster_name = " ${ var . tectonic_cluster_name } "
11
+ ignition = " ${ local . ignition_bootstrap } "
12
+ network_id = " ${ local . libvirt_network_id } "
38
13
}
You can’t perform that action at this time.
0 commit comments