Pupper error - Duplicate definition Service ServiceName is already defined

0 votes

I would like to do this:

stop a service
reinstall a package
start the previous service again

I have defines my class:

class MyClass{
    service{"ServiceName-start":
      name => "ServiceName",
      ensure => "stopped",
    }
    package{"PackageName":
        ensure => "installed",
        require => Service["ServiceName-Start"],
    }
    service{"ServiceName-Stop":
      name =>  "ServiceName",
      ensure => "running",
      require => Package["PackageName"]
    }
}

I get the following error:

Duplicate definition: Service[ServiceName] is already defined
Feb 15, 2019 in Puppet by Nigya
594 views

1 answer to this question.

0 votes

Hey @Nigya, try something like this:

class MyClass {
  exec { "ServiceName-Stop":
    command => "/bin/sh -c '/sbin/service ServiceName stop",
  }
  package{"PackageName":
    ensure => "installed",
    require => Service["ServiceName-Stop"],
  }
  service{"ServiceName-Start":
    name =>  "ServiceName",
    ensure => "running",
    require => Package["PackageName"]
  }
}
answered Feb 15, 2019 by Hatim

Related Questions In Puppet

0 votes
1 answer

Service already defines error in Puppet

Hey @Rohan, try this: class MyClass { ...READ MORE

answered Feb 9, 2019 in Puppet by Monish
1,111 views
0 votes
0 answers

Puppet: Cannot start php service that is defined in a puppet manifest.

I have written a puppet manifest to ...READ MORE

Sep 18, 2019 in Puppet by Karan
• 19,610 points
973 views
0 votes
1 answer

Error: PuppetDB is running but Puppet Master can't reach it.

If PuppetDB is running but the Puppet ...READ MORE

answered Jul 31, 2019 in Puppet by Sirajul
• 59,230 points
1,127 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,024 views
+2 votes
1 answer
0 votes
1 answer

DNS is set but I dont know how to add new hosts?

Follow these steps to add host to your ...READ MORE

answered Feb 21, 2019 in Puppet by Kashish
850 views
0 votes
1 answer

Error while enabling the official puppet lab collection repository

Hey @Alia, try executing these commands and ...READ MORE

answered Feb 25, 2019 in Puppet by Nandita
960 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP