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

ensure => 'absent' on nginx::resource::server leaves file behind #1103

Closed
dominics opened this issue Aug 4, 2017 · 5 comments
Closed

ensure => 'absent' on nginx::resource::server leaves file behind #1103

dominics opened this issue Aug 4, 2017 · 5 comments
Assignees

Comments

@dominics
Copy link

dominics commented Aug 4, 2017

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.0.1
  • Module version: 0.7.0

How to reproduce

Create a server with something like:

nginx::resource::server { "foo":
  server_name => ['foo.example.com'];
}

Then mark it absent:

nginx::resource::server { "foo":
  ensure => 'absent',
  server_name => ['foo.example.com'];
}

What are you seeing

The locations are removed from the server, and the sites-enabled symlink is removed, but the emptied server definition still lives in sites-available. (As the locations are removed, it's kind-of useless; you couldn't "just" re-symlink it anyway.)

What behaviour did you expect instead

I'd expect the server definition file to be removed from sites-available as well.

Additional information

  • I think this can be fixed just by passing the $ensure value to the concat_file definition at https://github.com/voxpupuli/puppet-nginx/blob/v0.7.0/manifests/resource/server.pp#L304 - that way the entire file will be absent, rather than just the locations within it.
  • Not a super-important bug - already works functionally because the symlink is removed, which is the important bit. But just a bit annoying to have to define your own file {} to clean up after a server definition is removed.
@wyardley
Copy link
Collaborator

wyardley commented Aug 4, 2017

I'm curious, if you remove the server resource rather than set ensure => absent (which is how I'd normally get rid of it), with $server_purge enabled, won't that ensure that the file is removed? That's how I normally deal with it vs. doing ensure => absent on something I no longer need, so if you don't have unmanaged files that you need in those directories (or are using $confd_only), that might be an option.

That said, I agree with your assessment of what's happening and your proposed fix seems reasonable. Can you test #1104 and see if that works as you suggested?

@wyardley
Copy link
Collaborator

wyardley commented Aug 4, 2017

ps - PRs also welcomed if that's something you're interested in / comfortable with.

@wyardley wyardley self-assigned this Aug 4, 2017
alexjfisher added a commit that referenced this issue Aug 7, 2017
Ensure absent on concat resource for server resource with ensure => absent (#1103)
@wyardley
Copy link
Collaborator

wyardley commented Aug 7, 2017

Closed via #1104

@wyardley wyardley closed this as completed Aug 7, 2017
@bittner
Copy link

bittner commented Sep 5, 2018

I'm not 100% sure, but also with nginx::resource::location there seems to be an issue with ensure => absent.

The code doesn't really do a lot to remove locations, does it?

@alexjfisher
Copy link
Member

@bittner I think you're right that

$ensure_real = $ensure ? {
'absent' => absent,
default => file,
}
could be removed. But I think locations will correctly be removed from their servers if you set ensure => absent as there will no longer be any concat::fragments added to the config_file

I don't think setting ensure => absent does anything more than not declaring the location in the first place though. If you'd like to create a PR to clear any of this mess up, it'd be greatly appreciated!

cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this issue Sep 13, 2019
cegeka-jenkins pushed a commit to cegeka/puppet-nginx that referenced this issue Sep 13, 2019
Ensure absent on concat resource for server resource with ensure => absent (voxpupuli#1103)
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
Rubueno pushed a commit to Rubueno/puppet-nginx that referenced this issue Oct 19, 2020
Ensure absent on concat resource for server resource with ensure => absent (voxpupuli#1103)
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

No branches or pull requests

4 participants