With the inheritance we can set the order in which resources are applied on an agent.
A test manifest is shown below, it is rather simple one.
Here we have defined a class “ownerfile”, which has a resource file “/tmp/owner.txt”. There is another file “/tmp/depenfile”, which will be created after the owners.txt file.
First owner.txt file is created and then depenfile is created.
Another approach is using the “require”
In the above manifest it is shown that,
File resource “/tmp/dependrequire.txt” defined which requires another resource which is a file resource too, “tmp/owners.txt”
First owners.txt is created as it is required by the file resource dependrequire.txt. Then dependrequire.txt is created.
A test manifest is shown below, it is rather simple one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Demonstrate the inheritance | |
class ownerfile { | |
file { "/tmp/owner.txt": | |
content => " I am the owner and the next file is depeandent on me", | |
before => File["/tmp/depenfile"] | |
} | |
file { "/tmp/depenfile": | |
content => " I am the Dependent of owner" | |
} | |
} |
Here we have defined a class “ownerfile”, which has a resource file “/tmp/owner.txt”. There is another file “/tmp/depenfile”, which will be created after the owners.txt file.
First owner.txt file is created and then depenfile is created.
Another approach is using the “require”
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ownerfile { | |
file { "/tmp/dependrequire.txt": | |
content => " My requirement is owner txt file\n ", | |
require => File["/tmp/owner.txt"] | |
} | |
file { "/tmp/owner.txt": | |
content => " I am the of owner\n" | |
} | |
} |
In the above manifest it is shown that,
File resource “/tmp/dependrequire.txt” defined which requires another resource which is a file resource too, “tmp/owners.txt”
First owners.txt is created as it is required by the file resource dependrequire.txt. Then dependrequire.txt is created.
No comments:
Post a Comment