I realize that the name 'Linux Provider' is misleading, but I needed this provider and couldn't find a more suitable name.
Requirements
- Terraform 0.12.x
- Go 1.12 (to build the provider plugin)
Usage
provider "linux" {
host = "192.168.1.2"
user = "user"
}
Building The Provider
Clone repository to: $GOPATH/src/github.com/mavidser/terraform-provider-linux
$ mkdir -p $GOPATH/src/github.com/terraform-providers; cd $GOPATH/src/github.com/terraform-providers
$ git clone git@github.com:mavidser/terraform-provider-linux
Enter the provider directory and build the provider
$ cd $GOPATH/src/github.com/mavidser/terraform-provider-linux
$ make build
Using the provider
Sample configuration for creating a few users/groups:
resource "linux_group" "testgroup" {
name = "testgroup"
system = false
}
resource "linux_user" "testuser1" {
name = "testuser1"
gid = linux_group.testgroup.gid
system = false
}
resource "linux_user" "testuser2" {
name = "testuser2"
gid = linux_group.testgroup.gid
system = false
}
Developing the Provider
If you wish to work on the provider, you'll first need Go installed on your machine (version 1.11+ is required). You'll also need to correctly setup a GOPATH, as well as adding $GOPATH/bin
to your $PATH
.
To compile the provider, run make build
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
$ make build
...
$ $GOPATH/bin/terraform-provider-linux
...
In order to test the provider, you can simply run make test
.
Note: These tests will require docker installed to spin up a container with ssh access.
$ make test
In order to run the full suite of Acceptance tests, run make testacc
.
$ make testacc
In order to run only single Acceptance tests, execute the following steps:
# setup the testing environment
$ source ./scripts/tests_setup.sh
# run single tests
TF_LOG=INFO TF_ACC=1 go test -v ./linux -run TestAccUserCreation -timeout 360s
# cleanup the local testing resources
$ source ./scripts/tests_cleanup.sh