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

run task/plan: Allow noop and environment option #632

Merged
merged 4 commits into from Mar 3, 2023

Conversation

bastelfreak
Copy link
Collaborator

No description provided.

@bastelfreak bastelfreak self-assigned this Jan 3, 2023
@bastelfreak bastelfreak requested a review from a team as a code owner January 3, 2023 12:40
@bastelfreak bastelfreak changed the title run task: Allow noop option run task: Allow noop and environment option Jan 3, 2023
@bastelfreak bastelfreak requested a review from a team as a code owner January 3, 2023 14:12
@bastelfreak bastelfreak changed the title run task: Allow noop and environment option run task/plan: Allow noop and environment option Jan 3, 2023
Copy link
Contributor

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, i am only thinking about non default settings. Is it worth handling it?

plan puppet_agent::run (
TargetSpec $targets
TargetSpec $targets,
Boolean $noop = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if some site hardcode noop=true in puppet configuration, does it make sense to make this parameter:

Suggested change
Boolean $noop = false,
Optional[Boolean] $noop = undef,

That way the default behavior would be the same as before, and passing noop=false would allow to actually apply changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered it. When you currently set $noop to false (or keep the default), the parameter won't be passed at all to puppet agent. So it's not a breaking change. I think that's a sane default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late response. My point was that when noop=true in puppet.conf, this module plan are currently unusable to actually do changes because puppet run in noop mode all the time because of the configuration setting.

With this PR, we have a chance to "fix" it by adding an explicit --no-noop parameter to the puppet command when we set noop=false.

I heard some people are setting noop=true in puppet.conf and manually run the agent in no-noop mode when they detect drift. These users are currently not able to do this using the provided tasks and plans.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, in this case the 'sane default' is not to change noop unless a value was passed.

In any case, this PR as it is today is very fine for me if you think the value is not worth it.

Comment on lines +64 to +67
$arg_noop = $noop ? {
true => { 'noop' => true, },
default => {},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$arg_noop = $noop ? {
true => { 'noop' => true, },
default => {},
}
$arg_noop = {
'noop' => $noop,
}

Comment on lines +4 to +9
"noop": {
"description": "run the puppet agent with --noop",
"type": "Boolean",
"default": false
},
"environment": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"noop": {
"description": "run the puppet agent with --noop",
"type": "Boolean",
"default": false
},
"environment": {
"noop": {
"description": "run the puppet agent with --noop",
"type": "Optional[Boolean]",
},
"environment": {

Comment on lines +141 to +143
def noop(params)
params['noop'] == true ? '--noop' : ''
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def noop(params)
params['noop'] == true ? '--noop' : ''
end
def noop(params)
case params['noop']
when true then '--noop'
when false then '--no-noop'
else ''
end
end

@mhashizume
Copy link
Contributor

@bastelfreak LGTM, it looks like there are a few puppet-lint whitespace errors but once those are fixed I'm happy to approve and merge.

@bastelfreak
Copy link
Collaborator Author

@mhashizume I think all of the puppet-lint violations were already present in main. I fixed the ones in the run plan.

@mhashizume
Copy link
Contributor

Thanks @bastelfreak !

@mhashizume mhashizume merged commit d7818b2 into puppetlabs:main Mar 3, 2023
@bastelfreak
Copy link
Collaborator Author

thanks for merging! Is it possible to make a new release soonish?

@bastelfreak bastelfreak deleted the noop branch March 3, 2023 18:28
@mhashizume
Copy link
Contributor

Yeah, we have some more work on this module ticketed out in preparation for Puppet 8 (you can see them in this epic with the prefix "[puppet_agent]") but will cut a release when we've finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants