Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6b22a15

Browse files
authored
Merge pull request rancher#201 from bashofmann/master
Automatically generate README and tfvars examples from input variables
2 parents b577e26 + 0223489 commit 6b22a15

21 files changed

+838
-720
lines changed

.github/workflows/terraform.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,17 @@ jobs:
4141
# Validates the Terraform configuration files
4242
- name: Terraform Validate
4343
run: terraform validate
44+
45+
- name: Setup go
46+
uses: actions/setup-go@v2
47+
with:
48+
go-version: 1.17.6
49+
50+
- name: Setup terraform-docs
51+
run: go install github.com/terraform-docs/[email protected]
52+
53+
- name: Validate if terraform-docs generated README.md is up to date
54+
run: terraform-docs -c ../.terraform-docs-readme.yml . --output-check
55+
56+
- name: Validate if terraform-docs generated terraform.tfvars.example is up to date
57+
run: terraform-docs -c ../.terraform-docs-tfvars.yml . --output-check

.terraform-docs-readme.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
formatter: markdown table
2+
3+
output:
4+
file: README.md
5+
mode: inject
6+
7+
sort:
8+
by: required
9+
10+
settings:
11+
description: true

.terraform-docs-tfvars.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
formatter: tfvars hcl
2+
3+
output:
4+
file: terraform.tfvars.example
5+
mode: replace
6+
template: |-
7+
{{ .Content }}
8+
9+
sort:
10+
by: required
11+
12+
settings:
13+
description: true

Makefile

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
1-
PROVIDERS = aws azure do gcp hcloud linode scw
1+
PROVIDERS = rancher-common aws azure do gcp hcloud linode scw
2+
23
upgrade-targets = $(addprefix upgrade-, $(PROVIDERS))
4+
docs-targets = $(addprefix docs-, $(PROVIDERS))
5+
tfvars-targets = $(addprefix tfvars-, $(PROVIDERS))
6+
fmt-targets = $(addprefix fmt-, $(PROVIDERS))
7+
validate-targets = $(addprefix validate-, $(PROVIDERS))
38

49
upgrade: $(upgrade-targets)
5-
610
$(upgrade-targets): upgrade-%: %
711
cd $< && terraform init -upgrade
812

13+
docs: $(docs-targets)
14+
$(docs-targets): docs-%: %
15+
cd $< && terraform-docs -c ../.terraform-docs-readme.yml .
16+
17+
tfvars: $(tfvars-targets)
18+
$(tfvars-targets): tfvars-%: %
19+
cd $< && terraform-docs -c ../.terraform-docs-tfvars.yml .
20+
21+
fmt: $(fmt-targets)
22+
$(fmt-targets): fmt-%: %
23+
cd $< && terraform fmt
24+
25+
validate: $(validate-targets)
26+
$(validate-targets): validate-%: %
27+
cd $< && terraform validate
28+
929
.PHONY: test
1030
test:
1131
cd test/ && go test -v -timeout 45m
1232

13-
.PHONY: fmt
14-
fmt:
15-
terraform fmt -recursive

aws/README.md

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,71 @@ Two single-node RKE Kubernetes clusters will be created from two EC2 instances r
44
Both instances will have wide-open security groups and will be accessible over SSH using the SSH keys
55
`id_rsa` and `id_rsa.pub`.
66

7-
## Variables
8-
9-
###### `aws_access_key`
10-
- **Required**
11-
AWS access key used to create infrastructure
12-
13-
###### `aws_secret_key`
14-
- **Required**
15-
AWS secret key used to create AWS infrastructure
16-
17-
###### `aws_region`
18-
- Default: **`"us-east-1"`**
19-
AWS region used for all resources
20-
21-
###### `prefix`
22-
- Default: **`"quickstart"`**
23-
Prefix added to names of all resources
24-
25-
###### `instance_type`
26-
- Default: **`"t3a.medium"`**
27-
Instance type used for all EC2 instances
28-
29-
###### `docker_version`
30-
- Default: **`"19.03"`**
31-
Docker version to install on nodes
32-
33-
###### `rancher_kubernetes_version`
34-
- Default: **`"v1.21.8+k3s1"`**
35-
Kubernetes version to use for Rancher server cluster
36-
37-
See `rancher-common` module variable `rancher_kubernetes_version` for more details.
38-
39-
###### `workload_kubernetes_version`
40-
- Default: **`"v1.20.6-rancher1-1"`**
41-
Kubernetes version to use for managed workload cluster
42-
43-
See `rancher-common` module variable `workload_kubernetes_version` for more details.
44-
45-
###### `cert_manager_version`
46-
- Default: **`"1.5.3"`**
47-
Version of cert-manager to install alongside Rancher (format: 0.0.0)
48-
49-
See `rancher-common` module variable `cert_manager_version` for more details.
50-
51-
###### `rancher_version`
52-
- Default: **`"v2.6.3"`**
53-
Rancher server version (format v0.0.0)
54-
55-
See `rancher-common` module variable `rancher_version` for more details.
56-
57-
###### `rancher_server_admin_password`
58-
- **Required**
59-
Admin password to use for Rancher server bootstrap
60-
61-
See `rancher-common` module variable `admin_password` for more details.
62-
7+
<!-- BEGIN_TF_DOCS -->
8+
## Requirements
9+
10+
| Name | Version |
11+
|------|---------|
12+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
13+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | 3.68.0 |
14+
| <a name="requirement_local"></a> [local](#requirement\_local) | 2.1.0 |
15+
| <a name="requirement_tls"></a> [tls](#requirement\_tls) | 3.1.0 |
16+
17+
## Providers
18+
19+
| Name | Version |
20+
|------|---------|
21+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 3.68.0 |
22+
| <a name="provider_local"></a> [local](#provider\_local) | 2.1.0 |
23+
| <a name="provider_tls"></a> [tls](#provider\_tls) | 3.1.0 |
24+
25+
## Modules
26+
27+
| Name | Source | Version |
28+
|------|--------|---------|
29+
| <a name="module_rancher_common"></a> [rancher\_common](#module\_rancher\_common) | ../rancher-common | n/a |
30+
31+
## Resources
32+
33+
| Name | Type |
34+
|------|------|
35+
| [aws_instance.quickstart_node](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/resources/instance) | resource |
36+
| [aws_instance.quickstart_node_win](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/resources/instance) | resource |
37+
| [aws_instance.rancher_server](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/resources/instance) | resource |
38+
| [aws_key_pair.quickstart_key_pair](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/resources/key_pair) | resource |
39+
| [aws_security_group.rancher_sg_allowall](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/resources/security_group) | resource |
40+
| [local_file.ssh_private_key_pem](https://registry.terraform.io/providers/hashicorp/local/2.1.0/docs/resources/file) | resource |
41+
| [local_file.ssh_public_key_openssh](https://registry.terraform.io/providers/hashicorp/local/2.1.0/docs/resources/file) | resource |
42+
| [tls_private_key.global_key](https://registry.terraform.io/providers/hashicorp/tls/3.1.0/docs/resources/private_key) | resource |
43+
| [aws_ami.sles](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/data-sources/ami) | data source |
44+
| [aws_ami.windows](https://registry.terraform.io/providers/hashicorp/aws/3.68.0/docs/data-sources/ami) | data source |
45+
46+
## Inputs
47+
48+
| Name | Description | Type | Default | Required |
49+
|------|-------------|------|---------|:--------:|
50+
| <a name="input_aws_access_key"></a> [aws\_access\_key](#input\_aws\_access\_key) | AWS access key used to create infrastructure | `string` | n/a | yes |
51+
| <a name="input_aws_secret_key"></a> [aws\_secret\_key](#input\_aws\_secret\_key) | AWS secret key used to create AWS infrastructure | `string` | n/a | yes |
52+
| <a name="input_rancher_server_admin_password"></a> [rancher\_server\_admin\_password](#input\_rancher\_server\_admin\_password) | Admin password to use for Rancher server bootstrap | `string` | n/a | yes |
53+
| <a name="input_add_windows_node"></a> [add\_windows\_node](#input\_add\_windows\_node) | Add a windows node to the workload cluster | `bool` | `false` | no |
54+
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS region used for all resources | `string` | `"us-east-1"` | no |
55+
| <a name="input_aws_session_token"></a> [aws\_session\_token](#input\_aws\_session\_token) | AWS session token used to create AWS infrastructure | `string` | `""` | no |
56+
| <a name="input_cert_manager_version"></a> [cert\_manager\_version](#input\_cert\_manager\_version) | Version of cert-manager to install alongside Rancher (format: 0.0.0) | `string` | `"1.5.3"` | no |
57+
| <a name="input_docker_version"></a> [docker\_version](#input\_docker\_version) | Docker version to install on nodes | `string` | `"19.03"` | no |
58+
| <a name="input_instance_type"></a> [instance\_type](#input\_instance\_type) | Instance type used for all EC2 instances | `string` | `"t3a.medium"` | no |
59+
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Prefix added to names of all resources | `string` | `"quickstart"` | no |
60+
| <a name="input_rancher_kubernetes_version"></a> [rancher\_kubernetes\_version](#input\_rancher\_kubernetes\_version) | Kubernetes version to use for Rancher server cluster | `string` | `"v1.21.8+k3s1"` | no |
61+
| <a name="input_rancher_version"></a> [rancher\_version](#input\_rancher\_version) | Rancher server version (format: v0.0.0) | `string` | `"v2.6.3"` | no |
62+
| <a name="input_windows_instance_type"></a> [windows\_instance\_type](#input\_windows\_instance\_type) | Instance type used for all EC2 windows instances | `string` | `"t3a.large"` | no |
63+
| <a name="input_workload_kubernetes_version"></a> [workload\_kubernetes\_version](#input\_workload\_kubernetes\_version) | Kubernetes version to use for managed workload cluster | `string` | `"v1.20.6-rancher1-1"` | no |
64+
65+
## Outputs
66+
67+
| Name | Description |
68+
|------|-------------|
69+
| <a name="output_rancher_node_ip"></a> [rancher\_node\_ip](#output\_rancher\_node\_ip) | n/a |
70+
| <a name="output_rancher_server_url"></a> [rancher\_server\_url](#output\_rancher\_server\_url) | n/a |
71+
| <a name="output_windows-workload-ips"></a> [windows-workload-ips](#output\_windows-workload-ips) | n/a |
72+
| <a name="output_windows_password"></a> [windows\_password](#output\_windows\_password) | Returns the decrypted AWS generated windows password |
73+
| <a name="output_workload_node_ip"></a> [workload\_node\_ip](#output\_workload\_node\_ip) | n/a |
74+
<!-- END_TF_DOCS -->

aws/terraform.tfvars.example

Lines changed: 23 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
1-
# Required variables
2-
# - Fill in before beginning quickstart
3-
# ==========================================================
41

5-
# AWS Access Key
2+
# AWS access key used to create infrastructure
63
aws_access_key = ""
74

8-
# AWS Secret Key
5+
# AWS secret key used to create AWS infrastructure
96
aws_secret_key = ""
107

11-
# AWS Session Key
12-
# aws_session_token = ""
13-
14-
# Password used to log in to the `admin` account on the new Rancher server
15-
# - Must be at least 12 characters
8+
# Admin password to use for Rancher server bootstrap
169
rancher_server_admin_password = ""
1710

1811
# Add a windows node to the workload cluster
1912
add_windows_node = false
2013

21-
# Optional variables, uncomment to customize the quickstart
22-
# ----------------------------------------------------------
14+
# AWS region used for all resources
15+
aws_region = "us-east-1"
2316

24-
# AWS region for all resources
25-
# aws_region = ""
17+
# AWS session token used to create AWS infrastructure
18+
aws_session_token = ""
2619

27-
# Prefix for all resources created by quickstart
28-
# prefix = ""
20+
# Version of cert-manager to install alongside Rancher (format: 0.0.0)
21+
cert_manager_version = "1.5.3"
2922

30-
# EC2 instance size of all created instances
31-
# instance_type = ""
23+
# Docker version to install on nodes
24+
docker_version = "19.03"
3225

33-
# Docker version installed on target hosts
34-
# - Must be a version supported by the Rancher install scripts
35-
# docker_version = ""
26+
# Instance type used for all EC2 instances
27+
instance_type = "t3a.medium"
3628

37-
# Kubernetes version used for creating management server cluster
38-
# - Must be supported by RKE terraform provider 1.0.1
39-
# rancher_kubernetes_version = ""
29+
# Prefix added to names of all resources
30+
prefix = "quickstart"
4031

41-
# Kubernetes version used for creating workload cluster
42-
# - Must be supported by RKE terraform provider 1.0.1
43-
# workload_kubernetes_version = ""
32+
# Kubernetes version to use for Rancher server cluster
33+
rancher_kubernetes_version = "v1.21.8+k3s1"
4434

45-
# Version of cert-manager to install, used in case of older Rancher versions
46-
# cert_manager_version = ""
35+
# Rancher server version (format: v0.0.0)
36+
rancher_version = "v2.6.3"
4737

48-
# Version of Rancher to install
49-
# rancher_version = ""
38+
# Instance type used for all EC2 windows instances
39+
windows_instance_type = "t3a.large"
5040

41+
# Kubernetes version to use for managed workload cluster
42+
workload_kubernetes_version = "v1.20.6-rancher1-1"

0 commit comments

Comments
 (0)