Skip to content

Commit 1ce6539

Browse files
committed
Initial implementation
1 parent c46f927 commit 1ce6539

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

cloud-init-user-data

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#cloud-config
2+
3+
package_update: true
4+
package_upgrade: true
5+
6+
packages:
7+
- curl
8+
- git
9+
- zsh
10+
11+
runcmd:
12+
# install Oh My ZSH
13+
- 'git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git /root/.oh-my-zsh'
14+
- 'cp /root/.oh-my-zsh/templates/zshrc.zsh-template /root/.zshrc'
15+
- 'sed -i "s/ZSH_THEME=\".*\"/ZSH_THEME=\"ys\"/" /root/.zshrc'
16+
- 'chsh -s /usr/bin/zsh'

main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
data "scaleway_image" "image" {
2+
count = "${var.node_count > 0 ? 1 : 0}"
3+
4+
architecture = "${var.server_arch}"
5+
name = "${var.server_image}"
6+
}
7+
8+
resource "scaleway_server" "node" {
9+
count = "${var.node_count}"
10+
11+
name = "${var.node_name}-${count.index}"
12+
13+
image = "${data.scaleway_image.image.id}"
14+
type = "${var.server_type}"
15+
dynamic_ip_required = true
16+
}
17+
18+
data "template_file" "userdata" {
19+
template = "${file("${path.module}/cloud-init-user-data")}"
20+
}
21+
22+
resource "scaleway_user_data" "ud" {
23+
count = "${var.node_count}"
24+
server = "${element(scaleway_server.node.*.id, count.index)}"
25+
key = "cloud-init"
26+
value = "${data.template_file.userdata.rendered}"
27+
}

outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "public_ips" {
2+
value = "${scaleway_server.node.*.public_ip}"
3+
}
4+

variables.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
variable "node_count" {
2+
type = "string"
3+
default = "1"
4+
}
5+
6+
variable "node_name" {
7+
type = "string"
8+
default = "cloud-init"
9+
}
10+
11+
variable "server_arch" {
12+
type = "string"
13+
default = "x86_64"
14+
}
15+
16+
variable "server_image" {
17+
type = "string"
18+
default = "Ubuntu Bionic"
19+
}
20+
21+
variable "server_type" {
22+
type = "string"
23+
default = "START1-S"
24+
}

0 commit comments

Comments
 (0)