I am new to puppet deployment. I have two classes defined
class taskname{
exec{ "deploy_script":
command = "cp ${old_path} ${new path}",
user = root,
}
cron{"cron_script2":
command = "pyrhton ${new_path}",
user = root,
require = Exec["deploy_script"]
}
}
class taksname2{
exec{ "deploy_script2":
command = "cp ${old_path} ${new path}",
user = root,
}
cron{"cron_script":
command = "pyrhton ${new_path}",
user = root,
require = Exec["deploy_script2"]
}
}
How do I make sure the running order of these two classes. I have tried in a new manifest file
init.pp to include these two classes
include taskname
include taskname2
It seems that second task running before the first task. How to I enforce the running order?
Use one of these metaparameters.
So to sum up: whenever a resource depends on another resource, use the
before
orrequire
metaparameter or chain the resources with->
. Whenever a resource needs to refresh when another resource changes, use thenotify
orsubscribe
metaparameter or chain the resources with~>
. Some resources will autorequire other resources if they see them, which can save you some effort.
Also works for classes declared with a resource-like syntax.
When declared with the resource-like syntax, a class may use any metaparameter. In such cases, every resource contained in the class will also have that metaparameter. So if you declare a class with
noop => true
, every resource in the class will also havenoop => true
, unless they specifically override it. Metaparameters which can take more than one value (like the relationship metaparameters) will merge the values from the container and any specific values from the individual resource.
Try using the metaparameter ->
to specify a dependency relationship between the classes. In init.pp where you declare/instantiate these classes, replace the include statements with parameterized class syntax:
class {"taskname":} ->
class {"taskname2":}
This will ensure taskname
is invoked before taskname2
. For more information, see http://docs.puppetlabs.com/guides/parameterized_classes.html#declaring-a-parameterized-class
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With