PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, April 28, 2022

[FIXED] How to avoid “resource cloning” warning in Chef 12, while using resource which name can't be changed

 April 28, 2022     chef-infra, deprecated, warnings     No comments   

Issue

I know that when I use two resources that have the same name, I might get "deprecated feature used: resource cloning" warning in Chef 12. I could change the name of second resource to avoid resource cloning and get rid of that warning. But what if I can not change resource name? Let's say I have mount at the beginning of my recipe:

mount '/mnt/directory' do
  device "//192.168.1.2/something"
  action [:mount]
end

and then at the end I have umount:

mount '/mnt/directory' do
  device "//192.168.1.2/something"
  action [:umount]
end

I know that this is not common to do both mount and umount in one recipe, but that's my unorthodox way of achieving something. While executing this recipe I get warning about "deprecated feature used: resource cloning". How can I avoid that warning while I can not change the name of second resource, since "/mnt/directory" is the name and I can not change the directory on which the umount will take action?


Solution

Every resource in Chef has a so-called name property. The value of this property is taken from the name of the resource, but it also can be overwritten using the explicit property name itself.

For the mount resource the name property is mount_point. If you set mount_point in your resource, it will not matter how you name the resource:

mount 'mount /mnt/directory' do
  mount_point '/mnt/directory'
  device "//192.168.1.2/something"
  action [:mount]
end

mount 'umount /mnt/directory' do
  mount_point '/mnt/directory'
  device "//192.168.1.2/something"
  action [:umount]
end


Answered By - Draco Ater
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing