mirror of
https://github.com/phfroidmont/self-hosting.git
synced 2025-12-25 05:36:59 +01:00
Simplify dynamic inventory to only use tags as groups
This commit is contained in:
parent
9e83baffb3
commit
9f8e3dc0c7
1 changed files with 11 additions and 16 deletions
|
|
@ -52,22 +52,17 @@ class SCWInventory(object):
|
||||||
[i['name'], i['public_ip'], i['tags'], i['private_ip']] for i in result_par1['servers'] + result_ams1['servers']
|
[i['name'], i['public_ip'], i['tags'], i['private_ip']] for i in result_par1['servers'] + result_ams1['servers']
|
||||||
]
|
]
|
||||||
for host, ip_info, tags, private_ip in self.inventory:
|
for host, ip_info, tags, private_ip in self.inventory:
|
||||||
if 'env:'+self.environment in tags:
|
self.response['_meta']['hostvars'][host] = {
|
||||||
if ip_info:
|
'ansible_host': ip_info['address'] if ip_info else private_ip,
|
||||||
self.response['_meta']['hostvars'][host] = {
|
'public_ip': ip_info['address'] if ip_info else None,
|
||||||
'ansible_host': ip_info['address'],
|
'private_ip': private_ip
|
||||||
'public_ip': ip_info['address'],
|
}
|
||||||
'private_ip': private_ip
|
if tags:
|
||||||
}
|
for tag in tags:
|
||||||
if tags:
|
self._add_to_response(
|
||||||
for tag in tags:
|
tag,
|
||||||
if tag.startswith('group:'):
|
host
|
||||||
self._add_to_response(
|
)
|
||||||
tag.split(':')[1],
|
|
||||||
host
|
|
||||||
)
|
|
||||||
if tag.startswith('fact'):
|
|
||||||
self.response['_meta']['hostvars'][host][tag.split(':')[1]] = tag.split(':')[2]
|
|
||||||
|
|
||||||
def _add_to_response(self, group, hostname):
|
def _add_to_response(self, group, hostname):
|
||||||
'''
|
'''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue