Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

triton-kubernetes#161 The -module option is no longer supported since Terraform 0.12 #168

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/.vscode
bin/terraform*
*/terraform.tfstate*
terraform/.terraform*
Expand Down
19 changes: 19 additions & 0 deletions create/manager_triton.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ type tritonManagerTerraformConfig struct {
MasterTritonMachinePackage string `json:"master_triton_machine_package,omitempty"`
}

type typeManagerOutput struct {
Value string `json:"value"`
}

func newTritonManager(currentState state.State, name string) error {
nonInteractiveMode := viper.GetBool("non-interactive")

Expand All @@ -54,6 +58,18 @@ func newTritonManager(currentState state.State, name string) error {
baseManagerTerraformConfig: baseConfig,
}

rancherAccessKeyOtpt := typeManagerOutput{
Value: "${module.cluster-manager.rancher_access_key}",
}

rancherSecretKeyOtpt := typeManagerOutput{
Value: "${module.cluster-manager.rancher_secret_key}",
}

rancherUrlKeyOtpt := typeManagerOutput{
Value: "${module.cluster-manager.rancher_url}",
}

// Triton Account
if viper.IsSet("triton_account") {
cfg.TritonAccount = viper.GetString("triton_account")
Expand Down Expand Up @@ -394,6 +410,9 @@ func newTritonManager(currentState state.State, name string) error {
}

currentState.SetManager(&cfg)
currentState.SetOutput(&rancherUrlKeyOtpt, "rancher_url")
currentState.SetOutput(&rancherAccessKeyOtpt, "rancher_access_key")
currentState.SetOutput(&rancherSecretKeyOtpt, "rancher_secret_key")

return nil
}
4 changes: 2 additions & 2 deletions shell/run_terraform.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func RunTerraformDestroyWithState(currentState state.State, args []string) error
}

// Run terraform destroy
allArgs := append([]string{"destroy", "-force"}, args...)
allArgs := append([]string{"destroy", "-auto-approve"}, args...)
err = runShellCommand(&shellOptions, "terraform", allArgs...)
if err != nil {
return err
Expand Down Expand Up @@ -182,7 +182,7 @@ func RunTerraformOutputWithState(state state.State, moduleName string) error {
}

// Run terraform output
err = runShellCommand(&shellOptions, "terraform", "output", "-module", moduleName)
err = runShellCommand(&shellOptions, "terraform", "output")
if err != nil {
return err
}
Expand Down
9 changes: 9 additions & 0 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ func (state *State) SetManager(obj interface{}) error {
return nil
}

func (state *State) SetOutput(obj interface{}, outputName string) error {
_, err := state.configJSON.SetP(obj, fmt.Sprintf("output.%s", outputName))
if err != nil {
return err
}

return nil
}

func (state *State) SetTerraformBackendConfig(tfBackendPath string, tfBackendObj interface{}) error {
_, err := state.configJSON.SetP(tfBackendObj, tfBackendPath)
if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions terraform/modules/bare-metal-rancher-k8s-host/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ resource "null_resource" "install_rancher_agent" {
}

provisioner "remote-exec" {
inline = <<EOF
${data.template_file.install_rancher_agent.rendered}

EOF
inline = [
"${data.template_file.install_rancher_agent.rendered}"
]

}
}
Expand Down
23 changes: 9 additions & 14 deletions terraform/modules/bare-metal-rancher/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ resource "null_resource" "install_docker" {
}

provisioner "remote-exec" {
inline = <<EOF
${data.template_file.install_docker.rendered}

EOF

inline = [
"${data.template_file.install_docker.rendered}"
]
}
}

Expand Down Expand Up @@ -66,11 +64,9 @@ resource "null_resource" "install_rancher_master" {
}

provisioner "remote-exec" {
inline = <<EOF
${data.template_file.install_rancher_master.rendered}

EOF

inline = [
"${data.template_file.install_rancher_master.rendered}"
]
}
}

Expand Down Expand Up @@ -101,10 +97,9 @@ resource "null_resource" "setup_rancher_k8s" {
}

provisioner "remote-exec" {
inline = <<EOF
${data.template_file.setup_rancher_k8s.rendered}

EOF
inline = [
"${data.template_file.setup_rancher_k8s.rendered}"
]

}
}
Expand Down