From e29492a25955c54c2a79587a4ec471df5786f3cb Mon Sep 17 00:00:00 2001 From: Ryan Petrello Date: Mon, 24 Jul 2017 17:02:08 -0400 Subject: [PATCH] more tower -> awx for task execution and isolated tooling --- awx/main/isolated/isolated_manager.py | 4 ++-- awx/main/isolated/run.py | 2 +- awx/main/tasks.py | 4 ++-- awx/main/tests/unit/isolated/test_expect.py | 2 +- awx/main/tests/unit/test_tasks.py | 12 ++++++------ awx/main/utils/common.py | 2 +- awx/playbooks/heartbeat_isolated.yml | 4 ++-- .../isolated/{tower_capacity.py => awx_capacity.py} | 0 ...r_isolated_cleanup.py => awx_isolated_cleanup.py} | 4 ++-- tools/docker-compose/README | 4 ++-- tools/docker-isolated/README.md | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) rename awx/plugins/isolated/{tower_capacity.py => awx_capacity.py} (100%) rename awx/plugins/isolated/{tower_isolated_cleanup.py => awx_isolated_cleanup.py} (94%) diff --git a/awx/main/isolated/isolated_manager.py b/awx/main/isolated/isolated_manager.py index c20e61f2f2..72d9f9c58e 100644 --- a/awx/main/isolated/isolated_manager.py +++ b/awx/main/isolated/isolated_manager.py @@ -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 diff --git a/awx/main/isolated/run.py b/awx/main/isolated/run.py index 00c6c423e9..db14be820d 100755 --- a/awx/main/isolated/run.py +++ b/awx/main/isolated/run.py @@ -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 diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 1da82635e1..c8ffa67f69 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -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: diff --git a/awx/main/tests/unit/isolated/test_expect.py b/awx/main/tests/unit/isolated/test_expect.py index adf43d4bb9..e9e36095d7 100644 --- a/awx/main/tests/unit/isolated/test_expect.py +++ b/awx/main/tests/unit/isolated/test_expect.py @@ -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 diff --git a/awx/main/tests/unit/test_tasks.py b/awx/main/tests/unit/test_tasks.py index 162904629c..234f2c4b73 100644 --- a/awx/main/tests/unit/test_tasks.py +++ b/awx/main/tests/unit/test_tasks.py @@ -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) diff --git a/awx/main/utils/common.py b/awx/main/utils/common.py index a3b402a92a..80a72c9cb2 100644 --- a/awx/main/utils/common.py +++ b/awx/main/utils/common.py @@ -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 diff --git a/awx/playbooks/heartbeat_isolated.yml b/awx/playbooks/heartbeat_isolated.yml index 9c100c84af..7963d5fbe2 100644 --- a/awx/playbooks/heartbeat_isolated.yml +++ b/awx/playbooks/heartbeat_isolated.yml @@ -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: diff --git a/awx/plugins/isolated/tower_capacity.py b/awx/plugins/isolated/awx_capacity.py similarity index 100% rename from awx/plugins/isolated/tower_capacity.py rename to awx/plugins/isolated/awx_capacity.py diff --git a/awx/plugins/isolated/tower_isolated_cleanup.py b/awx/plugins/isolated/awx_isolated_cleanup.py similarity index 94% rename from awx/plugins/isolated/tower_isolated_cleanup.py rename to awx/plugins/isolated/awx_isolated_cleanup.py index ac9a0cd101..a5b4d9b1df 100644 --- a/awx/plugins/isolated/tower_isolated_cleanup.py +++ b/awx/plugins/isolated/awx_isolated_cleanup.py @@ -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 diff --git a/tools/docker-compose/README b/tools/docker-compose/README index c6706af8ce..3591102b0f 100644 --- a/tools/docker-compose/README +++ b/tools/docker-compose/README @@ -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 diff --git a/tools/docker-isolated/README.md b/tools/docker-isolated/README.md index e2574fd6ca..397c4485cb 100644 --- a/tools/docker-isolated/README.md +++ b/tools/docker-isolated/README.md @@ -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`.