In my previous articles, we looked at consuming the OneFuse Modules using the OneFuse Terraform Provider. Although the OneFuse Terraform Module still uses the OneFuse Terraform Provider, it offers a simplified way to consume the different OneFuse Modules.
If you haven’t seen my previous articles it’s a good idea to read through them to gain some familiarity with how the OneFuse Terraform Provider functions. Recommended articles are:
- Terraform with OneFuse: Naming
- Terraform with OneFuse: IPAM
- Terraform with OneFuse: DNS
- Terraform with OneFuse: Active Directory
The OneFuse Terraform module is currently in beta with the latest version as of this writing being v1.2-beta.1. To utilize the module you can define the following source in your terraform configuration file:
Source = “git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git?ref=v1.2-beta.1”
It is also possible to access sub-modules for each available OneFuse module at the follow addresses:
Naming
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//naming?ref=v1.2-beta.1”
IPAM
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ipam?ref=v1.2-beta.1”
DNS
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//dns?ref=v1.2-beta.1”
AD
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ad?ref=v1.2-beta.1”
Scripting
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//scripting?ref=v1.2-beta.1”
Ansible Tower
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ansible?ref=v1.2-beta.1”
Property Toolkit
“git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ptk?ref=v1.2-beta.1”
Naming
Below is an example Terraform configuration for consume naming using the naming terraform module:
// Comment out the following for Terraform 0.12
terraform {
required_providers {
onefuse = {
source = "CloudBoltSoftware/onefuse"
version = ">= 1.20.0"
}
}
required_version = ">= 0.13"
}
// Comment out the above for Terraform 0.12
// Inititalize OneFuse Provider
provider "onefuse" {
scheme = var.onefuse_scheme
address = var.onefuse_address
port = var.onefuse_port
user = var.onefuse_user
password = var.onefuse_password
verify_ssl = var.onefuse_verify_ssl
}
module "name" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//naming?ref=v1.2-beta.1"
policy = var.policy
template_properties = var.template_properties
}
output "hostname" {
value = module.name.hostname
}
output "dns_suffix" {
value = module.name.dns_suffix
}
If you have read my articles covering the use of the OneFuse Terraform provider, you will notice that you no longer need to make two different declarations for naming. With the provider, you need to declare the data source and the resource. With the Terraform module, you simply call the module, pass in your policy and the template_properties
.
IPAM
// Comment out the following for Terraform 0.12
terraform {
required_providers {
onefuse = {
source = "CloudBoltSoftware/onefuse"
version = ">= 1.20.0"
}
}
required_version = ">= 0.13"
}
// Comment out the above for Terraform 0.12
// Inititalize OneFuse Provider
provider "onefuse" {
scheme = var.onefuse_scheme
address = var.onefuse_address
port = var.onefuse_port
user = var.onefuse_user
password = var.onefuse_password
verify_ssl = var.onefuse_verify_ssl
}
module "ipam" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ipam?ref=v1.2-beta.1"
policy = var.policy
hostname = var.hostname
template_properties = var.template_properties
}
output "ip_address" {
value = module.ipam.ip_address
}
output "netmask" {
value = module.ipam.netmask
}
output "gateway" {
value = module.ipam.gateway
}
output "network" {
value = module.ipam.network
}
output "subnet" {
value = module.ipam.network
}
output "primary_dns" {
value = module.ipam.primary_dns
}
output "secondary_dns" {
value = module.ipam.secondary_dns
}
By now I’m sure you see the pattern forming. The OneFuse modules combine the data source and the resource into a single module making it so you only need one declaration in your configurations to consume the integration.
DNS
I’m not going to post the entire configurations for DNS or the remaining modules, with the exception of the module declarations and the outputs the rest of the configuration information is the same.
module "dns" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//dns?ref=v1.2-beta.1"
policy = var.policy
hostname = var.hostname
ip_address = var.ip_address
dns_zones = var.dns_zones
template_properties = var.template_properties
}
Active Directory
module "computer" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ad?ref=v1.2-beta.1"
policy = var.policy
hostname = var.hostname
template_properties = var.template_properties
}
Scripting
module "script" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//scripting?ref=v1.2-beta.1"
policy = var.policy
template_properties = var.template_properties
}
Ansible Tower
module "ansible_job" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git//ansible?ref=v1.2-beta.1"
policy = var.policy
hostname = var.hostname
template_properties = var.template_properties
}
The necessary inputs for each OneFuse module remain the same. It gets a little easier if you are looking to call all of the OneFuse foundation modules. Foundations are naming, IPAM, DNS, and Active Directory. If you are wanting to call all four there is no need to call each module individually. You can simple consume the parent OneFuse Terraform Module like below:
module "onefuse" {
source = "git::https://github.com/CloudBoltSoftware/terraform-module-onefuse.git?ref=v1.2-beta.1"
name_policy = var.name_policy
ipam_policy = var.ipam_policy
dns_policy = var.dns_policy
ad_policy = var.ad_policy
template_properties = var.template_properties
}
Visit the onefuse-examples github repo for more examples as well as sample modules for consuming OneFuse modules with other Terraform providers.
Want to try OneFuse with Terraform for yourself? Check out the WWT HOL Accelerating Terraform with OneFuse.