forked from seapath/ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathansible-lint.sh
executable file
·72 lines (65 loc) · 1.52 KB
/
ansible-lint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
#
# Copyright (C) 2023, RTE (http://www.rte-france.com)
# SPDX-License-Identifier: Apache-2.0
#
# This script download the sources of a specific pull request,
# then configure and launch ansible-lint on it
set -e
die() {
echo "linter internal failure : $@" 1>&2
exit 1
}
# Standard help message
usage()
{
cat <<EOF
This script is the launcher for the ansible-linter on SEAPATH ansible.
It is separated in two functions in order to display logs properly.
They should be called one after another.
USAGE:
./launch.sh <init|lint>
EOF
}
# Download and prepare the pull request sources
initialization() {
if ! type -p cqfd > /dev/null; then
die "cqfd not found"
fi
# Get sources
git clone -q https://github.com/seapath/ansible
cd ansible
git fetch -q origin ${GITHUB_REF}
git checkout -q FETCH_HEAD
echo "Pull request sources downloaded succesfully"
# Prepare ansible repository
echo "ansible-lint == 5.4" >> .cqfd/docker/requirements.txt
cqfd init
cqfd -b prepare
echo "Sources prepared succesfully"
}
# Launch ansible-lint
ansible_lint() {
cp ci/ansible-lint.conf ansible
cd ansible
INVENTORIES_DIR=/home/virtu/ansible/seapath_inventories
CQFD_EXTRA_RUN_ARGS=" \
-v $INVENTORIES_DIR:/etc/ansible/hosts \
-v $WORK_DIR/ansible/ceph-ansible/roles:/etc/ansible/roles \
" \
cqfd run ansible-lint -c ansible-lint.conf
}
case "$1" in
init)
initialization
exit 0
;;
lint)
ansible_lint
exit 0
;;
*)
usage
die "Unknown command"
;;
esac