Ignore OOB management interface, allow configuring loopback interface with NetBox data, and setting MTU.
		
			
				
	
	
		
			21 lines
		
	
	
	
		
			650 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
	
		
			650 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| #!/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}
 |