Overriding chef built-in providers


#1

Hi! I would like to override the mount provider so that it does try to
mount in my dev environment . . I was hoping to add a mount cookbook with
a provider that would simply check the chef environment and make super
calls if the environment is not dev.

Is this stupid? Anyone have a better way? If this doesn’t sound terrible,
then can someone say if what I want to do is possible? I couldn’t find
anything on the nets about overriding providers . .

Thanks a lot,
Guy


#2

Why not enclosing the mounts with a

if node.chef_environment != ‘dev’ do

[… mounts calls and so ont … ]

end

or a

do

[…]

end unless node.chef_environment == ‘dev’

For what it worth, I wrote that without control, so I may have typos and
other cross language errors, but the idea is there :slight_smile:

Le 2014-03-20 16:40, Guy Matz a écrit :

Hi! I would like to override the mount provider so that it does try to mount in my dev environment . . I was hoping to add a mount cookbook with a provider that would simply check the chef environment and make super calls if the environment is not dev.

Is this stupid? Anyone have a better way? If this doesn’t sound terrible, then can someone say if what I want to do is possible? I couldn’t find anything on the nets about overriding providers . .

Thanks a lot,
Guy


#3

Thanks, but I’d rather do it in one place, and be able to change it there
rather than have to change it throughout my code if my requirements change

On Thu, Mar 20, 2014 at 11:43 AM, Tensibai tensibai@iabis.net wrote:

Why not enclosing the mounts with a

if node.chef_environment != ‘dev’ do

[… mounts calls and so ont … ]

end

or a

do

[…]

end unless node.chef_environment == ‘dev’

For what it worth, I wrote that without control, so I may have typos and
other cross language errors, but the idea is there :slight_smile:

Le 2014-03-20 16:40, Guy Matz a écrit :

Hi! I would like to override the mount provider so that it does try to
mount in my dev environment . . I was hoping to add a mount cookbook with
a provider that would simply check the chef environment and make super
calls if the environment is not dev.

Is this stupid? Anyone have a better way? If this doesn’t sound
terrible, then can someone say if what I want to do is possible? I
couldn’t find anything on the nets about overriding providers . .

Thanks a lot,
Guy


#4

I just today learned how to override one of chef’s providers with a
heavyweight provider, code snippet here:

HTH

On Thu, Mar 20, 2014 at 8:40 AM, Guy Matz guymatz@gmail.com wrote:

Hi! I would like to override the mount provider so that it does try to mount
in my dev environment . . I was hoping to add a mount cookbook with a
provider that would simply check the chef environment and make super calls
if the environment is not dev.

Is this stupid? Anyone have a better way? If this doesn’t sound terrible,
then can someone say if what I want to do is possible? I couldn’t find
anything on the nets about overriding providers . .

Thanks a lot,
Guy


#5

You could set an attribute foo.nomount = true on the environments. When you call a mount resource include a not_if { node.foo.nomount } in then resource block.

Advantages: You don’t block the mount resource on certain environments. You use the attribute as a toggle able feature flag. Its not a method like chef.environment so an attribute may be easier to change across systems.

Guy Matz guymatz@gmail.com wrote:

Thanks, but I’d rather do it in one place, and be able to change it there rather than have to change it throughout my code if my requirements change

On Thu, Mar 20, 2014 at 11:43 AM, Tensibai <tensibai@iabis.netmailto:tensibai@iabis.net> wrote:

Why not enclosing the mounts with a

if node.chef_environment != ‘dev’ do

[… mounts calls and so ont … ]

end

or a

do

[…]

end unless node.chef_environment == ‘dev’

For what it worth, I wrote that without control, so I may have typos and other cross language errors, but the idea is there :slight_smile:

Le 2014-03-20 16:40, Guy Matz a écrit :

Hi! I would like to override the mount provider so that it does try to mount in my dev environment . . I was hoping to add a mount cookbook with a provider that would simply check the chef environment and make super calls if the environment is not dev.

Is this stupid? Anyone have a better way? If this doesn’t sound terrible, then can someone say if what I want to do is possible? I couldn’t find anything on the nets about overriding providers . .

Thanks a lot,
Guy