3 # ============LICENSE_START=======================================================
4 # Copyright (C) 2019 The Nordix Foundation. All rights reserved.
5 # ================================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
18 # SPDX-License-Identifier: Apache-2.0
19 # ============LICENSE_END=========================================================
21 # source engine-vars.sh so we can install the correct versions of
22 # pip, ansible, and ansible-lint
23 source $WORKSPACE/engine/config/engine-vars.sh
25 # install dependencies
26 sudo apt update > /dev/null 2>&1
27 sudo apt install -y -q=3 gcc libffi-dev libssl-dev lsb-release libpython3-dev \
28 python3-minimal python3-pip python3-yaml virtualenv > /dev/null 2>&1
31 echo "Info: Install pip==$ENGINE_PIP_VERSION ansible==$ENGINE_ANSIBLE_VERSION and ansible-lint==$ENGINE_ANSIBLE_LINT_VERSION"
32 echo "----------------------------------------------------"
34 # install pip, ansible, and ansible-lint in venv
35 export ANSIBLE_VENV=$WORKSPACE/.venv
36 virtualenv -p python3 --quiet --no-site-packages ${ANSIBLE_VENV}
37 source ${ANSIBLE_VENV}/bin/activate
38 pip -q install --upgrade pip==$ENGINE_PIP_VERSION
39 pip -q install --upgrade virtualenv pip setuptools shade \
40 ansible==$ENGINE_ANSIBLE_VERSION ansible-lint==$ENGINE_ANSIBLE_LINT_VERSION
42 echo "----------------------------------------------------"
44 echo "Info: Run ansible-lint on playbooks"
45 echo "----------------------------------------------------"
47 # the locations of the engine playbooks
48 playbooks_dir=(engine/playbooks engine/provisioner/bifrost/playbooks engine/provisioner/heat/playbooks \
49 engine/installer/kolla/playbooks engine/installer/kubespray/playbooks)
51 # set exit_code so we exit ourselves rather than ansible-lint bailing out without
52 # verifying all the playbooks
53 declare -i exit_code=0
56 for dir in ${playbooks_dir[@]}; do
57 for play in $(ls ${WORKSPACE}/${dir}/*.yml); do
58 echo "--> Checking '${play}' playbook..."
59 ansible-lint --nocolor ${play}
61 if [[ $lint_exit_code != 0 ]]; then
62 exit_code=$lint_exit_code
69 echo "----------------------------------------------------"
73 # vim: set ts=2 sw=2 expandtab: