Skip to content

Commit

Permalink
update ansible_navigator_run resource to exclude working dir change w…
Browse files Browse the repository at this point in the history
…hen deciding to run playbook (#61)
  • Loading branch information
marshallford authored Aug 20, 2024
1 parent ecefe4a commit f1cc450
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 50 deletions.
3 changes: 1 addition & 2 deletions internal/provider/navigator_run_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,10 @@ func (r *NavigatorRunResource) Schema(ctx context.Context, req resource.SchemaRe
}

func (NavigatorRunResource) ShouldRun(plan *NavigatorRunResourceModel, state *NavigatorRunResourceModel) bool {
// skip ansible_navigator_binary, run_on_destroy, timeouts
// skip working_directory, ansible_navigator_binary, run_on_destroy, timeouts
attributeChanges := []bool{
plan.Playbook.Equal(state.Playbook),
plan.Inventory.Equal(state.Inventory),
plan.WorkingDirectory.Equal(state.WorkingDirectory),
plan.ExecutionEnvironment.Equal(state.ExecutionEnvironment),
plan.AnsibleOptions.Equal(state.AnsibleOptions), // TODO check nested attrs
plan.Timezone.Equal(state.Timezone),
Expand Down
28 changes: 2 additions & 26 deletions internal/provider/navigator_run_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-testing/config"
"github.com/hashicorp/terraform-plugin-testing/helper/acctest"
"github.com/hashicorp/terraform-plugin-testing/helper/resource"
"github.com/hashicorp/terraform-plugin-testing/knownvalue"
"github.com/hashicorp/terraform-plugin-testing/plancheck"
Expand Down Expand Up @@ -312,27 +311,6 @@ func TestAccNavigatorRunResource_pull_args(t *testing.T) {
})
}

func TestAccNavigatorRunResource_relative_binary(t *testing.T) {
t.Parallel()

resource.Test(t, resource.TestCase{
PreCheck: func() { testPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testTerraformFile(t, filepath.Join("navigator_run_resource", "relative_binary")),
ConfigVariables: testConfigVariables(t, config.Variables{
"working_directory": config.StringVariable(t.TempDir()),
}),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttrSet(navigatorRunResource, "id"),
resource.TestCheckResourceAttrSet(navigatorRunResource, "command"),
),
},
},
})
}

func TestAccNavigatorRunResource_role(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -377,10 +355,8 @@ func TestAccNavigatorRunResource_skip_run(t *testing.T) {
),
},
{
Config: testTerraformFile(t, filepath.Join("navigator_run_resource", "skip_run_update")),
ConfigVariables: testConfigVariables(t, config.Variables{
"ansible_navigator_binary": config.StringVariable(acctest.RandString(8)),
}),
Config: testTerraformFile(t, filepath.Join("navigator_run_resource", "skip_run_update")),
ConfigVariables: testDefaultConfigVariables(t),
ConfigPlanChecks: resource.ConfigPlanChecks{
PreApply: []plancheck.PlanCheck{
plancheck.ExpectNonEmptyPlan(),
Expand Down

This file was deleted.

6 changes: 0 additions & 6 deletions internal/provider/testdata/navigator_run_resource/skip_run.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ resource "ansible_navigator_run" "test" {
jq_filter = "now"
}
}
run_on_destroy = true
timeouts = {
create = "60m"
update = "60m"
delete = "60m"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "ansible_navigator_run" "test" {
ansible_navigator_binary = var.ansible_navigator_binary
ansible_navigator_binary = "${path.module}/${var.ansible_navigator_binary}"
playbook = <<-EOT
- hosts: localhost
become: false
Expand All @@ -10,7 +10,8 @@ resource "ansible_navigator_run" "test" {
jq_filter = "now"
}
}
run_on_destroy = false
working_directory = ".."
run_on_destroy = true
timeouts = {
create = "90m"
update = "90m"
Expand Down

0 comments on commit f1cc450

Please sign in to comment.