From 4042e78757c5fa5367f058fef65aca33f5bf4b73 Mon Sep 17 00:00:00 2001 From: Francois Herbert Date: Thu, 21 May 2020 12:03:45 +1200 Subject: [PATCH 1/3] Add option to follow symlinks when scanning for playbooks --- awx/main/conf.py | 10 ++++++++++ awx/main/models/projects.py | 2 +- awx/settings/defaults.py | 3 +++ .../forms/jobs-form/configuration-jobs.form.js | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/awx/main/conf.py b/awx/main/conf.py index bd9b953695..1aa3990aee 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -423,6 +423,16 @@ register( category_slug='jobs', ) +register( + 'AWX_SHOW_PLAYBOOK_LINKS', + field_class=fields.BooleanField, + default=False, + label=_('Follow symlinks'), + help_text=_('Follow symbolic links when scanning for playbooks'), + category=_('Jobs'), + category_slug='jobs', +) + register( 'PRIMARY_GALAXY_URL', field_class=fields.URLField, diff --git a/awx/main/models/projects.py b/awx/main/models/projects.py index 0207fec97b..bc703f216e 100644 --- a/awx/main/models/projects.py +++ b/awx/main/models/projects.py @@ -199,7 +199,7 @@ class ProjectOptions(models.Model): results = [] project_path = self.get_project_path() if project_path: - for dirpath, dirnames, filenames in os.walk(smart_str(project_path)): + for dirpath, dirnames, filenames in os.walk(smart_str(project_path, followlinks=settings.AWX_SHOW_PLAYBOOK_LINKS)): if skip_directory(dirpath): continue for filename in filenames: diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index 1895a47b72..b300579471 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -563,6 +563,9 @@ AWX_ROLES_ENABLED = True # Note: This setting may be overridden by database settings. AWX_COLLECTIONS_ENABLED = True +# Follow symlinks when scanning for playbooks +AWX_SHOW_PLAYBOOK_LINKS = False + # Settings for primary galaxy server, should be set in the UI PRIMARY_GALAXY_URL = '' PRIMARY_GALAXY_USERNAME = '' diff --git a/awx/ui/client/src/configuration/forms/jobs-form/configuration-jobs.form.js b/awx/ui/client/src/configuration/forms/jobs-form/configuration-jobs.form.js index 3d0ad107ed..faff8e2366 100644 --- a/awx/ui/client/src/configuration/forms/jobs-form/configuration-jobs.form.js +++ b/awx/ui/client/src/configuration/forms/jobs-form/configuration-jobs.form.js @@ -71,6 +71,9 @@ export default ['i18n', function(i18n) { AWX_COLLECTIONS_ENABLED: { type: 'toggleSwitch', }, + AWX_SHOW_PLAYBOOK_LINKS: { + type: 'toggleSwitch', + }, PRIMARY_GALAXY_URL: { type: 'text', reset: 'PRIMARY_GALAXY_URL', From b9396372665385fffad53c864c6652f1d809f171 Mon Sep 17 00:00:00 2001 From: Francois Herbert Date: Wed, 27 May 2020 07:15:13 +1200 Subject: [PATCH 2/3] Add warning regarding infinite recursion --- awx/main/conf.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/awx/main/conf.py b/awx/main/conf.py index 1aa3990aee..51cc62af77 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -428,7 +428,9 @@ register( field_class=fields.BooleanField, default=False, label=_('Follow symlinks'), - help_text=_('Follow symbolic links when scanning for playbooks'), + help_text=_('Follow symbolic links when scanning for playbooks. Be aware that setting this to True ' + 'can lead to infinite recursion if a link points to a parent directory of itself.' + ), category=_('Jobs'), category_slug='jobs', ) From e2d3407f6605ee24ab6029a6d7ffa1ebda0bccfb Mon Sep 17 00:00:00 2001 From: Francois Herbert Date: Wed, 27 May 2020 08:04:25 +1200 Subject: [PATCH 3/3] Fixup indenting for linting --- awx/main/conf.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/awx/main/conf.py b/awx/main/conf.py index 51cc62af77..dcc40c0528 100644 --- a/awx/main/conf.py +++ b/awx/main/conf.py @@ -428,8 +428,9 @@ register( field_class=fields.BooleanField, default=False, label=_('Follow symlinks'), - help_text=_('Follow symbolic links when scanning for playbooks. Be aware that setting this to True ' - 'can lead to infinite recursion if a link points to a parent directory of itself.' + help_text=_( + 'Follow symbolic links when scanning for playbooks. Be aware that setting this to True can lead ' + 'to infinite recursion if a link points to a parent directory of itself.' ), category=_('Jobs'), category_slug='jobs',