mirror of
https://github.com/ansible/awx.git
synced 2026-01-17 20:51:21 -03:30
update tests
This commit is contained in:
parent
5135b8a969
commit
060585434a
@ -54,7 +54,6 @@ from awx.main.models import (
|
||||
UnifiedJob, Notification,
|
||||
Inventory, SmartInventoryMembership,
|
||||
Job, AdHocCommand, ProjectUpdate, InventoryUpdate, SystemJob,
|
||||
Project,
|
||||
JobEvent, ProjectUpdateEvent, InventoryUpdateEvent, AdHocCommandEvent, SystemJobEvent,
|
||||
build_safe_env
|
||||
)
|
||||
@ -65,8 +64,8 @@ from awx.main.expect import isolated_manager
|
||||
from awx.main.dispatch.publish import task
|
||||
from awx.main.dispatch import get_local_queuename, reaper
|
||||
from awx.main.utils import (get_ssh_version, update_scm_url,
|
||||
build_proot_temp_dir, get_licenser,
|
||||
OutputEventFilter, OutputVerboseFilter, ignore_inventory_computed_fields,
|
||||
get_licenser,
|
||||
ignore_inventory_computed_fields,
|
||||
ignore_inventory_group_removal, extract_ansible_vars, schedule_task_manager)
|
||||
from awx.main.utils.safe_yaml import safe_dump, sanitize_jinja
|
||||
from awx.main.utils.reload import stop_local_services
|
||||
@ -961,6 +960,12 @@ class BaseTask(object):
|
||||
'''
|
||||
return OrderedDict()
|
||||
|
||||
def create_expect_passwords_data_struct(self, password_prompts, passwords):
|
||||
expect_passwords = {}
|
||||
for k, v in password_prompts.items():
|
||||
expect_passwords[k] = passwords.get(v, '') or ''
|
||||
return expect_passwords
|
||||
|
||||
def pre_run_hook(self, instance):
|
||||
'''
|
||||
Hook for any steps to run before the job/task starts
|
||||
@ -1041,7 +1046,6 @@ class BaseTask(object):
|
||||
status, rc, tb = 'error', None, ''
|
||||
output_replacements = []
|
||||
extra_update_fields = {}
|
||||
stdout_handle = None
|
||||
fact_modification_times = {}
|
||||
self.event_ct = 0
|
||||
private_data_dir = None
|
||||
@ -1099,10 +1103,10 @@ class BaseTask(object):
|
||||
)
|
||||
self.write_args_file(private_data_dir, args)
|
||||
|
||||
expect_passwords = {}
|
||||
password_prompts = self.get_password_prompts(passwords)
|
||||
for k, v in password_prompts.items():
|
||||
expect_passwords[k] = passwords.get(v, '') or ''
|
||||
expect_passwords = self.create_expect_passwords_data_struct(password_prompts, passwords)
|
||||
|
||||
# TODO: Probably remove this when cleaning up isolated path
|
||||
_kw = dict(
|
||||
extra_update_fields=extra_update_fields,
|
||||
proot_cmd=getattr(settings, 'AWX_PROOT_CMD', 'bwrap'),
|
||||
@ -1369,9 +1373,9 @@ class RunJob(BaseTask):
|
||||
|
||||
ssh_username, become_username, become_method = '', '', ''
|
||||
if creds:
|
||||
ssh_username = creds.username
|
||||
become_method = creds.become_method
|
||||
become_username = creds.become_username
|
||||
ssh_username = creds.get_input('username', default='')
|
||||
become_method = creds.get_input('become_method', default='')
|
||||
become_username = creds.get_input('become_username', default='')
|
||||
else:
|
||||
become_method = None
|
||||
become_username = ""
|
||||
@ -2140,7 +2144,7 @@ class RunInventoryUpdate(BaseTask):
|
||||
'cloudforms': 'CLOUDFORMS_INI_PATH'
|
||||
}
|
||||
if inventory_update.source in ini_mapping:
|
||||
cred_data = private_data_files.get('credentials', '')
|
||||
cred_data = private_data_files.get('credentials', {})
|
||||
env[ini_mapping[inventory_update.source]] = cred_data.get(
|
||||
inventory_update.get_cloud_credential(), ''
|
||||
)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
19
docs/ansible_runner_integration.md
Normal file
19
docs/ansible_runner_integration.md
Normal file
@ -0,0 +1,19 @@
|
||||
## Ansible Runner Integration Overview
|
||||
|
||||
Much of the code in AWX around ansible and ansible-playbook invocation interacting has been removed and put into the project ansible-runner. AWX now calls out to ansible-runner to invoke ansible and ansible-playbook.
|
||||
|
||||
### Lifecycle
|
||||
|
||||
In AWX, a task of a certain job type is kicked off (i.e. RunJob, RunProjectUpdate, RunInventoryUpdate, etc) in tasks.py. A temp directory is build to house ansible-runner parameters (i.e. envvars, cmdline, extravars, etc.). The temp directory is filled with the various concepts in AWX (i.e. ssh keys, extra varsk, etc.). The code then builds a set of parameters to be passed to the ansible-runner python module interface, `ansible-runner.interface.run()`. This is where AWX passes control to ansible-runner. Feedback is gathered by AWX via callbacks and handlers passed in.
|
||||
|
||||
The callbacks and handlers are:
|
||||
* event_handler: Called each time a new event is created in ansible runner. AWX will disptach the event to rabbitmq to be processed on the other end by the callback receiver.
|
||||
* cancel_callback: Called periodically by ansible runner. This is so that AWX can inform ansible runner if the job should be canceled or not.
|
||||
* finished_callback: Called once by ansible-runner to denote that the process that was asked to run is finished. AWX will construct the special control event, `EOF`, with an associated total number of events that it observed.
|
||||
* status_handler: Called by ansible-runner as the process transitions state internally. AWX uses the `starting` status to know that ansible-runner has made all of its decisions around the process that it will launch. AWX gathers and associates these decisions with the Job for historical observation.
|
||||
|
||||
### Debugging
|
||||
|
||||
If you want to debug ansible-runner then set `AWX_CLEANUP_PATHS=False`, run a job, observe the job's `AWX_PRIVATE_DATA_DIR` property, and go the node where the job was executed and inspect that directory.
|
||||
|
||||
If you want to debug the process that ansible-runner invoked (i.e. ansible or ansible-playbook) then observe the job's job_env, job_cwd, and job_args parameters.
|
||||
@ -4,6 +4,8 @@ In older version of Ansible Tower we used a system called `proot` to isolate tow
|
||||
|
||||
For Tower 3.1 and later we have switched to using `bubblewrap` which is a much lighter weight and maintained process isolation system.
|
||||
|
||||
Tower 3.4 forward uses the process isolation feature in ansible runner to achieve process isolation.
|
||||
|
||||
### Activating Process Isolation
|
||||
|
||||
By default `bubblewrap` is enabled, this can be turned off via Tower Config or from a tower settings file:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user