LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   puppet needs to stop a service, do something, then start the service (https://www.linuxquestions.org/questions/programming-9/puppet-needs-to-stop-a-service-do-something-then-start-the-service-4175439839/)

edwardcode 12-03-2012 01:14 PM

puppet needs to stop a service, do something, then start the service
 
I need to write puppet code that will stop a service, make a change to a file then start the service. I can not change the file wile it is running. That is why I need to stop the service first. I had this test code:
Code:

service { cupsd : ensure => stopped } -> file { "/home/testing": ensure => true } -> service { cupsd : ensure => running }
But when I run it throws an error saying:

Code:

Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Service[cupsd] is already declared in file /etc/puppet/modules/test/manifests/init.pp at line 2; cannot redeclare on node
I am not sure how to work around this error or how to "declare" something twice.

Any help would be great.

Thanks

acid_kewpie 12-03-2012 01:58 PM

Puppet defines a state of a system, not how it is done, so if you need to run a series of operations, you'd write a script to do it, and deploy that via puppet with an exec http://docs.puppetlabs.com/reference...type.html#exec

You can't declare it twice as there is no order to the definitions, they aren't executed in order at all, so having two entries is just a direct contradiction of the other.


All times are GMT -5. The time now is 05:06 PM.