Pergunta

Creating a symlink in Chef:

link "#{node[:tomcat][:home]}/webapps/myface.war" do
  to "/srv/scafandru/current/myface.war"
end

fails, since at that time the parent directory is missing on the node.

In the link resource I couldn't see any attribute similar to the directory resource's recursive true, so my current approach is to ensure that the directory structure exists by running

directory "#{node[:tomcat][:home]}/webapps" do
  recursive true
end

right before linking.

Is there any elegant way to encapsulate this behaviour inside the link resource?

Foi útil?

Solução

Your solution is the best one if you don't want to write code.

If you are willing to have a better solution, you may extend the provider for link to add the recursive attribute.

To do that, you can refer to opscode documentation that states:

Extending An Existing Provider

If you'd like to write a LWP that extends another provider class, you can accomplish that as a mixin, which you would then place in a library under the library directory of the cookbook using that extended class.

Your LWRP would then be written to include that library in the provider implementation to get access to the extended core resource. For an example, see the Transmission Cookbook, which includes a transmission_torrent_file LWRP that allows you to download a file via the BitTorrent protocol. This transmission_torrent_file LWRP are an extension of the existing file and remote_file resources.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top