openstack-ansible/scripts/run-playbooks.sh
Jesse Pretorius 8d2caac546 Restrict Ansible fact gathering to base subset
In Ansible 2.x the fact gathering process includes facts gathered
by facter [1] and ohai [2]if they are available. While this may be
useful in some environment, OpenStack-Ansible does not make use of
any of these facts in any of its playbooks/roles and the facts
gathered are therefore just an extra overhead.

This patch removes the facter and aohai gathering subsets. On a
test AIO this reduced the execution time for fact gathering to the
host and all running containers from 1m5s to 6s.

[1] https://docs.puppet.com/facter/
[2] https://docs.chef.io/ohai.html

This patch also re-implements the selective fact gathering in
run-playbooks that was implemented in
I348a4b7dfe70d56a64899246daf65ea834a75d2a but unintentionally
removed in 9be0662c4f79783d4db8736b89bbd38063635067

Change-Id: I9bfee53571f3dc3a0b0a0950242008e815722180
2016-08-20 13:11:32 +00:00

102 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright 2014, Rackspace US, Inc.
#
# 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.
## Shell Opts ----------------------------------------------------------------
set -e -u
## Variables -----------------------------------------------------------------
DEPLOY_AIO=${DEPLOY_AIO:-false}
COMMAND_LOGS=${COMMAND_LOGS:-"/openstack/log/ansible_cmd_logs/"}
## Main ----------------------------------------------------------------------
function run_play_book_exit_message {
echo -e "\e[1;5;97m*** NOTICE ***\e[0m
The \"\e[1;31m${0}\e[0m\" script has exited. This script is no longer needed from now on.
If you need to re-run parts of the stack, adding new nodes to the environment,
or have encountered an error you will no longer need this application to
interact with the environment. All jobs should be executed out of the
\"\e[1;33m${PLAYBOOK_DIR}\e[0m\" directory using the \"\e[1;32mopenstack-ansible\e[0m\"
command line wrapper.
For more information about OpenStack-Ansible please review our documentation at:
\e[1;36mhttp://docs.openstack.org/developer/openstack-ansible\e[0m
Additionally if there's ever a need for information on common operational tasks please
see the following information:
\e[1;36mhttp://docs.openstack.org/developer/openstack-ansible/developer-docs/ops.html\e[0m
If you ever have any questions please join the community conversation on IRC at
#openstack-ansible on freenode.
"
}
function playbook_run {
# First we gather facts about the hosts to populate the fact cache.
# We can't gather the facts for all hosts yet because the containers
# aren't built yet.
ansible -m setup -a "gather_subset=!facter,!ohai" hosts
for root_include in $(awk -F'include:' '{print $2}' setup-everything.yml); do
# Once setup-hosts is complete, we should gather facts for everything
# (now including containers) so that the fact cache is complete for the
# remainder of the run.
if [[ "${root_include}" == "setup-infrastructure.yml" ]]; then
ansible -m setup -a "gather_subset=!facter,!ohai" all
fi
for include in $(awk -F'include:' '{print $2}' "${root_include}"); do
echo "[Executing \"${include}\" playbook]"
if [[ "${DEPLOY_AIO}" = true ]] && [[ "${include}" == "security-hardening.yml" ]]; then
# NOTE(mattt): We have to skip V-38462 as openstack-infra are now building
# images with apt config Apt::Get::AllowUnauthenticated set
# to true.
# NOTE(mhayden): Skipping V-38660 since it breaks the Xenial gate. The
# CI Xenial image has non-SNMPv3 configurations.
install_bits "${include}" --skip-tag V-38462,V-38660
else
install_bits "${include}"
fi
done
done
}
trap run_play_book_exit_message EXIT
info_block "Checking for required libraries." 2> /dev/null || source $(dirname ${0})/scripts-library.sh
# Initiate the deployment
pushd "playbooks"
PLAYBOOK_DIR="$(pwd)"
# Execute setup everything
playbook_run
if [[ "${DEPLOY_AIO}" = true ]]; then
# Log some data about the instance and the rest of the system
log_instance_info
# Log repo data
mkdir -p "${COMMAND_LOGS}/repo_data"
ansible 'repo_all[0]' -m raw \
-a 'find /var/www/repo/os-releases -type l' \
-t "${COMMAND_LOGS}/repo_data"
openstack-ansible os-tempest-install.yml
print_report
fi
popd