mirror of
https://github.com/ansible/awx.git
synced 2026-05-22 16:27:42 -02:30
push limit to inventory sources
move limit field from InventorySourceSerializer to InventorySourceOptionsSerializer (#13464) InventorySourceOptionsSerializer is the parent for both InventorySourceSerializer and InventoryUpdateSerializer The limit option need to be exposed to both inventory_source and inventory_update Co-Authored-By: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com>
This commit is contained in:
@@ -2144,6 +2144,7 @@ class InventorySourceOptionsSerializer(BaseSerializer):
|
|||||||
'custom_virtualenv',
|
'custom_virtualenv',
|
||||||
'timeout',
|
'timeout',
|
||||||
'verbosity',
|
'verbosity',
|
||||||
|
'limit',
|
||||||
)
|
)
|
||||||
read_only_fields = ('*', 'custom_virtualenv')
|
read_only_fields = ('*', 'custom_virtualenv')
|
||||||
|
|
||||||
|
|||||||
@@ -79,4 +79,14 @@ class Migration(migrations.Migration):
|
|||||||
max_length=32,
|
max_length=32,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventorysource',
|
||||||
|
name='limit',
|
||||||
|
field=models.TextField(blank=True, default='', help_text='Enter host, group or pattern match'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='inventoryupdate',
|
||||||
|
name='limit',
|
||||||
|
field=models.TextField(blank=True, default='', help_text='Enter host, group or pattern match'),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -969,7 +969,7 @@ class InventorySourceOptions(BaseModel):
|
|||||||
host_filter = models.TextField(
|
host_filter = models.TextField(
|
||||||
blank=True,
|
blank=True,
|
||||||
default='',
|
default='',
|
||||||
help_text=_('Regex where only matching hosts will be imported.'),
|
help_text=_('This field is deprecated and will be removed in a future release. Regex where only matching hosts will be imported.'),
|
||||||
)
|
)
|
||||||
overwrite = models.BooleanField(
|
overwrite = models.BooleanField(
|
||||||
default=False,
|
default=False,
|
||||||
@@ -989,6 +989,11 @@ class InventorySourceOptions(BaseModel):
|
|||||||
blank=True,
|
blank=True,
|
||||||
default=1,
|
default=1,
|
||||||
)
|
)
|
||||||
|
limit = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
default='',
|
||||||
|
help_text=_("Enter host, group or pattern match"),
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def cloud_credential_validation(source, cred):
|
def cloud_credential_validation(source, cred):
|
||||||
|
|||||||
@@ -1542,6 +1542,11 @@ class RunInventoryUpdate(SourceControlMixin, BaseTask):
|
|||||||
|
|
||||||
args.append('-i')
|
args.append('-i')
|
||||||
args.append(container_location)
|
args.append(container_location)
|
||||||
|
# Added this in order to allow older versions of ansible-inventory https://github.com/ansible/ansible/pull/79596
|
||||||
|
# limit should be usable in ansible-inventory 2.15+
|
||||||
|
if inventory_update.limit:
|
||||||
|
args.append('--limit')
|
||||||
|
args.append(inventory_update.limit)
|
||||||
|
|
||||||
args.append('--output')
|
args.append('--output')
|
||||||
args.append(os.path.join(CONTAINER_ROOT, 'artifacts', str(inventory_update.id), 'output.json'))
|
args.append(os.path.join(CONTAINER_ROOT, 'artifacts', str(inventory_update.id), 'output.json'))
|
||||||
|
|||||||
Reference in New Issue
Block a user