mirror of
https://github.com/ansible/awx.git
synced 2026-05-11 03:17:38 -02:30
Remove PROJECTS_ROOT and JOBOUTPUT_ROOT from stngs
This commit is contained in:
@@ -216,7 +216,7 @@ class ApiV1ConfigView(APIView):
|
|||||||
|
|
||||||
if request.user.is_superuser or request.user.admin_of_organizations.filter(active=True).count():
|
if request.user.is_superuser or request.user.admin_of_organizations.filter(active=True).count():
|
||||||
data.update(dict(
|
data.update(dict(
|
||||||
project_base_dir = tower_settings.PROJECTS_ROOT,
|
project_base_dir = settings.PROJECTS_ROOT,
|
||||||
project_local_paths = Project.get_local_path_choices(),
|
project_local_paths = Project.get_local_path_choices(),
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import re
|
|||||||
import urlparse
|
import urlparse
|
||||||
|
|
||||||
# Django
|
# Django
|
||||||
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
@@ -45,9 +46,9 @@ class ProjectOptions(models.Model):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_local_path_choices(cls):
|
def get_local_path_choices(cls):
|
||||||
if os.path.exists(tower_settings.PROJECTS_ROOT):
|
if os.path.exists(settings.PROJECTS_ROOT):
|
||||||
paths = [x.decode('utf-8') for x in os.listdir(tower_settings.PROJECTS_ROOT)
|
paths = [x.decode('utf-8') for x in os.listdir(settings.PROJECTS_ROOT)
|
||||||
if (os.path.isdir(os.path.join(tower_settings.PROJECTS_ROOT, x)) and
|
if (os.path.isdir(os.path.join(settings.PROJECTS_ROOT, x)) and
|
||||||
not x.startswith('.') and not x.startswith('_'))]
|
not x.startswith('.') and not x.startswith('_'))]
|
||||||
qs = Project.objects.filter(active=True)
|
qs = Project.objects.filter(active=True)
|
||||||
used_paths = qs.values_list('local_path', flat=True)
|
used_paths = qs.values_list('local_path', flat=True)
|
||||||
@@ -143,7 +144,7 @@ class ProjectOptions(models.Model):
|
|||||||
def get_project_path(self, check_if_exists=True):
|
def get_project_path(self, check_if_exists=True):
|
||||||
local_path = os.path.basename(self.local_path)
|
local_path = os.path.basename(self.local_path)
|
||||||
if local_path and not local_path.startswith('.'):
|
if local_path and not local_path.startswith('.'):
|
||||||
proj_path = os.path.join(tower_settings.PROJECTS_ROOT, local_path)
|
proj_path = os.path.join(settings.PROJECTS_ROOT, local_path)
|
||||||
if not check_if_exists or os.path.exists(smart_str(proj_path)):
|
if not check_if_exists or os.path.exists(smart_str(proj_path)):
|
||||||
return proj_path
|
return proj_path
|
||||||
|
|
||||||
|
|||||||
@@ -537,9 +537,9 @@ class BaseTask(Task):
|
|||||||
cwd = self.build_cwd(instance, **kwargs)
|
cwd = self.build_cwd(instance, **kwargs)
|
||||||
env = self.build_env(instance, **kwargs)
|
env = self.build_env(instance, **kwargs)
|
||||||
safe_env = self.build_safe_env(instance, **kwargs)
|
safe_env = self.build_safe_env(instance, **kwargs)
|
||||||
if not os.path.exists(tower_settings.JOBOUTPUT_ROOT):
|
if not os.path.exists(settings.JOBOUTPUT_ROOT):
|
||||||
os.makedirs(tower_settings.JOBOUTPUT_ROOT)
|
os.makedirs(settings.JOBOUTPUT_ROOT)
|
||||||
stdout_filename = os.path.join(tower_settings.JOBOUTPUT_ROOT, "%d-%s.out" % (pk, str(uuid.uuid1())))
|
stdout_filename = os.path.join(settings.JOBOUTPUT_ROOT, "%d-%s.out" % (pk, str(uuid.uuid1())))
|
||||||
stdout_handle = codecs.open(stdout_filename, 'w', encoding='utf-8')
|
stdout_handle = codecs.open(stdout_filename, 'w', encoding='utf-8')
|
||||||
if self.should_use_proot(instance, **kwargs):
|
if self.should_use_proot(instance, **kwargs):
|
||||||
if not check_proot_installed():
|
if not check_proot_installed():
|
||||||
@@ -814,7 +814,7 @@ class RunJob(BaseTask):
|
|||||||
return self.get_path_to('..', 'playbooks')
|
return self.get_path_to('..', 'playbooks')
|
||||||
cwd = job.project.get_project_path()
|
cwd = job.project.get_project_path()
|
||||||
if not cwd:
|
if not cwd:
|
||||||
root = tower_settings.PROJECTS_ROOT
|
root = settings.PROJECTS_ROOT
|
||||||
raise RuntimeError('project local_path %s cannot be found in %s' %
|
raise RuntimeError('project local_path %s cannot be found in %s' %
|
||||||
(job.project.local_path, root))
|
(job.project.local_path, root))
|
||||||
return cwd
|
return cwd
|
||||||
|
|||||||
@@ -331,8 +331,8 @@ class RunAdHocCommandTest(BaseAdHocCommandTest):
|
|||||||
settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')]
|
settings.AWX_PROOT_HIDE_PATHS = [os.path.join(settings.BASE_DIR, 'settings')]
|
||||||
# Create list of paths that should not be visible to the command.
|
# Create list of paths that should not be visible to the command.
|
||||||
hidden_paths = [
|
hidden_paths = [
|
||||||
os.path.join(tower_settings.PROJECTS_ROOT, '*'),
|
os.path.join(settings.PROJECTS_ROOT, '*'),
|
||||||
os.path.join(tower_settings.JOBOUTPUT_ROOT, '*'),
|
os.path.join(settings.JOBOUTPUT_ROOT, '*'),
|
||||||
]
|
]
|
||||||
# Create a temp directory that should not be visible to the command.
|
# Create a temp directory that should not be visible to the command.
|
||||||
temp_path = tempfile.mkdtemp()
|
temp_path = tempfile.mkdtemp()
|
||||||
|
|||||||
@@ -264,14 +264,14 @@ class BaseTestMixin(QueueTestMixin, MockCommonlySlowTestMixin):
|
|||||||
if not name:
|
if not name:
|
||||||
name = self.unique_name('Project')
|
name = self.unique_name('Project')
|
||||||
|
|
||||||
if not os.path.exists(tower_settings.PROJECTS_ROOT):
|
if not os.path.exists(settings.PROJECTS_ROOT):
|
||||||
os.makedirs(tower_settings.PROJECTS_ROOT)
|
os.makedirs(settings.PROJECTS_ROOT)
|
||||||
# Create temp project directory.
|
# Create temp project directory.
|
||||||
if unicode_prefix:
|
if unicode_prefix:
|
||||||
tmp_prefix = u'\u2620tmp'
|
tmp_prefix = u'\u2620tmp'
|
||||||
else:
|
else:
|
||||||
tmp_prefix = 'tmp'
|
tmp_prefix = 'tmp'
|
||||||
project_dir = tempfile.mkdtemp(prefix=tmp_prefix, dir=tower_settings.PROJECTS_ROOT)
|
project_dir = tempfile.mkdtemp(prefix=tmp_prefix, dir=settings.PROJECTS_ROOT)
|
||||||
self._temp_paths.append(project_dir)
|
self._temp_paths.append(project_dir)
|
||||||
# Create temp playbook in project (if playbook content is given).
|
# Create temp playbook in project (if playbook content is given).
|
||||||
if playbook_content:
|
if playbook_content:
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ class ProjectsTest(BaseTransactionTest):
|
|||||||
url = reverse('api:api_v1_config_view')
|
url = reverse('api:api_v1_config_view')
|
||||||
response = self.get(url, expect=200, auth=self.get_super_credentials())
|
response = self.get(url, expect=200, auth=self.get_super_credentials())
|
||||||
self.assertTrue('project_base_dir' in response)
|
self.assertTrue('project_base_dir' in response)
|
||||||
self.assertEqual(response['project_base_dir'], tower_settings.PROJECTS_ROOT)
|
self.assertEqual(response['project_base_dir'], settings.PROJECTS_ROOT)
|
||||||
self.assertTrue('project_local_paths' in response)
|
self.assertTrue('project_local_paths' in response)
|
||||||
self.assertEqual(set(response['project_local_paths']),
|
self.assertEqual(set(response['project_local_paths']),
|
||||||
set(Project.get_local_path_choices()))
|
set(Project.get_local_path_choices()))
|
||||||
@@ -219,7 +219,7 @@ class ProjectsTest(BaseTransactionTest):
|
|||||||
self.assertEquals(results['count'], 0)
|
self.assertEquals(results['count'], 0)
|
||||||
|
|
||||||
# can add projects (super user)
|
# can add projects (super user)
|
||||||
project_dir = tempfile.mkdtemp(dir=tower_settings.PROJECTS_ROOT)
|
project_dir = tempfile.mkdtemp(dir=settings.PROJECTS_ROOT)
|
||||||
self._temp_paths.append(project_dir)
|
self._temp_paths.append(project_dir)
|
||||||
project_data = {
|
project_data = {
|
||||||
'name': 'My Test Project',
|
'name': 'My Test Project',
|
||||||
|
|||||||
@@ -1413,8 +1413,8 @@ class RunJobTest(BaseJobExecutionTest):
|
|||||||
project_path = self.project.local_path
|
project_path = self.project.local_path
|
||||||
job_template = self.create_test_job_template()
|
job_template = self.create_test_job_template()
|
||||||
extra_vars = {
|
extra_vars = {
|
||||||
'projects_root': tower_settings.PROJECTS_ROOT,
|
'projects_root': settings.PROJECTS_ROOT,
|
||||||
'joboutput_root': tower_settings.JOBOUTPUT_ROOT,
|
'joboutput_root': settings.JOBOUTPUT_ROOT,
|
||||||
'project_path': project_path,
|
'project_path': project_path,
|
||||||
'other_project_path': other_project_path,
|
'other_project_path': other_project_path,
|
||||||
'temp_path': temp_path,
|
'temp_path': temp_path,
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import contextlib
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
# Django REST Framework
|
# Django REST Framework
|
||||||
|
from django.conf import settings
|
||||||
from rest_framework.exceptions import ParseError, PermissionDenied
|
from rest_framework.exceptions import ParseError, PermissionDenied
|
||||||
from django.utils.encoding import smart_str
|
from django.utils.encoding import smart_str
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
@@ -467,8 +468,8 @@ def wrap_args_with_proot(args, cwd, **kwargs):
|
|||||||
new_args = [getattr(settings, 'AWX_PROOT_CMD', 'proot'), '-v',
|
new_args = [getattr(settings, 'AWX_PROOT_CMD', 'proot'), '-v',
|
||||||
str(getattr(settings, 'AWX_PROOT_VERBOSITY', '0')), '-r', '/']
|
str(getattr(settings, 'AWX_PROOT_VERBOSITY', '0')), '-r', '/']
|
||||||
hide_paths = ['/etc/tower', '/var/lib/awx', '/var/log',
|
hide_paths = ['/etc/tower', '/var/lib/awx', '/var/log',
|
||||||
tempfile.gettempdir(), tower_settings.PROJECTS_ROOT,
|
tempfile.gettempdir(), settings.PROJECTS_ROOT,
|
||||||
tower_settings.JOBOUTPUT_ROOT]
|
settings.JOBOUTPUT_ROOT]
|
||||||
hide_paths.extend(getattr(tower_settings, 'AWX_PROOT_HIDE_PATHS', None) or [])
|
hide_paths.extend(getattr(tower_settings, 'AWX_PROOT_HIDE_PATHS', None) or [])
|
||||||
for path in sorted(set(hide_paths)):
|
for path in sorted(set(hide_paths)):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
|
|||||||
@@ -682,20 +682,6 @@ FACT_CACHE_PORT = 6564
|
|||||||
ORG_ADMINS_CAN_SEE_ALL_USERS = True
|
ORG_ADMINS_CAN_SEE_ALL_USERS = True
|
||||||
|
|
||||||
TOWER_SETTINGS_MANIFEST = {
|
TOWER_SETTINGS_MANIFEST = {
|
||||||
"PROJECTS_ROOT": {
|
|
||||||
"name": "Projects Root Directory",
|
|
||||||
"description": "Directory to store synced projects in and to look for manual projects",
|
|
||||||
"default": PROJECTS_ROOT,
|
|
||||||
"type": "string",
|
|
||||||
"category": "jobs",
|
|
||||||
},
|
|
||||||
"JOBOUTPUT_ROOT": {
|
|
||||||
"name": "Job Standard Output Directory",
|
|
||||||
"description": "Directory to store job standard output files",
|
|
||||||
"default": JOBOUTPUT_ROOT,
|
|
||||||
"type": "string",
|
|
||||||
"category": "jobs",
|
|
||||||
},
|
|
||||||
"SCHEDULE_MAX_JOBS": {
|
"SCHEDULE_MAX_JOBS": {
|
||||||
"name": "Maximum Scheduled Jobs",
|
"name": "Maximum Scheduled Jobs",
|
||||||
"description": "Maximum number of the same job template that can be waiting to run when launching from a schedule before no more are created",
|
"description": "Maximum number of the same job template that can be waiting to run when launching from a schedule before no more are created",
|
||||||
|
|||||||
Reference in New Issue
Block a user