-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.tf
More file actions
35 lines (30 loc) · 980 Bytes
/
main.tf
File metadata and controls
35 lines (30 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
terraform {
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
version = "1.40.0"
}
}
}
provider "openstack" {
auth_url = "https://auth.cloud.ovh.net/v3"
domain_name = "default"
}
resource "openstack_compute_keypair_v2" "ansible-keypair" {
name = "ansible"
public_key = file("~/.ssh/ovhcloud.pub")
}
resource "openstack_compute_instance_v2" "test-server" {
name = "ubuntu-test"
image_name = "Ubuntu 20.04" # Ubuntu 20.04 LTS
flavor_name = "s1-2" # Sandbox 2Go RAM / 10Go SSD
key_pair = openstack_compute_keypair_v2.ansible-keypair.name
}
# Generate ansible inventory file
resource "local_file" "inventory" {
filename = "hosts"
content = <<EOF
[sandbox]
${openstack_compute_instance_v2.test-server.name} ansible_host=${openstack_compute_instance_v2.test-server.access_ip_v4} ansible_user=ubuntu ansible_private_key_file=~/.ssh/ovhcloud
EOF
}