mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 23:18:03 -03:30
more tower -> awx for task execution and isolated tooling
This commit is contained in:
parent
c7c9d0780e
commit
e29492a259
@ -193,7 +193,7 @@ class IsolatedManager(object):
|
||||
isolated_ssh_path = None
|
||||
try:
|
||||
if getattr(settings, 'AWX_ISOLATED_PRIVATE_KEY', None):
|
||||
isolated_ssh_path = tempfile.mkdtemp(prefix='ansible_tower_isolated', dir=settings.AWX_PROOT_BASE_PATH)
|
||||
isolated_ssh_path = tempfile.mkdtemp(prefix='ansible_awx_isolated', dir=settings.AWX_PROOT_BASE_PATH)
|
||||
os.chmod(isolated_ssh_path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
isolated_key = os.path.join(isolated_ssh_path, '.isolated')
|
||||
ssh_sock = os.path.join(isolated_ssh_path, '.isolated_ssh_auth.sock')
|
||||
@ -446,7 +446,7 @@ class IsolatedManager(object):
|
||||
isolated job on
|
||||
:param private_data_dir: an absolute path on the local file system
|
||||
where job-specific data should be written
|
||||
(i.e., `/tmp/ansible_tower_xyz/`)
|
||||
(i.e., `/tmp/ansible_awx_xyz/`)
|
||||
:param proot_temp_dir: a temporary directory which bwrap maps
|
||||
restricted paths to
|
||||
|
||||
|
||||
@ -143,7 +143,7 @@ def run_isolated_job(private_data_dir, secrets, logfile=sys.stdout):
|
||||
|
||||
:param private_data_dir: an absolute path on the local file system where
|
||||
job metadata exists (i.e.,
|
||||
`/tmp/ansible_tower_xyz/`)
|
||||
`/tmp/ansible_awx_xyz/`)
|
||||
:param secrets: a dict containing sensitive job metadata, {
|
||||
'env': { ... } # environment variables,
|
||||
'passwords': { ... } # pexpect password prompts
|
||||
|
||||
@ -472,7 +472,7 @@ class BaseTask(Task):
|
||||
'''
|
||||
Create a temporary directory for job-related files.
|
||||
'''
|
||||
path = tempfile.mkdtemp(prefix='ansible_tower_%s_' % instance.pk, dir=settings.AWX_PROOT_BASE_PATH)
|
||||
path = tempfile.mkdtemp(prefix='ansible_awx_%s_' % instance.pk, dir=settings.AWX_PROOT_BASE_PATH)
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
self.cleanup_paths.append(path)
|
||||
return path
|
||||
@ -1855,7 +1855,7 @@ class RunInventoryUpdate(BaseTask):
|
||||
elif src == 'scm':
|
||||
args.append(inventory_update.get_actual_source_path())
|
||||
elif src == 'custom':
|
||||
runpath = tempfile.mkdtemp(prefix='ansible_tower_inventory_', dir=settings.AWX_PROOT_BASE_PATH)
|
||||
runpath = tempfile.mkdtemp(prefix='ansible_awx_inventory_', dir=settings.AWX_PROOT_BASE_PATH)
|
||||
handle, path = tempfile.mkstemp(dir=runpath)
|
||||
f = os.fdopen(handle, 'w')
|
||||
if inventory_update.source_script is None:
|
||||
|
||||
@ -28,7 +28,7 @@ def rsa_key(request):
|
||||
|
||||
@pytest.fixture(scope='function')
|
||||
def private_data_dir(request):
|
||||
path = tempfile.mkdtemp(prefix='ansible_tower_unit_test')
|
||||
path = tempfile.mkdtemp(prefix='ansible_awx_unit_test')
|
||||
request.addfinalizer(lambda: shutil.rmtree(path))
|
||||
return path
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ class TestJobExecution:
|
||||
EXAMPLE_PRIVATE_KEY = '-----BEGIN PRIVATE KEY-----\nxyz==\n-----END PRIVATE KEY-----'
|
||||
|
||||
def setup_method(self, method):
|
||||
self.project_path = tempfile.mkdtemp(prefix='ansible_tower_project_')
|
||||
self.project_path = tempfile.mkdtemp(prefix='ansible_awx_project_')
|
||||
with open(os.path.join(self.project_path, 'helloworld.yml'), 'w') as f:
|
||||
f.write('---')
|
||||
|
||||
@ -312,7 +312,7 @@ class TestIsolatedExecution(TestJobExecution):
|
||||
credential.inputs['password'] = encrypt_field(credential, 'password')
|
||||
self.instance.credential = credential
|
||||
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_tower_')
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_awx_')
|
||||
self.task.build_private_data_dir = mock.Mock(return_value=private_data)
|
||||
inventory = json.dumps({"all": {"hosts": ["localhost"]}})
|
||||
|
||||
@ -351,7 +351,7 @@ class TestIsolatedExecution(TestJobExecution):
|
||||
extra_vars = json.loads(extra_vars)
|
||||
assert extra_vars['dest'] == '/tmp'
|
||||
assert extra_vars['src'] == private_data
|
||||
assert extra_vars['proot_temp_dir'].startswith('/tmp/ansible_tower_proot_')
|
||||
assert extra_vars['proot_temp_dir'].startswith('/tmp/ansible_awx_proot_')
|
||||
|
||||
def test_systemctl_failure(self):
|
||||
# If systemctl fails, read the contents of `artifacts/systemctl_logs`
|
||||
@ -364,7 +364,7 @@ class TestIsolatedExecution(TestJobExecution):
|
||||
)
|
||||
self.instance.credential = credential
|
||||
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_tower_')
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_awx_')
|
||||
self.task.build_private_data_dir = mock.Mock(return_value=private_data)
|
||||
inventory = json.dumps({"all": {"hosts": ["localhost"]}})
|
||||
|
||||
@ -464,7 +464,7 @@ class TestJobCredentials(TestJobExecution):
|
||||
)
|
||||
return ['successful', 0]
|
||||
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_tower_')
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_awx_')
|
||||
self.task.build_private_data_dir = mock.Mock(return_value=private_data)
|
||||
self.run_pexpect.side_effect = partial(run_pexpect_side_effect, private_data)
|
||||
self.task.run(self.pk, private_data_dir=private_data)
|
||||
@ -1145,7 +1145,7 @@ class TestProjectUpdateCredentials(TestJobExecution):
|
||||
assert 'bob' in kwargs.get('expect_passwords').values()
|
||||
return ['successful', 0]
|
||||
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_tower_')
|
||||
private_data = tempfile.mkdtemp(prefix='ansible_awx_')
|
||||
self.task.build_private_data_dir = mock.Mock(return_value=private_data)
|
||||
self.run_pexpect.side_effect = partial(run_pexpect_side_effect, private_data)
|
||||
self.task.run(self.pk)
|
||||
|
||||
@ -655,7 +655,7 @@ def build_proot_temp_dir():
|
||||
Create a temporary directory for proot to use.
|
||||
'''
|
||||
from django.conf import settings
|
||||
path = tempfile.mkdtemp(prefix='ansible_tower_proot_', dir=settings.AWX_PROOT_BASE_PATH)
|
||||
path = tempfile.mkdtemp(prefix='ansible_awx_proot_', dir=settings.AWX_PROOT_BASE_PATH)
|
||||
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
|
||||
return path
|
||||
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
tasks:
|
||||
|
||||
- name: Get capacity of the instance
|
||||
tower_capacity:
|
||||
awx_capacity:
|
||||
|
||||
- name: Remove any stale temporary files
|
||||
tower_isolated_cleanup:
|
||||
awx_isolated_cleanup:
|
||||
|
||||
@ -39,7 +39,7 @@ def main():
|
||||
job_cutoff = datetime.datetime.now() - datetime.timedelta(hours=1)
|
||||
|
||||
for search_pattern in [
|
||||
'/tmp/ansible_tower_[0-9]*_*', '/tmp/ansible_tower_proot_*',
|
||||
'/tmp/ansible_awx_[0-9]*_*', '/tmp/ansible_awx_proot_*',
|
||||
]:
|
||||
for path in glob.iglob(search_pattern):
|
||||
st = os.stat(path)
|
||||
@ -49,7 +49,7 @@ def main():
|
||||
continue
|
||||
elif modtime > folder_cutoff:
|
||||
try:
|
||||
re_match = re.match(r'\/tmp\/ansible_tower_\d+_.+', path)
|
||||
re_match = re.match(r'\/tmp\/ansible_awx_\d+_.+', path)
|
||||
if re_match is not None:
|
||||
if subprocess.check_call(['awx-expect', 'is-alive', path]) == 0:
|
||||
continue
|
||||
@ -1,5 +1,5 @@
|
||||
docker build --no-cache=true --rm=true -t ansible/tower_devel:latest .
|
||||
docker run --name tower_test -it --memory="4g" --cpuset="0,1" -v /Users/meyers/ansible/:/tower_devel -p 8013:8013 -p 8080:8080 -p 27017:27017 -p 2222:22 ansible/tower_devel
|
||||
docker build --no-cache=true --rm=true -t ansible/awx_devel:latest .
|
||||
docker run --name awx_test -it --memory="4g" --cpuset="0,1" -v /Users/meyers/ansible/:/awx_devel -p 8013:8013 -p 8080:8080 -p 27017:27017 -p 2222:22 ansible/awx_devel
|
||||
|
||||
## How to use the logstash container
|
||||
|
||||
|
||||
@ -56,12 +56,12 @@ by disabling some parts of the cleanup_isolated.yml playbook.
|
||||
|
||||
Example location of a private data directory:
|
||||
|
||||
`/tmp/ansible_tower_29_OM6Mnx/`
|
||||
`/tmp/ansible_awx_29_OM6Mnx/`
|
||||
|
||||
The following command would run the playbook corresponding to that job.
|
||||
|
||||
```bash
|
||||
awx-expect start /tmp/ansible_tower_29_OM6Mnx/
|
||||
awx-expect start /tmp/ansible_awx_29_OM6Mnx/
|
||||
```
|
||||
|
||||
Other awx-expect commands include `start`, `is-alive`, and `stop`.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user