Skip to content

Commit da32e70

Browse files
committed
Initial Commit
0 parents  commit da32e70

15 files changed

+777
-0
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Local .terraform directories
2+
**/.terraform/*
3+
4+
# .tfstate files
5+
*.tfstate
6+
*.tfstate.*
7+
8+
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
9+
# .tfvars files are managed as part of configuration and so should be included in
10+
# version control.
11+
#
12+
# example.tfvars
13+
*.tfvars
14+
15+
# IntelliJ project files
16+
.idea
17+
*.iml
18+
out
19+
gen

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Deploy PowerDNS with Terraform
2+
Used to provision a PowerDNS server with PowerDNS-Admin interface in a libvirt environment
3+
4+
Adapted from - https://blog.jonaharagon.com/installing-powerdns-admin-on-ubuntu-18-04/
5+
6+
Note: This project is customized for KVM servers running Openvswitch. Installation of these dependencies can be
7+
complex and is outside the scope of this project.
8+
9+
The PowerDNS server configuration provided by this project will install an authoritative and recursive server as documented here:
10+
11+
- https://doc.powerdns.com/authoritative/guides/recursion.html#scenario-1-authoritative-server-as-recursor-with-private-zones
12+
13+
It has also been customized for use with the Terraform PowerDNS provider.
14+
- https://www.terraform.io/docs/providers/powerdns/index.html
15+
16+
### Prereqs
17+
KVM Server running Openvswitch
18+
19+
- https://github.com/mrlesmithjr/ansible-kvm
20+
- https://docs.openvswitch.org/en/latest/intro/install/distributions/
21+
22+
Terraform and the terraform-provider-libvirt
23+
24+
- https://www.terraform.io/downloads.html
25+
- https://github.com/dmacvicar/terraform-provider-libvirt#installing
26+
27+
28+
### Setup
29+
Clone Repository
30+
```bash
31+
git clone https://github.com/2stacks/terraform-powerdns.git
32+
cd terraform-powerdns
33+
```
34+
35+
Create secrets variable file, add your SSH public key and update database passwords.
36+
```bash
37+
cp secret.auto.tfvars.example secret.auto.tfvars
38+
```
39+
40+
Deploy libvirt guest with Terraform
41+
```bash
42+
terraform init
43+
terraform plan
44+
terraform apply
45+
```
46+
47+
When Terraform finishes it will output the libvirt guest IP
48+
49+
Example:
50+
```bash
51+
Outputs:
52+
53+
ip = [
54+
[
55+
192.168.100.12,
56+
fe80::5054:ff:fec2:43bd
57+
]
58+
]
59+
```
60+
61+
Open `https://(output_ip)/login` in your browser and register a new admin account.
62+
63+
### TODO
64+
- Secure PowerDNS-Admin interface with LetsEncrypt
65+
- Secure PowerDNS API server with LetsEncrypt
66+
- Move Terraform 'remote-exec' calls to shell scripts

default-vars.tf

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# CloudInit Variables
2+
variable "user_name" {}
3+
variable "ssh_authorized-key" {}
4+
5+
# DNS/Mysql Variables
6+
variable "mysql_root_pass" {}
7+
variable "mysql_user" {}
8+
variable "mysql_user_pass" {}
9+
variable "api_key" {}
10+
11+
variable "api_allow_from" {
12+
description = "Define networks allowed to access PowerDNS API"
13+
default = "127.0.0.1"
14+
}
15+
16+
# Libvirt Variables
17+
variable "libvirt_uri" {
18+
description = "URI of server running libvirtd"
19+
default = "qemu:///system"
20+
}
21+
22+
variable "prefix" {
23+
description = "Resources will be prefixed with this to avoid clashing names"
24+
default = "pub-dns"
25+
}
26+
27+
variable "guest_count" {
28+
description = "Number of Guests to Create"
29+
default = "1"
30+
}
31+
32+
variable "libvirt_volume_source" {
33+
description = "Volume Image Source"
34+
default = "https://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img"
35+
}
36+
37+
variable "libvirt_volume_pool" {
38+
description = "Volume Storage Pool"
39+
default = "default"
40+
}
41+
42+
variable "libvirt_volume_size" {
43+
description = "Volume Size in Bytes"
44+
default = "21474836480"
45+
}
46+
47+
variable "mac_prefix" {
48+
description = "Must change before deploying in new subnet"
49+
default = "52:54:00:00:06"
50+
}
51+
52+
variable "hostname" {
53+
description = "Guest Hostname"
54+
default = "ns"
55+
}
56+
57+
variable "nameserver" {
58+
description = "Default DNS server for host"
59+
default = "127.0.0.1"
60+
}
61+
62+
variable "domain_name" {
63+
description = "Default Domain Name for host"
64+
default = "xip.io"
65+
}
66+
67+
variable "memory" {
68+
default = "2048"
69+
}
70+
71+
variable "vcpu" {
72+
default = "2"
73+
}
74+
75+
variable "network" {
76+
description = "Name of Libvirt Network"
77+
default = "default"
78+
}
79+
80+
variable "port_group" {
81+
description = "Name of OVS Port Group"
82+
default = "default"
83+
}
84+
85+
# SSL Variables
86+
variable "ssl_ou" {
87+
description = "SSL Organizational Unit"
88+
default = "IT Departement"
89+
}
90+
91+
variable "ssl_o" {
92+
description = "SSL Organization"
93+
default = "DNS"
94+
}
95+
96+
variable "ssl_l" {
97+
description = "SSL Location"
98+
default = "Mountain View"
99+
}
100+
101+
variable "ssl_st" {
102+
description = "SSL State"
103+
default = "California"
104+
}
105+
106+
variable "ssl_c" {
107+
description = "SSL Country"
108+
default = "US"
109+
}

0 commit comments

Comments
 (0)