Bump linters and remove dead code

- builds linters to current versions
- adds two missing roles used internally to mock list
- adds few missing modules to mock list
- nukes usbkey quickstart feature because it was fully broken and
  prevented newer linter from running on it. The current code
  attempted to run a tasks file as a playbooks, something that will
  never work.

Change-Id: I38b6f2fa9e831534eaca090ad51f531a742ec999
This commit is contained in:
Sorin Sbarnea 2021-07-05 14:14:39 +01:00 committed by Marios Andreou
parent 18a7677a84
commit 6b8fca9a2e
11 changed files with 25 additions and 567 deletions

View File

@ -3,6 +3,9 @@ parseable: true
exclude_paths:
- config/
- releasenotes/
# this file tries to execute a file that is part of tripleo-quickstart-extras
# so it will never pass.
- playbooks/build-images-and-quickstart.yml
skip_list:
# One two excuses for adding skips: bugs in linter and recent linter bumping
- '204' # [E204] Lines should be no longer than 120 chars
@ -12,3 +15,13 @@ skip_list:
- '208' # [E208] File permissions unset or incorrect
- '106' # [E106] Role name {} does not match ^[a-z][a-z0-9_]+$ pattern
- '303' # [E303] Using command rather than module
mock_roles:
- extras-common
- image-build
mock_modules:
- authorized_key
- modprobe
- openvswitch_bridge
- virt
- virt_net
- virt_pool

View File

@ -26,15 +26,8 @@ repos:
- id: flake8
- id: check-yaml
files: .*\.(yaml|yml)$
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.20.0
hooks:
- id: yamllint
files: \.(yaml|yml)$
types: [file, yaml]
entry: yamllint --strict -f parsable
- repo: https://github.com/ansible/ansible-lint.git
rev: 9da220ae3a11c10c10ee43284ad6cad6d8ba52b7
- repo: https://github.com/ansible-community/ansible-lint.git
rev: v5.1.0a1
hooks:
- id: ansible-lint
always_run: true
@ -44,8 +37,11 @@ repos:
# https://github.com/ansible/ansible-lint/issues/611
verbose: true
entry: env ANSIBLE_LIBRARY=library ansible-lint --force-color -p -v
additional_dependencies:
- ansible-core
- yamllint
- repo: https://github.com/openstack-dev/bashate.git
rev: 0.6.0
rev: 2.0.0
hooks:
- id: bashate
entry: bashate --error . --ignore=E006,E040

View File

@ -1,79 +0,0 @@
#!/bin/bash
set -e
######################################################################
# This script is part of the ooo-quickstart usbkey. It's designed
# to execute the quickstart from a usbkey on a test machine directly.
#
######################################################################
if [ -f /etc/redhat-release ]; then
if grep -q -i "Red Hat\|CentOS" /etc/redhat-release; then
true;
else
echo "Red Hat Enterprise Linux and CentOS are currently supported"
echo "We are working to add support for Fedora."
exit 1
fi
else
echo "Sorry your linux distribution is not supported at this time"
exit 1
fi
SCRIPT=$( readlink -f "${BASH_SOURCE[0]}" )
USB_DIR=$( dirname $SCRIPT )
#Set ansible environmental variables
source $USB_DIR/ansible_env
#launch quickstart using the local image against the localhost
pushd $USB_DIR/tripleo-quickstart
export COMMAND="bash quickstart.sh \
--playbook quickstart-usb.yml \
--extra-vars image_cache_dir=$HOME \
--extra-vars undercloud_image_url=file://$USB_DIR/undercloud.qcow2 \
localhost"
#check if the current user is root
if [[ $USER == root ]]; then
echo "Use a non-root user with sudo permissions instead of root, exiting"
exit
fi
echo "==================================================================="
echo "Installing Dependencies"
sudo bash quickstart.sh --install-deps
echo "==================================================================="
echo "Running tripelo-quickstart in 15 seconds w/ the following command"
echo ""
echo "See https://github.com/openstack/tripleo-quickstart for the latest"
echo "documenation and source code"
echo "==================================================================="
echo ""
echo $COMMAND
sleep 15
$COMMAND
echo ""
cat <<EOF
##################################
Note to ooo-usbkey users
##################################
Access the undercloud by:
ssh -F $HOME/.quickstart/ssh.config.local.ansible undercloud
Note: Using quickstart directly on the localhost requires a separate ssh config file.
Proceed with the above instructions.
##################################
Note to ooo-usbkey users
##################################
EOF
popd

View File

@ -1,6 +0,0 @@
#Set ansible environmental variables
export ANSIBLE_HOST_KEY_CHECKING=False
export ANSIBLE_FORCE_COLOR=1
export ANSIBLE_INVENTORY=$HOME/.quickstart/hosts
export SSH_CONFIG=$HOME/.quickstart/ssh.config.local.ansible
export ANSIBLE_SSH_ARGS="-F ${SSH_CONFIG}"

View File

@ -1,47 +0,0 @@
---
# This is the playbook used by the `quickstart.sh` script.
# The [provision.yml](provision.yml.html) playbook is responsible for
# creating an inventory entry for our `virthost` and for creating an
# unprivileged user on that host for use by our virtual environment.
- include_tasks: provision.yml
tags:
- provision
# The `environment/setup` role performs any tasks that require `root`
# access on the target host.
- name: Install libvirt packages and configure networks
hosts: virthost
tags:
- environment
roles:
- environment/setup
# The `libvirt/setup` role creates the undercloud and overcloud
# virtual machines.
- name: Setup undercloud and overcloud vms
hosts: virthost
gather_facts: true
roles:
- libvirt/teardown
- libvirt/setup
# Add the undercloud node to the generated
# inventory.
- name: Inventory the undercloud
hosts: localhost
gather_facts: true
vars:
inventory: undercloud
roles:
- tripleo-inventory
# DEPLOY ALL THE THINGS! Depending on the currently selected set of
# tags, this will deploy the undercloud, deploy the overcloud, and
# perform some validation tests on the overcloud.
- name: Install undercloud and deploy overcloud
hosts: undercloud
gather_facts: false
roles:
- tripleo/undercloud
- tripleo/overcloud

View File

@ -1,368 +0,0 @@
#!/bin/bash
DEFAULT_OPT_TAGS="untagged,provision,environment,undercloud-inventory,overcloud-scripts"
: ${OPT_BOOTSTRAP:=0}
: ${OPT_SYSTEM_PACKAGES:=0}
: ${OPT_WORKDIR:=$HOME/.quickstart}
: ${OPT_TAGS:=$DEFAULT_OPT_TAGS}
: ${OPT_REQUIREMENTS:=requirements.txt}
: ${OPT_PLAYBOOK:=quickstart.yml}
install_deps () {
yum -y install \
/usr/bin/git \
/usr/bin/virtualenv \
gcc \
libyaml \
libselinux-python \
libffi-devel \
openssl-devel
}
print_logo () {
if [ `tput cols` -lt 105 ]; then
cat <<EOBANNER
----------------------------------------------------------------------------
| , . , |
| )-_'''_-( |
| ./ o\ /o \. |
| . \__/ \__/ . |
| ... V ... |
| ... - - - ... |
| . - - . |
| \`-.....-´ |
| ____ ____ ____ _ _ _ _ |
| / __ \ / __ \ / __ \ (_) | | | | | | |
| | | | | ___ | | | | | | | |_ _ _ ___| | _____| |_ __ _ _ __| |_ |
| | | | |/ _ \| | | | | | | | | | | |/ __| |/ / __| __/ _\` | '__| __| |
| | |__| | |_| | |__| | | |__| | |_| | | (__| <\__ \ |_|(_| | | | |_ |
| \____/ \___/ \____/ \___\_\\\__,_|_|\___|_|\_\___/\__\__,_|_| \__| |
| |
| |
----------------------------------------------------------------------------
EOBANNER
else
cat <<EOBANNER
-------------------------------------------------------------------------------------------------------
| , . , _______ _ _ ____ ____ _ _ _ _ |
| )-_'''_-( |__ __| (_) | | / __ \ / __ \ (_) | | | | | | |
| ./ o\ /o \. | |_ __ _ _ __ | | ___| | | | | | | |_ _ _ ___| | _____| |_ __ _ _ __| |_ |
| . \__/ \__/ . | | '__| | '_ \| |/ _ \ | | | | | | | | | | |/ __| |/ / __| __/ _\` | '__| __| |
| ... V ... | | | | | |_) | | __/ |__| | | |__| | |_| | | (__| <\__ \ |_|(_| | | | |_ |
| ... - - - ... |_|_| |_| .__/|_|\___|\____/ \___\_\\\__,_|_|\___|_|\_\___/\__\__,_|_| \__| |
| . - - . | | |
| \`-.....-´ |_| |
-------------------------------------------------------------------------------------------------------
EOBANNER
fi
}
# This creates a Python virtual environment and installs
# tripleo-quickstart into that environment. It only runs if
# the local working directory does not exist, or if explicitly
# requested via --bootstrap.
bootstrap () {
( # run in a subshell so that we can 'set -e' without aborting
# the main script immediately (because we want to clean up
# on failure).
set -e
virtualenv\
$( [ "$OPT_SYSTEM_PACKAGES" = 1 ] && printf -- "--system-site-packages\n" )\
$OPT_WORKDIR
. $OPT_WORKDIR/bin/activate
if [ "$OPT_NO_CLONE" != 1 ]; then
if ! [ -d "$OOOQ_DIR" ]; then
echo "Cloning tripleo-quickstart repository..."
git clone https://opendev.org/openstack/tripleo-quickstart \
$OOOQ_DIR
fi
cd $OOOQ_DIR
if [ -n "$OPT_GERRIT" ]; then
git review -d "$OPT_GERRIT"
else
git remote update
git checkout --quiet origin/master
fi
fi
pushd $OOOQ_DIR
# (trown) This is a pretty big hack, but for the usbkey case, we don't
# want to be writing files to the usbkey itself, and I can not find a
# way to make setuptools not try to write the .eggs dir.
sed -i "s%os.curdir%\'$OPT_WORKDIR\'%" $OPT_WORKDIR/lib/python2.7/site-packages/setuptools/dist.py
python setup.py install egg_info --egg-base $OPT_WORKDIR
# Handle the case that pip is too old to use a cache-dir
pip install --no-cache-dir -r $OPT_REQUIREMENTS || pip install -r $OPT_REQUIREMENTS
popd
)
}
activate_venv() {
. $OPT_WORKDIR/bin/activate
}
usage () {
echo "$0: usage: $0 [options] virthost [release]"
echo "$0: usage: sudo $0 --install-deps"
echo "$0: options:"
echo " --system-site-packages"
echo " --ansible-debug"
echo " --bootstrap"
echo " --working-dir <directory>"
echo " --tags <tag1>[,<tag2>,...]"
echo " --skip-tags <tag1>,[<tag2>,...]"
echo " --config <file>"
echo " --playbook <file>"
echo " --extra-vars <key>=<value>"
echo " --requirements <requirements.txt>"
echo " --print-logo"
}
OPT_VARS=()
while [ "x$1" != "x" ]; do
case "$1" in
--install-deps)
OPT_INSTALL_DEPS=1
;;
--system-site-packages|-s)
OPT_SYSTEM_PACKAGES=1
;;
--requirements|-z)
OPT_REQUIREMENTS=$2
shift
;;
--bootstrap|-b)
OPT_BOOTSTRAP=1
;;
--ansible-debug|-v)
OPT_DEBUG_ANSIBLE=1
;;
--working-dir|-w)
OPT_WORKDIR=$2
shift
;;
--tags|-t)
OPT_TAGS=$2
shift
;;
--skip-tags)
OPT_SKIP_TAGS=$2
shift
;;
--config|-c)
OPT_CONFIG=$2
shift
;;
--playbook|-p)
OPT_PLAYBOOK=$2
shift
;;
--extra-vars|-e)
OPT_VARS+=("-e")
OPT_VARS+=("$2")
shift
;;
--help|-h)
usage
exit
;;
# developer options
--gerrit|-g)
OPT_GERRIT=$2
OPT_BOOTSTRAP=1
shift
;;
--no-clone|-n)
OPT_NO_CLONE=1
;;
--print-logo|-pl)
PRINT_LOGO=1
;;
--) shift
break
;;
-*) echo "ERROR: unknown option: $1" >&2
usage >&2
exit 2
;;
*) break
;;
esac
shift
done
if [ "$PRINT_LOGO" = 1 ]; then
print_logo
echo "..."
echo "Nothing more to do"
exit 1
fi
if [ "$OPT_NO_CLONE" = 1 ]; then
OOOQ_DIR=.
else
OOOQ_DIR=$OPT_WORKDIR/tripleo-quickstart
fi
# Set this default after option processing, because the default depends
# on another option.
: ${OPT_CONFIG:=$OOOQ_DIR/config/general_config/minimal.yml}
if [ "$OPT_INSTALL_DEPS" = 1 ]; then
echo "NOTICE: installing dependencies"
install_deps
exit $?
fi
if [ "$OPT_BOOTSTRAP" = 1 ] || ! [ -f "$OPT_WORKDIR/bin/activate" ]; then
bootstrap
if [ $? -ne 0 ]; then
echo "ERROR: bootstrap failed; removing $OPT_WORKDIR"
echo " try "sudo $0 --install-deps" to install requirements"
rm -rf $OPT_WORKDIR
exit 1
fi
fi
if [ "$#" -lt 1 ]; then
echo "ERROR: You must specify a target machine." >&2
usage >&2
exit 2
fi
if [ "$#" -gt 2 ]; then
usage >&2
exit 2
fi
VIRTHOST=$1
RELEASE=$2
# We use $RELEASE to build the undercloud image URL. It is also passed to the
# quickstart playbook, since there are now some version specific behaviors.
# If the user has provided an explicit URL, we should warn them of that
# fact.
if [ -z "$RELEASE" ]; then
RELEASE=train
fi
print_logo
echo "Installing OpenStack ${RELEASE:+"$RELEASE "}on host $VIRTHOST"
echo "Using directory $OPT_WORKDIR for a local working directory"
activate_venv
set -ex
export ANSIBLE_CONFIG=$OOOQ_DIR/ansible.cfg
export ANSIBLE_INVENTORY=$OPT_WORKDIR/hosts
# Clear out inventory file to avoid tripping over data
# from a previous invocation
rm -f $ANSIBLE_INVENTORY
if [ "$VIRTHOST" = "localhost" ]; then
echo "$0: WARNING: VIRTHOST == localhost; skipping provisioning" >&2
OPT_SKIP_TAGS="${OPT_SKIP_TAGS:+$OPT_SKIP_TAGS,}provision"
echo "[virthost]" > $ANSIBLE_INVENTORY
echo "localhost ansible_connection=local" >> $ANSIBLE_INVENTORY
fi
if [ "$OPT_DEBUG_ANSIBLE" = 1 ]; then
VERBOSITY=vvvv
else
VERBOSITY=vv
fi
ansible-playbook -$VERBOSITY $OPT_WORKDIR/playbooks/$OPT_PLAYBOOK \
-e @$OPT_CONFIG \
-e ansible_python_interpreter=/usr/bin/python \
-e @$OOOQ_DIR/config/release/$RELEASE.yml \
-e local_working_dir=$OPT_WORKDIR \
-e virthost=$VIRTHOST \
${OPT_VARS[@]} \
${OPT_TAGS:+-t $OPT_TAGS} \
${OPT_SKIP_TAGS:+--skip-tags $OPT_SKIP_TAGS}
# We only print out further usage instructions when using the default
# tags, since this is for new users (and not even applicable to some tags).
set +x
if [ $OPT_TAGS = $DEFAULT_OPT_TAGS ] ; then
cat <<EOF
##################################
Virtual Environment Setup Complete
##################################
Access the undercloud by:
ssh -F $OPT_WORKDIR/ssh.config.ansible undercloud
There are scripts in the home directory to continue the deploy:
undercloud-install.sh will run the undercloud install
undercloud-post-install.sh will perform all pre-deploy steps
overcloud-deploy.sh will deploy the overcloud
overcloud-deploy-post.sh will do any post-deploy configuration
overcloud-validate.sh will run post-deploy validation
Alternatively, you can ignore these scripts and follow the upstream docs:
First:
openstack undercloud install
source stackrc
Then continue with the instructions (limit content using dropdown on the left):
http://ow.ly/Ze8nK
##################################
Virtual Environment Setup Complete
##################################
EOF
fi

View File

@ -1,7 +0,0 @@
# General requirements
ansible==2.2.0.0
netaddr>=0.7.18
pbr>=1.6
setuptools>=11.3
# Roles

View File

@ -4,4 +4,6 @@
- name: noop playbook
hosts: localhost
tasks:
- debug: msg="noop"
- name: display noop
debug:
msg: noop

View File

@ -163,7 +163,8 @@
changed_when: true
failed_when: false
- debug:
- name: Display message
debug:
msg: "Add basic packages we need to the image"
- environment:

View File

@ -5,7 +5,7 @@
retries: "{{ libvirt_wait_retries }}"
delay: "{{ libvirt_wait_delay }}"
- name: Set_fact for undercloud ip
- name: Set_fact for undercloud ip # noqa: var-naming
set_fact:
"{{ item.name.replace('-', '_') }}_ip": "{{ ip_result.stdout_lines[0] }}"
cacheable: true

View File

@ -1,47 +0,0 @@
---
# This is the playbook used by the `quickstart.sh` script.
# The [provision.yml](provision.yml.html) playbook is responsible for
# creating an inventory entry for our `virthost` and for creating an
# unprivileged user on that host for use by our virtual environment.
- include_tasks: provision.yml
tags:
- provision
# The `environment/setup` role performs any tasks that require `root`
# access on the target host.
- name: Install libvirt packages and configure networks
hosts: virthost
tags:
- environment
roles:
- environment/setup
# The `libvirt/setup` role creates the undercloud and overcloud
# virtual machines.
- name: Setup undercloud and overcloud vms
hosts: virthost
gather_facts: true
roles:
- libvirt/teardown
- libvirt/setup
# Add the undercloud node to the generated
# inventory.
- name: Inventory the undercloud
hosts: undercloud
gather_facts: false
vars:
inventory: undercloud
roles:
- tripleo-inventory
# DEPLOY ALL THE THINGS! Depending on the currently selected set of
# tags, this will deploy the undercloud, deploy the overcloud, and
# perform some validation tests on the overcloud.
- name: Install undercloud and deploy overcloud
hosts: undercloud
gather_facts: false
roles:
- tripleo/undercloud
- tripleo/overcloud