0de387ee3c
Until now if there is a nit inside any Ansible task part of tripleo-heat-templates we will need to wait until the end-to-end test imports the actual tasks to fail. This submission adds the hability to run a syntax check for any Ansible task part of any role defined by default in the resource registry. Also it will allow to reduce the CI CO2 footprint by not executing unneeded jobs meant to fail. Let's save the planet and some CI cycles. Change-Id: I6eb7c873cc9a4b7d765e745dc260475bff7b268a
38 lines
1.2 KiB
Python
38 lines
1.2 KiB
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 os
|
|
|
|
import ansible_runner
|
|
|
|
|
|
def test_tht_ansible_syntax(pytestconfig):
|
|
|
|
tht_root = str(pytestconfig.invocation_params.dir)
|
|
role_path = os.path.join(tht_root,
|
|
"tripleo_heat_templates/tests/roles/tripleo-ansible/tripleo-ansible/tripleo_ansible/roles")
|
|
play_path = os.path.join(tht_root,
|
|
"tripleo_heat_templates/tests/test_tht_ansible_syntax.yml")
|
|
|
|
os.environ["ANSIBLE_ROLES_PATH"] = role_path
|
|
|
|
run = ansible_runner.run(
|
|
playbook=play_path,
|
|
extravars={'tht_root': tht_root}
|
|
)
|
|
|
|
try:
|
|
assert run.rc == 0
|
|
finally:
|
|
print("{}: {}".format(run.status, run.rc))
|