-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Terraform provider for Mreg, first commit
- Loading branch information
1 parent
bf96c23
commit 83023d4
Showing
23 changed files
with
702 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
--- | ||
page_title: "scaffolding Provider" | ||
page_title: "Provider: Mreg" | ||
subcategory: "" | ||
description: |- | ||
The Mreg provider provides resources to interact with [Mreg](https://github.com/unioslo/mreg/) through the API. | ||
--- | ||
|
||
# scaffolding Provider | ||
# Mreg Provider | ||
|
||
The Mreg provider provides resources to interact with [Mreg](https://github.com/unioslo/mreg/) through the API. | ||
|
||
## Example usage | ||
|
||
## Example Usage | ||
provider "mreg" { | ||
serverurl = "https://mreg.example.com/" | ||
token = "1234567890ABCDEF" | ||
} | ||
|
||
```terraform | ||
provider "scaffolding" { | ||
# example configuration here | ||
} | ||
``` | ||
### Required configuration options | ||
|
||
## Schema | ||
- **serverurl** (String) | ||
- **token** (String, Sensitive) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
page_title: "mreg_dns_srv Resource - terraform-provider-mreg" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# Resource `mreg_dns_srv` | ||
|
||
|
||
|
||
|
||
|
||
## Schema | ||
|
||
### Required | ||
|
||
- **name** (String) | ||
- **port** (Number) | ||
- **priority** (Number) | ||
- **proto** (String) | ||
- **service** (String) | ||
- **target_host** (String) | ||
- **weight** (Number) | ||
|
||
### Optional | ||
|
||
- **id** (String) The ID of this resource. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
page_title: "mreg_hosts Resource - terraform-provider-mreg" | ||
subcategory: "" | ||
description: |- | ||
--- | ||
|
||
# Resource `mreg_hosts` | ||
|
||
|
||
|
||
|
||
|
||
## Schema | ||
|
||
### Required | ||
|
||
- **contact** (String) | ||
- **host** (Block List, Min: 1) (see [below for nested schema](#nestedblock--host)) | ||
- **network** (String) | ||
|
||
### Optional | ||
|
||
- **comment** (String) | ||
- **id** (String) The ID of this resource. | ||
|
||
<a id="nestedblock--host"></a> | ||
### Nested Schema for `host` | ||
|
||
Required: | ||
|
||
- **name** (String) | ||
|
||
Optional: | ||
|
||
- **manual_ipaddress** (String) | ||
|
||
Read-only: | ||
|
||
- **comment** (String) | ||
- **contact** (String) | ||
- **ipaddress** (String) | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
terraform { | ||
required_providers { | ||
mreg = { | ||
version = "0.1.0" | ||
source = "uio.no/usit/mreg" | ||
} | ||
} | ||
} | ||
|
||
provider "mreg" { | ||
serverurl = "https://mreg-test01.example.com/" | ||
token = "1234567890ABCDEF" # replace with actual token | ||
} | ||
|
||
resource "mreg_hosts" "my_hosts" { | ||
# You can supply more than one host in one resource | ||
host { | ||
name = "terraform-provider-test01.example.com" | ||
} | ||
host { | ||
name = "terraform-provider-test02.example.com" | ||
# You can also manually pick an ip address instead of getting assigned a free one | ||
manual_ipaddress = "192.0.2.55" | ||
} | ||
host { | ||
name = "terraform-provider-test03.example.com" | ||
} | ||
contact = "your.email.address@example.com" | ||
comment = "Created by the Terraform provider for Mreg" | ||
network = "192.0.2.0/24" | ||
} | ||
|
||
locals { | ||
hostnames = toset(["test01.terraform-provider-test.example.com", "test02.terraform-provider-test.example.com"]) | ||
} | ||
|
||
resource "mreg_hosts" "loop_hosts" { | ||
# You can loop through a set of hostnames like this | ||
for_each = local.hostnames | ||
host { | ||
name = each.key | ||
} | ||
contact = "your.email.address@example.com" | ||
comment = "Created by the Terraform provider for Mreg" | ||
network = "192.0.2.0/24" | ||
} | ||
|
||
# Here's how to create SRV records | ||
resource "mreg_dns_srv" "srv" { | ||
depends_on = [mreg_hosts.loop_hosts] | ||
for_each = local.hostnames | ||
target_host = each.key | ||
service = "mysql" | ||
proto = "tcp" | ||
name = "terraform-provider-test.example.com" | ||
priority = 0 | ||
weight = 5 | ||
port = 3306 | ||
} | ||
|
||
output "foo" { | ||
value = mreg_hosts.my_hosts | ||
} | ||
|
||
output "bar" { | ||
value = mreg_hosts.loop_hosts | ||
} | ||
|
||
output "baz" { | ||
value = mreg_dns_srv.srv | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -e | ||
cd `dirname $0` | ||
pushd .. >/dev/null | ||
rm -f terraform-provider-mreg | ||
go get -v | ||
go build | ||
#TODO after the provider is added to the registry, there's no need to copy the file here | ||
rm -rf ~/.terraform.d/plugins/uio.no/usit/mreg/ | ||
mkdir -p ~/.terraform.d/plugins/uio.no/usit/mreg/0.1.0/linux_amd64 | ||
cp terraform-provider-mreg ~/.terraform.d/plugins/uio.no/usit/mreg/0.1.0/linux_amd64/ | ||
popd >/dev/null | ||
rm -rf .terraform .terraform.lock.hcl terraform.tfstate crash.log | ||
terraform init | ||
terraform apply -auto-approve -parallelism=10 | ||
terraform plan -detailed-exitcode # If there's a diff, the provider is not refreshing the state correctly | ||
terraform destroy -auto-approve | ||
echo Everything works! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
module github.com/hashicorp/terraform-provider-scaffolding | ||
module github.com/unioslo/terraform-provider-mreg | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/hashicorp/terraform-plugin-docs v0.3.0 | ||
github.com/hashicorp/terraform-plugin-sdk/v2 v2.4.0 | ||
github.com/juju/fslock v0.0.0-20160525022230-4d5c94c67b4b | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.