c60b55ec83
This commit enanbles Ansible linting and does some minor refactoring to make existing Ansible roles compatible with the new rules. Several Ansible linting rules have been excluded to keep the number of changes from being too onerous. Also a new script in ci-scripts is used to check very config file included in the Browbeat repo for validity using the template Browbeat uses when it runs. Here's a list of the new linting rules * Ansible tasks must have names * When you use shell you must use become not sudo * Using become_user without using become is not allowed * If a repo is pulled it must be a pinned version of commit, not latest * Always_run is deprecated don't use it * Variables without {{}} and not in when statements are deprecated don't use them * No Trailing whitepaces * YAML checking, catches big syntax errors but not less obvious ones Change-Id: Ic531c91c408996d4e7d8899afe8b21d364998680
28 lines
1.1 KiB
Python
28 lines
1.1 KiB
Python
#!/usr/bin/env python
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
import yaml
|
|
import sys
|
|
from pykwalify import core as pykwalify_core
|
|
from pykwalify import errors as pykwalify_errors
|
|
stream = open(sys.argv[1], 'r')
|
|
schema = yaml.load(stream)
|
|
check = pykwalify_core.Core(sys.argv[2], schema_data=schema)
|
|
try:
|
|
check.validate(raise_exception=True)
|
|
print ("Validation successful")
|
|
exit(0)
|
|
except pykwalify_errors.SchemaError as e:
|
|
print ("Config " + sys.argv[2] + " is not valid!")
|
|
raise Exception('File does not conform to schema: {}'.format(e))
|