Skip to content

Conversation

@smemsh
Copy link

@smemsh smemsh commented Jan 21, 2025

This patch adds -refresh=true to the plan generation command line (which is the default if not specified), and adds a module argument refresh with default true value, so user can override and make sure resources are not refreshed for a specific module run. This way, plan can be called with -refresh=false when a user knows they want this.

My use case: while implementing an image bake pipeline that uses Terraform to provision and Ansible to configure a node to be imaged, my play ends by cleaning out the cloud-init identity, shutting down the node, and then imaging the node. Unfortunately, the state refresh that happens prior to imaging wakes up the node, and then it can't be imaged. So I have a chicken-egg situation where I cannot plan the imaging step without waking up the node, whereas waking up the node prevents imaging.

Using -refresh=false during plan phase fixes this for my use case. I think it's a valuable flag to expose to other users of the Ansible Terraform module.

Terraform source code has the first reference to -refresh= flag very early, in June 2014, so don't think we need a version check for this.

@softwarefactory-project-zuul
Copy link

@smemsh smemsh force-pushed the add-refresh-arg branch from 3b013fe to 6a5da75 Compare May 15, 2025 12:44
@softwarefactory-project-zuul
Copy link

@smemsh
Copy link
Author

smemsh commented May 15, 2025

Rebased to current main tip after the recent release. Can someone please look at this? Don't know who to ping, but I'll try @GomathiselviS maybe?

P.S. did not know what to use for version_added, will change it once someone lets me know. Would it be perhaps 3.0.1 or 3.1.0 ?

@GomathiselviS GomathiselviS requested a review from abikouo May 15, 2025 13:41
@smemsh smemsh force-pushed the add-refresh-arg branch from 6a5da75 to cfb2cd6 Compare May 15, 2025 13:50
@softwarefactory-project-zuul
Copy link

…le-collections#168)

Sometimes we want our task to create a plan without the usual implied
state-refresh.  The default behavior of Terraform (either no-arg, or
'-refresh=true') is to always refresh state sources when the plan is
created.  When the user knows better, they can override, as they can
already on cli.
@softwarefactory-project-zuul
Copy link

@smemsh
Copy link
Author

smemsh commented Aug 23, 2025

So I rebased off the 4.0 main and changed the release fragment version to 4.0.1, however I'm a bit puzzled why 8 months has gone by and nobody commented on this PR or merged it? A major release came and went, others' PRs got merged, but nobody said anything about this one. Is there something wrong with it? If it will never be merged, could you please let me know @GomathiselviS / @abikouo ? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants