项目作者: GSLabDev

项目描述 :
Automates the Active Directory resource creation during Infrastructure build using Terraform Provider.
高级语言: Go
项目地址: git://github.com/GSLabDev/terraform-provider-ad.git
创建时间: 2017-09-20T13:06:19Z
项目社区:https://github.com/GSLabDev/terraform-provider-ad

开源协议:Mozilla Public License 2.0

下载


Terraform Active Directory Provider

This is the repository for the Terraform Active Directory Provider, which one can use
with Terraform to work with Active Directory.

Coverage is currently only limited to a one resource only computer, but in the coming months we are planning release coverage for most essential Active Directory workflows.
Watch this space!

For general information about Terraform, visit the official website and the
GitHub project page.

Using the Provider

The current version of this provider requires Terraform v0.10.2 or higher to
run.

Note that you need to run terraform init to fetch the provider before
deploying. Read about the provider split and other changes to TF v0.10.0 in the
official release announcement found here.

Full Provider Documentation

The provider is useful in adding computers to Active Directory.

Example

  1. # Configure the Active Directory Provider
  2. provider "ad" {
  3. domain = var.ad_server_domain
  4. user = var.ad_server_user
  5. password = var.ad_server_password
  6. ip = var.ad_server_ip
  7. }
  8. # Add computer to Active Directory
  9. resource "ad_computer" "foo" {
  10. domain = var.ad_domain
  11. computer_name = "terraformSample"
  12. description = "terraform sample server"
  13. }
  14. # Add computer to Organizational Unit of Active Directory
  15. resource "ad_computer_to_ou" "bar" {
  16. ou_distinguished_name = var.ad_ou_dn
  17. computer_name = "terraformOuSample"
  18. description = "terraform sample server to OU"
  19. }
  20. # Add group to Organizational Unit of Active Directory
  21. resource "ad_group_to_ou" "baz" {
  22. ou_distinguished_name = var.ad_ou_dn
  23. group_name = "terraformGroupSample"
  24. description = "terraform sample group to OU"
  25. }
  26. # Add User to Active Directory
  27. resource "ad_user" "foo1"{
  28. domain ="domain"
  29. first_name = "firstname"
  30. last_name = "lastname"
  31. logon_name = "logonname"
  32. email = "logonname@domain"
  33. password = "password"
  34. }
  35. # Add Organizational Unit to Active Directory
  36. resource "ad_organizational_unit" "test" {
  37. ou_name = "eample-ou"
  38. domain = "example.com"
  39. }

Building The Provider

NOTE: Unless you are developing or require a pre-release bugfix or feature,
you will want to use the officially released version of the provider (see the
section above
).

Cloning the Project

First, you will want to clone the repository to
$GOPATH/src/github.com/terraform-providers/terraform-provider-ad:

  1. mkdir -p $GOPATH/src/github.com/terraform-providers
  2. cd $GOPATH/src/github.com/terraform-providers
  3. git clone git@github.com:terraform-providers/terraform-provider-ad

Running the Build

After the clone has been completed, you can enter the provider directory and
build the provider.

  1. cd $GOPATH/src/github.com/terraform-providers/terraform-provider-ad
  2. make build

Installing the Local Plugin

After the build is complete, copy the terraform-provider-ad binary into
the same path as your terraform binary, and re-run terraform init.

After this, your project-local .terraform/plugins/ARCH/lock.json (where ARCH
matches the architecture of your machine) file should contain a SHA256 sum that
matches the local plugin. Run shasum -a 256 on the binary to verify the values
match.

Developing the Provider

If you wish to work on the provider, you’ll first need Go installed on your
machine (version 1.9+ is required). You’ll also need to correctly setup a
GOPATH, as well as adding $GOPATH/bin to your $PATH.

See Building the Provider for details on building the provider.

Testing the Provider

NOTE: Testing the Active Directory provider is currently a complex operation as it
requires having a Active Directory Server to test against.

Configuring Environment Variables

Most of the tests in this provider require a comprehensive list of environment
variables to run. See the individual *_test.go files in the
ad/ directory for more details. The next section also
describes how you can manage a configuration file of the test environment
variables.

Using the .tf-ad-devrc.mk file

The tf-ad-devrc.mk.example file contains
an up-to-date list of environment variables required to run the acceptance
tests. Copy this to $HOME/.tf-ad-devrc.mk and change the permissions to
something more secure (ie: chmod 600 $HOME/.tf-ad-devrc.mk), and
configure the variables accordingly.

Running the Acceptance Tests

After this is done, you can run the acceptance tests by running:

  1. $ make testacc

If you want to run against a specific set of tests, run make testacc with the
TESTARGS parameter containing the run mask as per below:

  1. make testacc TESTARGS="-run=TestAccAdComputer_Basic"

OR

  1. make testacc TESTARGS="-run=TestAccAdComputerToOU_Basic"

This following example would run all of the acceptance tests matching
TestAccAdComputer_Basic OR TestAccAdComputerToOU_Basic. Change this for the
specific tests you want to run.