Refactor services-to-host-mapping and playbooks
This commit is contained in:
parent
825393bbd3
commit
a8e14b53f5
9 changed files with 142 additions and 108 deletions
playbooks/filter_plugins
17
playbooks/filter_plugins/my_service_attributes.py
Normal file
17
playbooks/filter_plugins/my_service_attributes.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
class FilterModule(object):
|
||||
def filters(self):
|
||||
return {
|
||||
'my_service_attributes': self.my_service_attributes,
|
||||
}
|
||||
|
||||
def my_service_attributes(self, services, my_services, attribute="name"):
|
||||
result = []
|
||||
for service in services:
|
||||
if service["name"] in my_services:
|
||||
if attribute in service:
|
||||
if type(service[attribute]) == list:
|
||||
result.extend(service[attribute])
|
||||
else:
|
||||
result.append(service[attribute])
|
||||
|
||||
return result
|
Loading…
Add table
Add a link
Reference in a new issue