vmware-archive / vmware-vcenter

VMware vCenter Module
Other
87 stars 102 forks source link

Unable to use multiple hosts with the esx_service type #148

Open cwb124 opened 10 years ago

cwb124 commented 10 years ago

Using Hiera to create an array of hosts to be used in the recipe. Other types will loop through the array of hosts and apply the settings to all hosts, but the esx_service type isn't allowing me to do that, or I haven't been able to figure out the syntax.

For example, here is a working snippet for another type:

esx_ntpconfig { $esxi_servers:
server => $ntp_servers,
transport => Transport['vcenter'],
}

$esxi_servers is the array brought in from a hiera call above in the recipe. This approach works on multiple types, such as esx_syslog and esx_shells to name a few.

However the same approach doesn't work with the esx_service type because for some reason the service is jammed in with the host.

esx_service { "$esxi_servers:TSM-SSH":
running => true,
policy => 'on',
transport => Transport['vcenter'],
subscribe => Notify['trigger'],
}

We have tried multiple quotes placement and can never get it to work. Is it possible to do this with multiple hosts or does it only support 1 host per use?, If so, what is the syntax? And why put the service up there instead of as a normal parameter like running, policy, etc?

nanliu commented 10 years ago

This is due to Puppet's lousy composite namevar support. esx_service allows you to use server:servicename, so you can manage multiple service on same host. You can not use an array directly, but you should be able to work around this with a function from stdlib (assuming $esxi_servers is an array):

$ssh_service = suffix($esxi_servers, ':TSM-SSH')

esx_service { $ssh_service:
...
}