-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #119 from OctopusDeploy/beta-candidate-01
Beta candidate 01
- Loading branch information
Showing
419 changed files
with
23,485 additions
and
6,410 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 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,37 @@ | ||
TEST?=$$(go list ./... | grep -v 'vendor') | ||
HOSTNAME=octopus.com | ||
NAMESPACE=com | ||
NAME=octopusdeploy | ||
BINARY=terraform-provider-${NAME} | ||
VERSION=0.6 | ||
OS_ARCH=darwin_amd64 | ||
|
||
default: install | ||
|
||
build: | ||
go build -o ${BINARY} | ||
|
||
release: | ||
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 | ||
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 | ||
GOOS=freebsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_freebsd_amd64 | ||
GOOS=freebsd GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_freebsd_arm | ||
GOOS=linux GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_linux_386 | ||
GOOS=linux GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_linux_amd64 | ||
GOOS=linux GOARCH=arm go build -o ./bin/${BINARY}_${VERSION}_linux_arm | ||
GOOS=openbsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_openbsd_386 | ||
GOOS=openbsd GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_openbsd_amd64 | ||
GOOS=solaris GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_solaris_amd64 | ||
GOOS=windows GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_windows_386 | ||
GOOS=windows GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_windows_amd64 | ||
|
||
install: build | ||
mkdir -p ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} | ||
mv ${BINARY} ~/.terraform.d/plugins/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH} | ||
|
||
test: | ||
go test -i $(TEST) || exit 1 | ||
echo $(TEST) | xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4 | ||
|
||
testacc: | ||
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m |
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 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,42 @@ | ||
# Step 1 - Why Terraform? | ||
|
||
If you're new to Terraform in general, it may be in your best interest to start with some Terraform Getting Started Docs. | ||
|
||
[Getting Started](https://www.terraform.io/intro/index.html) | ||
|
||
## Why Terraform? | ||
|
||
Terraform has been the go-to for Infrastructure-as-code and quite frankly, Service-as-code for several organizations. You can essentially create anything including: | ||
1. Azure Web Apps | ||
2. Virtual Machines | ||
3. Networks | ||
4. Kubernetes Clusters | ||
5. On-prem resources | ||
|
||
And so much more... | ||
|
||
The idea behind taking infrastructure that you would typically create manually and writing code to deploy it is: | ||
1. You don't have to worry about manual efforts, especially if you have multiple pieces of an environment to set up. | ||
2. You can store the code in source control for anyone to have the ability to work on and contribute to it. | ||
3. Less mistakes happen in code vs creating resources manually because you can integrate tests and checks of the code. | ||
4. You can automatically deploy the code to create resources and don't even have to run the code in an adhoc fashion. | ||
|
||
## Why Terraform for Octopus Deploy? | ||
Well, the same rules apply for the *Why Terraform?* section. You want the ability to create resources automatically instead of manually going through a UI. | ||
|
||
With Terraform and the Octopus Deploy provider, you can create: | ||
1. Account types (Azure, AWS, UsernamePassword, SSH, etc.). | ||
2. Certificates | ||
3. Channels | ||
4. Deployment Triggers | ||
5. Environments | ||
6. Feeds | ||
7. Variables and variable sets | ||
8. Projects | ||
9. Project groups | ||
10. Lifecycles | ||
|
||
And that's just in the beta... (more resources will be added) | ||
|
||
Instead of having to create all of those resources manually in Octopus, or adhoc scripts, you can now create those resources in an automated fashion. You can even create the resources via a deployment from Octopus Deploy itself! | ||
|
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,52 @@ | ||
# Step 2 - The Setup | ||
|
||
To use the Terraform provider, you may want to test it if you don't have a dev environment of Octopus Deploy. | ||
|
||
To do this, let's set up Octopus Deploy instead of a Docker Container. | ||
|
||
## Prerequisites | ||
To follow along, you should have the following: | ||
1. Docker installed on the OS that you're using | ||
2. Familiarity with Docker | ||
|
||
## The Dockerfile | ||
|
||
To create an Octopus Deploy environment, the easiest way is with Docker Compose. | ||
|
||
The docker-compose code below will create an Octopus Deploy server and a local SQL server. | ||
|
||
You can access it once the container is up and running by going to `http://localhost:8080` | ||
|
||
*Please note this is for development purposes and should not be used in production* | ||
|
||
``` | ||
version: '3' | ||
services: | ||
octopus: | ||
ports: | ||
- "8080:8080" | ||
- "10943:10943" | ||
environment: | ||
ADMIN_USERNAME: admin | ||
ADMIN_EMAIL: test@gmail.com | ||
ADMIN_PASSWORD: Password01! | ||
ACCEPT_EULA: Y | ||
DB_CONNECTION_STRING: Server=mssql,1433;Database=Octopus;User Id=SA;Password=Password01!;ConnectRetryCount=6 | ||
CONNSTRING: Server=mssql,1433;Database=Octopus;User Id=SA;Password=Password01!;ConnectRetryCount=6 | ||
MASTER_KEY: 6EdU6IWsCtMEwk0kPKflQQ== | ||
image: octopusdeploy/octopusdeploy:latest | ||
labels: | ||
autoheal: true | ||
depends_on: | ||
- mssql | ||
mssql: | ||
environment: | ||
ACCEPT_EULA: Y | ||
SA_PASSWORD: Password01! | ||
MSSQL_PID: Express | ||
image: mcr.microsoft.com/mssql/server:2017-latest-ubuntu | ||
autoheal: | ||
image: willfarrell/autoheal:latest | ||
volumes: | ||
- /var/run/docker.sock:/var/run/docker.sock | ||
``` |
27 changes: 27 additions & 0 deletions
27
docs/Getting-Started/Step 3 - Setting Up a Working Terraform Directory.md
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,27 @@ | ||
# Step 3 - Terraform Directory | ||
|
||
Before we can create a resource, we need a place for the HCL code to exist. Of similar importance, we need the Octopus Deploy Terraform provider. | ||
|
||
Traditionally when you use Terraform, you can run `terraform init` and the provider gets pulled down for you. However, because the Terraform Provider is not yet in the Hashicorp store, you'll need to manually pull the package down and create the directory that the package should be in. | ||
|
||
## Creating the Directory | ||
In the directory where you plan to store the Terraform configuration files, you'll need to create the directory where the provider package will live. | ||
|
||
### On Windows | ||
The directory is: | ||
|
||
`.teraform/plugins/windows_amd64` | ||
|
||
### On MacOS | ||
The directory is: | ||
`.terraform/plugins/darwin_amd64` | ||
|
||
After you create the directory, it should look something like the screenshot below on Mac for example. | ||
|
||
![](images/terraformdirectory.png) | ||
|
||
## The Terraform Provider | ||
Once the directory is created, you'll need to add in the Terraform provider. The latest provider can be downloaded from the releases page found here: | ||
[Octopus_Terraform_Provider](https://github.com/OctopusDeploy/terraform-provider-octopusdeploy/releases) | ||
|
||
You should put the provider download in the directory that you created: `.terraform/plugins/os_version_amd64` |
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,33 @@ | ||
# Step 3 - Creating a Resource | ||
|
||
Now that the environment is up and running, it's time to create a resource to test. Just so we can see how it works, we'll create one resource. | ||
|
||
Before we start creating a Terraform configuration, we'll need a few components. | ||
|
||
1. The server URL, which is going to be `localhost:8080`. | ||
2. An API key which is generated from the Octopus Deploy server. | ||
|
||
When connecting to the Octopus Deploy Terraform provider, the server URL and API key is needed for authentication. That way, Terraform knows what environment to connect to. | ||
|
||
Once you have the API key, you can move on to the next step. | ||
|
||
## Main.tf | ||
The `main.tf` will be where you put the newly created resource. For example, you can create a resource to create a new project group. | ||
|
||
``` | ||
provider "octopusdeploy" { | ||
address = "localhost:8080" | ||
apikey = api_key | ||
space = "Default" | ||
} | ||
resource "octopusdeploy_project_group" "DevOpsProject" { | ||
name = "testProject" | ||
description = "my test project group" | ||
} | ||
``` | ||
|
||
With the above HCL code, the Terraform resource can be created with the standard Terraform commands: | ||
1. `terraform init` | ||
2. `terraform plan` | ||
3. `terraform apply` |
Oops, something went wrong.