diff options
author | Russell Teague <rteague@redhat.com> | 2017-08-23 16:45:01 -0400 |
---|---|---|
committer | Russell Teague <rteague@redhat.com> | 2017-08-29 08:14:37 -0400 |
commit | d8191cbd7a66fc2ba8b4d3cafeccc19afca76850 (patch) | |
tree | a7a03b9ebcfbe0c0826630af5dee9b28b092b416 /setup.py | |
parent | ab7b515d8ed8576b23147e64e4da73e6dea41df7 (diff) | |
download | openshift-d8191cbd7a66fc2ba8b4d3cafeccc19afca76850.tar.gz openshift-d8191cbd7a66fc2ba8b4d3cafeccc19afca76850.tar.bz2 openshift-d8191cbd7a66fc2ba8b4d3cafeccc19afca76850.tar.xz openshift-d8191cbd7a66fc2ba8b4d3cafeccc19afca76850.zip |
Test: Fail on entry point playbooks in common
Diffstat (limited to 'setup.py')
-rw-r--r-- | setup.py | 31 |
1 files changed, 20 insertions, 11 deletions
@@ -225,8 +225,9 @@ class OpenShiftAnsibleSyntaxCheck(Command): included_playbooks = set() for yaml_file in find_files( - os.path.join(os.getcwd(), 'playbooks', 'byo'), - None, None, r'\.ya?ml$'): + os.path.join(os.getcwd(), 'playbooks'), + ['adhoc', 'tasks'], + None, r'\.ya?ml$'): with open(yaml_file, 'r') as contents: for task in yaml.safe_load(contents): if not isinstance(task, dict): @@ -245,19 +246,27 @@ class OpenShiftAnsibleSyntaxCheck(Command): # Evaluate the difference between all playbooks and included playbooks entrypoint_playbooks = sorted(playbooks.difference(included_playbooks)) print('Entry point playbook count: {}'.format(len(entrypoint_playbooks))) - # Syntax each entry point playbook + for playbook in entrypoint_playbooks: print('-' * 60) print('Syntax checking playbook: {}'.format(playbook)) - try: - subprocess.check_output( - ['ansible-playbook', '-i localhost,', - '--syntax-check', playbook] - ) - except subprocess.CalledProcessError as cpe: - print('{}Execution failed: {}{}'.format( - self.FAIL, cpe, self.ENDC)) + + if 'common' in playbook: + # Error on any entry points in 'common' + print('{}Invalid entry point playbook. All playbooks must' + ' start in playbooks/byo{}'.format(self.FAIL, self.ENDC)) has_errors = True + else: + # Syntax check each entry point playbook + try: + subprocess.check_output( + ['ansible-playbook', '-i localhost,', + '--syntax-check', playbook] + ) + except subprocess.CalledProcessError as cpe: + print('{}Execution failed: {}{}'.format( + self.FAIL, cpe, self.ENDC)) + has_errors = True if has_errors: raise SystemExit(1) |