mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 03:17:38 -02:30
Implement extra vars on ad-hoc commands
This commit is contained in:
@@ -1917,7 +1917,7 @@ class AdHocCommandSerializer(UnifiedJobSerializer):
|
|||||||
class Meta:
|
class Meta:
|
||||||
model = AdHocCommand
|
model = AdHocCommand
|
||||||
fields = ('*', 'job_type', 'inventory', 'limit', 'credential',
|
fields = ('*', 'job_type', 'inventory', 'limit', 'credential',
|
||||||
'module_name', 'module_args', 'forks', 'verbosity',
|
'module_name', 'module_args', 'forks', 'verbosity', 'extra_vars',
|
||||||
'become_enabled', '-unified_job_template', '-description')
|
'become_enabled', '-unified_job_template', '-description')
|
||||||
extra_kwargs = {
|
extra_kwargs = {
|
||||||
'name': {
|
'name': {
|
||||||
|
|||||||
@@ -84,6 +84,12 @@ class AdHocCommand(UnifiedJob):
|
|||||||
editable=False,
|
editable=False,
|
||||||
through='AdHocCommandEvent',
|
through='AdHocCommandEvent',
|
||||||
)
|
)
|
||||||
|
extra_vars = models.TextField(
|
||||||
|
blank=True,
|
||||||
|
default='',
|
||||||
|
)
|
||||||
|
|
||||||
|
extra_vars_dict = VarsDictProperty('extra_vars', True)
|
||||||
|
|
||||||
def clean_inventory(self):
|
def clean_inventory(self):
|
||||||
inv = self.inventory
|
inv = self.inventory
|
||||||
|
|||||||
@@ -1615,6 +1615,9 @@ class RunAdHocCommand(BaseTask):
|
|||||||
if ad_hoc_command.verbosity:
|
if ad_hoc_command.verbosity:
|
||||||
args.append('-%s' % ('v' * min(5, ad_hoc_command.verbosity)))
|
args.append('-%s' % ('v' * min(5, ad_hoc_command.verbosity)))
|
||||||
|
|
||||||
|
if ad_hoc_command.extra_vars_dict:
|
||||||
|
args.extend(['-e', json.dumps(ad_hoc_command.extra_vars_dict)])
|
||||||
|
|
||||||
args.extend(['-m', ad_hoc_command.module_name])
|
args.extend(['-m', ad_hoc_command.module_name])
|
||||||
args.extend(['-a', ad_hoc_command.module_args])
|
args.extend(['-a', ad_hoc_command.module_args])
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user