mirror of
https://github.com/ansible/awx.git
synced 2026-03-01 00:38:45 -03:30
Store auth.json is pdd_wrapper directory
This commit is contained in:
@@ -297,8 +297,11 @@ class Credential(PasswordFieldsModel, CommonModelNameNotUnique, ResourceMixin):
|
|||||||
|
|
||||||
def has_inputs(self, field_names=()):
|
def has_inputs(self, field_names=()):
|
||||||
for name in field_names:
|
for name in field_names:
|
||||||
if name not in self.inputs:
|
if name in self.inputs:
|
||||||
return False
|
if self.inputs[name] in ('', None):
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
raise ValueError('{} is not an input field'.format(name))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _get_dynamic_input(self, field_name):
|
def _get_dynamic_input(self, field_name):
|
||||||
|
|||||||
@@ -834,7 +834,7 @@ class BaseTask(object):
|
|||||||
"""
|
"""
|
||||||
return os.path.abspath(os.path.join(os.path.dirname(__file__), *args))
|
return os.path.abspath(os.path.join(os.path.dirname(__file__), *args))
|
||||||
|
|
||||||
def build_execution_environment_params(self, instance):
|
def build_execution_environment_params(self, instance, private_data_dir):
|
||||||
if settings.IS_K8S:
|
if settings.IS_K8S:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
@@ -854,7 +854,7 @@ class BaseTask(object):
|
|||||||
if instance.execution_environment.credential:
|
if instance.execution_environment.credential:
|
||||||
cred = instance.execution_environment.credential
|
cred = instance.execution_environment.credential
|
||||||
if cred.has_inputs(field_names=('host', 'username', 'password')):
|
if cred.has_inputs(field_names=('host', 'username', 'password')):
|
||||||
path = self.build_private_data_dir(instance)
|
path = os.path.split(private_data_dir)[0]
|
||||||
with open(path + '/auth.json', 'w') as authfile:
|
with open(path + '/auth.json', 'w') as authfile:
|
||||||
host = cred.get_input('host')
|
host = cred.get_input('host')
|
||||||
username = cred.get_input('username')
|
username = cred.get_input('username')
|
||||||
@@ -866,7 +866,7 @@ class BaseTask(object):
|
|||||||
os.chmod(authfile.name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
os.chmod(authfile.name, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||||
params["container_options"].append(f'--authfile={authfile.name}')
|
params["container_options"].append(f'--authfile={authfile.name}')
|
||||||
else:
|
else:
|
||||||
logger.exception('Please recheck that your host, username, and password fields are all filled.')
|
raise RuntimeError('Please recheck that your host, username, and password fields are all filled.')
|
||||||
|
|
||||||
pull = instance.execution_environment.pull
|
pull = instance.execution_environment.pull
|
||||||
if pull:
|
if pull:
|
||||||
@@ -1726,11 +1726,11 @@ class RunJob(BaseTask):
|
|||||||
"""
|
"""
|
||||||
return settings.AWX_RESOURCE_PROFILING_ENABLED
|
return settings.AWX_RESOURCE_PROFILING_ENABLED
|
||||||
|
|
||||||
def build_execution_environment_params(self, instance):
|
def build_execution_environment_params(self, instance, private_data_dir):
|
||||||
if settings.IS_K8S:
|
if settings.IS_K8S:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
params = super(RunJob, self).build_execution_environment_params(instance)
|
params = super(RunJob, self).build_execution_environment_params(instance, private_data_dir)
|
||||||
# If this has an insights agent and it is not already mounted then show it
|
# If this has an insights agent and it is not already mounted then show it
|
||||||
insights_dir = os.path.dirname(settings.INSIGHTS_SYSTEM_ID_FILE)
|
insights_dir = os.path.dirname(settings.INSIGHTS_SYSTEM_ID_FILE)
|
||||||
if instance.use_fact_cache and os.path.exists(insights_dir):
|
if instance.use_fact_cache and os.path.exists(insights_dir):
|
||||||
@@ -2341,11 +2341,11 @@ class RunProjectUpdate(BaseTask):
|
|||||||
if status == 'successful' and instance.launch_type != 'sync':
|
if status == 'successful' and instance.launch_type != 'sync':
|
||||||
self._update_dependent_inventories(instance, dependent_inventory_sources)
|
self._update_dependent_inventories(instance, dependent_inventory_sources)
|
||||||
|
|
||||||
def build_execution_environment_params(self, instance):
|
def build_execution_environment_params(self, instance, private_data_dir):
|
||||||
if settings.IS_K8S:
|
if settings.IS_K8S:
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
params = super(RunProjectUpdate, self).build_execution_environment_params(instance)
|
params = super(RunProjectUpdate, self).build_execution_environment_params(instance, private_data_dir)
|
||||||
project_path = instance.get_project_path(check_if_exists=False)
|
project_path = instance.get_project_path(check_if_exists=False)
|
||||||
cache_path = instance.get_cache_path()
|
cache_path = instance.get_cache_path()
|
||||||
params.setdefault('container_volume_mounts', [])
|
params.setdefault('container_volume_mounts', [])
|
||||||
@@ -2848,7 +2848,7 @@ class RunSystemJob(BaseTask):
|
|||||||
event_model = SystemJobEvent
|
event_model = SystemJobEvent
|
||||||
event_data_key = 'system_job_id'
|
event_data_key = 'system_job_id'
|
||||||
|
|
||||||
def build_execution_environment_params(self, system_job):
|
def build_execution_environment_params(self, system_job, private_data_dir):
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def build_args(self, system_job, private_data_dir, passwords):
|
def build_args(self, system_job, private_data_dir, passwords):
|
||||||
@@ -2964,7 +2964,7 @@ class AWXReceptorJob:
|
|||||||
self.unit_id = None
|
self.unit_id = None
|
||||||
|
|
||||||
if self.task and not self.task.instance.is_container_group_task:
|
if self.task and not self.task.instance.is_container_group_task:
|
||||||
execution_environment_params = self.task.build_execution_environment_params(self.task.instance)
|
execution_environment_params = self.task.build_execution_environment_params(self.task.instance, runner_params['private_data_dir'])
|
||||||
self.runner_params['settings'].update(execution_environment_params)
|
self.runner_params['settings'].update(execution_environment_params)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user