Add concept of host alias for regrouping hosts

Ansible doesn't provide a way to uniquely identify hosts which would
allow ARA to track a single host across multiple playbook runs.

This patch adds a field for each host, 'alias'.
The plan is to leverage this field as a way to regroup the results
for what is believed to be the same host -- the same alias.

A host alias is arbitrary and generic. It can be the inventory
hostname or the result of a hashing algorithm like md5sum/sha1sum
of a combination of host facts.

Change-Id: I16b668f473a9f31686c7a921d7dcd31a5292febd
This commit is contained in:
David Moreau Simard 2018-09-03 20:15:58 -04:00
parent fa2ebaf911
commit 7d15ae22c6
No known key found for this signature in database
GPG Key ID: 33A07694CBB71ECC
3 changed files with 29 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.1.1 on 2018-09-04 00:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('api', '0002_add_labels'),
]
operations = [
migrations.AddField(
model_name='host',
name='alias',
field=models.CharField(max_length=255, null=True),
),
]

View File

@ -194,6 +194,16 @@ class Host(Base):
ok = models.IntegerField(default=0)
skipped = models.IntegerField(default=0)
unreachable = models.IntegerField(default=0)
# Ansible doesn't supply a mechanism to uniquely identify a host out of
# the box.
# ARA can attempt to reconcile what it believes are the results same hosts
# based on user-supplied configuration or through a hashing algorithm.
# The goal is to "regroup" all unique hosts under a single alias if they
# are the same host.
# The logic for supplying aliases does not live here, it's provided by the
# clients and consumers.
alias = models.CharField(max_length=255, null=True)
play = models.ForeignKey(Play, on_delete=models.DO_NOTHING, related_name='hosts')
def __str__(self):

View File

@ -109,6 +109,7 @@ class HostFactory(factory.DjangoModelFactory):
ok = 2
skipped = 1
unreachable = 0
alias = "9f5d3ba7-e43d-4f3b-ab17-f90c39e43d07"
play = factory.SubFactory(PlayFactory)