alpine: support non-VM hosts in interfaces template
Ignore OOB management interface, allow configuring loopback interface with NetBox data, and setting MTU.
This commit is contained in:
parent
cbd3f1a7ea
commit
bf4fd2c82d
2 changed files with 38 additions and 3 deletions
21
filter_plugins/util.py
Normal file
21
filter_plugins/util.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
class FilterModule(object):
|
||||
'''Helper filters to make Ansible less unpleasant'''
|
||||
def filters(self):
|
||||
return {
|
||||
'defaultattr': self.defaultattr,
|
||||
'list2dict': self.list2dict,
|
||||
}
|
||||
|
||||
def defaultattr(self, objects, attr, val=None):
|
||||
'''
|
||||
Set a default value if the given attribute is not defined for an object.
|
||||
'''
|
||||
yield from (obj | { attr: obj.get(attr, val) } for obj in objects)
|
||||
|
||||
def list2dict(self, items, key):
|
||||
'''
|
||||
Like items2dict but keep entire dictionaries as values.
|
||||
'''
|
||||
return {item[key]: item for item in items}
|
Loading…
Add table
Add a link
Reference in a new issue