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' doesn't do what it should do #374

Closed
albatrossflavour opened this issue Sep 27, 2019 · 1 comment
Closed

ensure => 'absent' doesn't do what it should do #374

albatrossflavour opened this issue Sep 27, 2019 · 1 comment

Comments

@albatrossflavour
Copy link

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: N/A
  • Ruby: N/A
  • Distribution: N/A
  • Module version: 0.9.0

How to reproduce (e.g Puppet code you use)

class profile::soe::monitoring::new_relic (
  Boolean $enable = lookup('profile::soe::monitoring::new_relic::enable',Boolean,first,false),
) {

  $key = lookup('profile::soe::monitoring::new_relic::sensitive_license_key',Sensitive,first,undef)

  case $enable {
    true: {
      $ensure = 'latest'
      $package_repo_ensure = 'present'
      $service_ensure = 'running'
    }
    default: {
      $ensure = 'absent'
      $package_repo_ensure = 'absent'
      $service_ensure = 'stopped'
    }
  }

  class { 'newrelic_infra::agent':
    ensure              => $ensure,
    package_repo_ensure => $package_repo_ensure,
    service_ensure      => $service_ensure,
    license_key         => $key.unwrap,
  }
}

What are you seeing

If set to true, the agent installs perfectly fine and works. If set to false without ever being set to true, Centos 6 and Ubuntu 14 fail on the newreelic-infra service as the upstart config is not in place.

If set to false having once been set to true (to remove a node from monitoring) it works, but only after I added in the package_repo and service ensure statements.

What behaviour did you expect instead

Ideally, setting the following should ensure that the New Relic software isn't installed or running, irrespective of the previous state:

class { 'newreelic_infra::agent':
  ensure => 'absent',
}

Output log

ubuntu14 node that has never had new relic installed

14:06 # puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Retrieving locales
Info: Loading facts
Info: Caching catalog for ubuntu14.laptop.bandcamp.tv
Info: Applying configuration version 'puppetmaster-production-fe032af225c'
Error: /Stage[main]/Newrelic_infra::Agent/Service[newrelic-infra]: Could not evaluate: Could not find init script or upstart conf file for 'newrelic-infra'

results of just setting a node previously set to 'ensure => 'latest'toensure => 'absent'`

Systemd start for newrelic-infra failed!
journalctl log for newrelic-infra:
-- Logs begin at Thu 2019-09-26 16:23:49 AEST, end at Fri 2019-09-27 11:25:37 AEST. --
Sep 27 11:25:29 dashboard.lab.bandcamp.tv newrelic-infra[2035]: 2019/09/27 11:25:29 Orderly shutdown commenced
Sep 27 11:25:29 dashboard.lab.bandcamp.tv newrelic-infra[2035]: time="2019-09-27T11:25:29+10:00" level=info msg="Gracefully Exiting"
Sep 27 11:25:29 dashboard.lab.bandcamp.tv newrelic-infra[2035]: time="2019-09-27T11:25:29+10:00" level=info msg="Agent service manager shutdown completed successfully." component=AgentService service=newrelic-infra
Sep 27 11:25:29 dashboard.lab.bandcamp.tv systemd[1]: Stopping New Relic Infrastructure Agent...
Sep 27 11:25:29 dashboard.lab.bandcamp.tv systemd[1]: Stopped New Relic Infrastructure Agent.

It's still trying to manage the service, even though the software has been removed. It also leaves behind the repos.

Any additional information you'd like to impart

I'm going to have a stab at fixing this up myself, but wanted it recorded incase anyone else runs into it in the interim.

@albatrossflavour
Copy link
Author

Damn it, I should check that I'm on the right tab before I raise an issue. Sorry!

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

1 participant