|
1 | 1 | # Configure the Scaleway Provider |
2 | 2 | provider "scaleway" { |
3 | | - organization = "${var.scw_org}" |
4 | | - token = "${var.scw_token}" |
5 | | - region = "${var.region}" |
| 3 | + access_key = var.scw_access_key |
| 4 | + organization_id = var.scw_org |
| 5 | + secret_key = var.scw_token |
| 6 | + region = var.region |
| 7 | + zone = var.zone |
6 | 8 | } |
7 | 9 |
|
| 10 | +variable "scw_access_key" {} |
| 11 | + |
8 | 12 | variable "scw_org" {} |
9 | 13 |
|
10 | 14 | variable "scw_token" {} |
@@ -45,107 +49,107 @@ variable "region" { |
45 | 49 | default = "par1" |
46 | 50 | } |
47 | 51 |
|
| 52 | +variable "zone" { |
| 53 | + default = "fr-par-1" |
| 54 | +} |
| 55 | + |
48 | 56 | variable "docker_version_agent" { |
49 | | - default = "17.03" |
| 57 | + default = "19.03" |
50 | 58 | } |
51 | 59 |
|
52 | 60 | variable "type" { |
53 | | - default = "START1-S" |
| 61 | + default = "DEV1-S" |
54 | 62 | } |
55 | 63 |
|
56 | 64 | variable "rancher_server_address" {} |
57 | 65 |
|
58 | | -data "scaleway_image" "xenial" { |
59 | | - architecture = "x86_64" |
60 | | - name = "Ubuntu Xenial" |
61 | | -} |
62 | | - |
63 | | -resource "scaleway_server" "rancheragent_all" { |
64 | | - count = "${var.count_agent_all_nodes}" |
65 | | - image = "${data.scaleway_image.xenial.id}" |
66 | | - type = "${var.type}" |
67 | | - name = "${var.prefix}-rancheragent-${count.index}-all" |
68 | | - security_group = "${scaleway_security_group.allowall.id}" |
69 | | - dynamic_ip_required = true |
70 | | -} |
71 | | - |
72 | | -resource "scaleway_user_data" "rancheragent_all" { |
73 | | - count = "${var.count_agent_all_nodes}" |
74 | | - server = "${scaleway_server.rancheragent_all.*.id[count.index]}" |
75 | | - key = "cloud-init" |
76 | | - value = "${data.template_file.userdata_agent.rendered}" |
77 | | -} |
78 | | - |
79 | | -resource "scaleway_server" "rancheragent_etcd" { |
80 | | - count = "${var.count_agent_etcd_nodes}" |
81 | | - image = "${data.scaleway_image.xenial.id}" |
82 | | - type = "${var.type}" |
83 | | - name = "${var.prefix}-rancheragent-${count.index}-etcd" |
84 | | - security_group = "${scaleway_security_group.allowall.id}" |
85 | | - dynamic_ip_required = true |
86 | | -} |
87 | | - |
88 | | -resource "scaleway_user_data" "rancheragent_etcd" { |
89 | | - count = "${var.count_agent_etcd_nodes}" |
90 | | - server = "${scaleway_server.rancheragent_etcd.*.id[count.index]}" |
91 | | - key = "cloud-init" |
92 | | - value = "${data.template_file.userdata_agent.rendered}" |
93 | | -} |
94 | | - |
95 | | -resource "scaleway_server" "rancheragent_controlplane" { |
96 | | - count = "${var.count_agent_controlplane_nodes}" |
97 | | - image = "${data.scaleway_image.xenial.id}" |
98 | | - type = "${var.type}" |
99 | | - name = "${var.prefix}-rancheragent-${count.index}-controlplane" |
100 | | - security_group = "${scaleway_security_group.allowall.id}" |
101 | | - dynamic_ip_required = true |
102 | | -} |
103 | | - |
104 | | -resource "scaleway_user_data" "rancheragent_controlplane" { |
105 | | - count = "${var.count_agent_controlplane_nodes}" |
106 | | - server = "${scaleway_server.rancheragent_controlplane.*.id[count.index]}" |
107 | | - key = "cloud-init" |
108 | | - value = "${data.template_file.userdata_agent.rendered}" |
| 66 | +resource "scaleway_instance_server" "rancheragent_all" { |
| 67 | + count = var.count_agent_all_nodes |
| 68 | + image = "ubuntu-bionic" |
| 69 | + type = var.type |
| 70 | + name = "${var.prefix}-rancheragent-${count.index}-all" |
| 71 | + security_group_id = scaleway_instance_security_group.allowall.id |
| 72 | + enable_dynamic_ip = true |
| 73 | + cloud_init = templatefile("${path.module}/files/userdata_agent", { |
| 74 | + admin_password = var.admin_password |
| 75 | + cluster_name = var.cluster_name |
| 76 | + docker_version_agent = var.docker_version_agent |
| 77 | + rancher_version = var.rancher_version |
| 78 | + server_address = var.rancher_server_address |
| 79 | + }) |
| 80 | + root_volume { |
| 81 | + size_in_gb = 40 |
| 82 | + delete_on_termination = false |
| 83 | + } |
109 | 84 | } |
110 | 85 |
|
111 | | -resource "scaleway_server" "rancheragent_worker" { |
112 | | - count = "${var.count_agent_worker_nodes}" |
113 | | - image = "${data.scaleway_image.xenial.id}" |
114 | | - type = "${var.type}" |
115 | | - name = "${var.prefix}-rancheragent-${count.index}-worker" |
116 | | - security_group = "${scaleway_security_group.allowall.id}" |
117 | | - dynamic_ip_required = true |
| 86 | +resource "scaleway_instance_server" "rancheragent_etcd" { |
| 87 | + count = var.count_agent_etcd_nodes |
| 88 | + image = "ubuntu-bionic" |
| 89 | + type = var.type |
| 90 | + name = "${var.prefix}-rancheragent-${count.index}-etcd" |
| 91 | + security_group_id = scaleway_instance_security_group.allowall.id |
| 92 | + enable_dynamic_ip = true |
| 93 | + cloud_init = templatefile("${path.module}/files/userdata_agent", { |
| 94 | + admin_password = var.admin_password |
| 95 | + cluster_name = var.cluster_name |
| 96 | + docker_version_agent = var.docker_version_agent |
| 97 | + rancher_version = var.rancher_version |
| 98 | + server_address = var.rancher_server_address |
| 99 | + }) |
| 100 | + root_volume { |
| 101 | + size_in_gb = 40 |
| 102 | + delete_on_termination = false |
| 103 | + } |
118 | 104 | } |
119 | 105 |
|
120 | | -resource "scaleway_user_data" "rancheragent_worker" { |
121 | | - count = "${var.count_agent_worker_nodes}" |
122 | | - server = "${scaleway_server.rancheragent_worker.*.id[count.index]}" |
123 | | - key = "cloud-init" |
124 | | - value = "${data.template_file.userdata_agent.rendered}" |
| 106 | +resource "scaleway_instance_server" "rancheragent_controlplane" { |
| 107 | + count = var.count_agent_controlplane_nodes |
| 108 | + image = "ubuntu-bionic" |
| 109 | + type = var.type |
| 110 | + name = "${var.prefix}-rancheragent-${count.index}-controlplane" |
| 111 | + security_group_id = scaleway_instance_security_group.allowall.id |
| 112 | + enable_dynamic_ip = true |
| 113 | + cloud_init = templatefile("${path.module}/files/userdata_agent", { |
| 114 | + admin_password = var.admin_password |
| 115 | + cluster_name = var.cluster_name |
| 116 | + docker_version_agent = var.docker_version_agent |
| 117 | + rancher_version = var.rancher_version |
| 118 | + server_address = var.rancher_server_address |
| 119 | + }) |
| 120 | + root_volume { |
| 121 | + size_in_gb = 40 |
| 122 | + delete_on_termination = false |
| 123 | + } |
125 | 124 | } |
126 | 125 |
|
127 | | -data "template_file" "userdata_agent" { |
128 | | - template = "${file("files/userdata_agent")}" |
129 | | - |
130 | | - vars { |
131 | | - admin_password = "${var.admin_password}" |
132 | | - cluster_name = "${var.cluster_name}" |
133 | | - docker_version_agent = "${var.docker_version_agent}" |
134 | | - rancher_version = "${var.rancher_version}" |
135 | | - server_address = "${var.rancher_server_address}" |
| 126 | +resource "scaleway_instance_server" "rancheragent_worker" { |
| 127 | + count = var.count_agent_worker_nodes |
| 128 | + image = "ubuntu-bionic" |
| 129 | + type = var.type |
| 130 | + name = "${var.prefix}-rancheragent-${count.index}-worker" |
| 131 | + security_group_id = scaleway_instance_security_group.allowall.id |
| 132 | + enable_dynamic_ip = true |
| 133 | + cloud_init = templatefile("${path.module}/files/userdata_agent", { |
| 134 | + admin_password = var.admin_password |
| 135 | + cluster_name = var.cluster_name |
| 136 | + docker_version_agent = var.docker_version_agent |
| 137 | + rancher_version = var.rancher_version |
| 138 | + server_address = var.rancher_server_address |
| 139 | + }) |
| 140 | + root_volume { |
| 141 | + size_in_gb = 40 |
| 142 | + delete_on_termination = false |
136 | 143 | } |
137 | 144 | } |
138 | 145 |
|
139 | | -resource "scaleway_security_group" "allowall" { |
| 146 | +resource "scaleway_instance_security_group" "allowall" { |
140 | 147 | name = "${var.prefix}-rancher-agent-allowall" |
141 | 148 | description = "allow all traffic" |
142 | | -} |
143 | 149 |
|
144 | | -resource "scaleway_security_group_rule" "all_accept" { |
145 | | - security_group = "${scaleway_security_group.allowall.id}" |
146 | | - |
147 | | - action = "accept" |
148 | | - direction = "inbound" |
149 | | - ip_range = "0.0.0.0/0" |
150 | | - protocol = "TCP" |
| 150 | + inbound_rule { |
| 151 | + action = "accept" |
| 152 | + ip_range = "0.0.0.0/0" |
| 153 | + protocol = "TCP" |
| 154 | + } |
151 | 155 | } |
0 commit comments