Not sure if this is nuts, bad practice or just insane, but today I found myself in need to load the provider for a resource I was dependent on, in a custom provider.
Take the following example:
provision {'worker':
provider => 'puppet',
provision => 'worker.pp'
require => Chroot['worker'],
chroot => Chroot['worker']
}
Let me give you some context: Puppet is running puppet inside a debootstrap lvm-snapshot schroot. I know, mental.
I needed the instance of the chroot provider (in this case, the schroot provider), inside my “provision” provider so I can run the puppet apply in the right schroot source.
Anyway, here’s how I’ve done it:
def provision
resource.catalog.resource('chroot', resource[:chroot].title).provider.source_exec(puppet_apply_cmd)
end
Is there a nicer way of doing this?