Reworked script and playbook to include tags
This commit is contained in:
@@ -94,6 +94,7 @@ class LinodeInventory:
|
||||
inventory['ungrouped']['hosts'].append(hostname)
|
||||
|
||||
# Host variables
|
||||
linode_tags = instance.get('tags', [])
|
||||
inventory['_meta']['hostvars'][hostname] = {
|
||||
'ansible_host': primary_ip,
|
||||
'linode_id': instance['id'],
|
||||
@@ -103,14 +104,22 @@ class LinodeInventory:
|
||||
'linode_status': instance['status'],
|
||||
'linode_ipv4': instance.get('ipv4', []),
|
||||
'linode_ipv6': instance.get('ipv6'),
|
||||
'linode_tags': instance.get('tags', []),
|
||||
'linode_tags': linode_tags,
|
||||
'linode_specs': instance.get('specs', {}),
|
||||
'linode_hypervisor': instance.get('hypervisor'),
|
||||
'linode_created': instance.get('created'),
|
||||
'linode_updated': instance.get('updated'),
|
||||
'linode_group': instance.get('group', ''),
|
||||
'linode_image': instance.get('image', {}).get('id', '') if isinstance(instance.get('image'), dict) else '',
|
||||
'linode_backups': instance.get('backups', {}).get('enabled', False) if isinstance(instance.get('backups'), dict) else False
|
||||
'linode_backups': instance.get('backups', {}).get('enabled', False) if isinstance(instance.get('backups'), dict) else False,
|
||||
# Add individual tag variables for easy access
|
||||
'is_debian': 'Debian' in linode_tags,
|
||||
'is_ubuntu': 'Ubuntu' in linode_tags,
|
||||
'is_k3s': 'k3s' in linode_tags,
|
||||
'is_control_plane': 'control-plane' in linode_tags,
|
||||
'is_worker_node': 'worker-node' in linode_tags,
|
||||
# Tag string for easy filtering
|
||||
'tag_string': ','.join(linode_tags).lower(),
|
||||
}
|
||||
|
||||
# Group by region
|
||||
|
Reference in New Issue
Block a user