Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quiet ansible #150

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ansible_roles/roles/log_and_terminate/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
# tasks file for termination on failure

- name: First,log to the error log
cmd: "echo Fatal error: {{ exit_msg }} >> {{ working_dir }}/error_log"

- name: Aborting test
fail:
msg: "{{ exit_msg }}"

8 changes: 5 additions & 3 deletions ansible_roles/roles/terminate_on_error/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
vars:
tf_dir: "tf"
when: config_info.cloud_terminate_instance == 1 and config_info.term_system == "yes"
- name: Aborting test
fail:
msg: "{{ exit_msg }}"
- name: Log failure
include_role:
name: log_and_terminate
vars:
exit_msg: "{{ exit_msg }}"
when: status.rc == 1

38 changes: 32 additions & 6 deletions bin/burden
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ gl_max_systems_set=0
# should provide a usage. The --test_version_check option is present
# so we can only check the versions via an option
#
gl_ansible_verbosity="normal"
gl_test_version_check=1
gl_update_test_versions=0
gl_disk_iops=0
Expand Down Expand Up @@ -1895,13 +1896,22 @@ create_ansible_options()
if [[ "$gl_ssh_key_file" != "" ]]; then
base_string="${base_string} -s $gl_ssh_key_file"
fi
if [[ $gl_ansible_verbosity != "normal" ]]; then
base_string=${base_string}" -l $gl_ansible_verbosity"
fi
echo $cli "${arguments[@]}" | sed "s/bin/./g" > ${run_dir}/exec_command
kick_off.sh $base_string | tee ${run_dir}/ansible_log &
pids[${pindex}]=$!
test_info_str=`grep test_to_run: $run_dir/ansible_vars_main.yml | sed "s/\[//g" | sed "s/\]//g" | cut -d: -f 2 | sed "s/ //g"`
echo "Starting ${test_info_str} on ${host_or_cloud_inst}"
kick_off.sh $base_string &
index=$!
pids[${pindex}]="${index}:${test_info_str} on ${host_or_cloud_inst}"
let "pindex=$pindex+1"
if [[ $pindex -eq $gl_max_systems ]]; then
for pid in ${pids[*]}; do
wait $pid
for pid in "${pids[*]}"; do
wait_for=`echo $pid | cut -d ':' -f 1`
wait $wait_for
out_string=`echo $pid | cut -d ':' -f 2-`
echo Finsihed $out_string
done
pindex=0
fi
Expand All @@ -1915,8 +1925,11 @@ create_ansible_options()
#
# Wait for everyone to finish up.
#
for pid in ${pids[*]}; do
wait $pid
for pid in "${pids[*]}"; do
wait_for=`echo $pid | cut -d ':' -f 1`
wait $wait_for
out_string=`echo $pid | cut -d ':' -f 2-`
echo Finsihed $out_string
done

#
Expand Down Expand Up @@ -3042,6 +3055,10 @@ usage()
echo "Usage: $0"
echo "Version: "$version
echo "General options"
echo " --ansible_noise_level <level>: How much information ansible is to output."
echo " normal: standard ansible output"
echo " dense: just report the task executed"
echo " silence: nothing reported"
echo " --archive <dir>/<results>: location to save the archive information to"
echo " --child: tells burden it is a child of another burden process and not to"
echo " perform the initial setup work"
Expand Down Expand Up @@ -3218,6 +3235,14 @@ set_general_value()
{
shift_by=0
case "$1" in
--ansible_noise_level)
echo "$1 $2" >> $gl_cli_supplied_options
if [[ $2 != "normal" ]] && [[ $2 != "dense" ]] && [[ $2 != "silence" ]]; then
cleanup_and_exit "$2 not valid value for --ansible_noise_level. Valid values are normal, dense or silence" 1
fi
gl_ansible_verbosity=$2
shift_by=2
;;
--archive)
if [[ $gl_archive_location == $value_not_set ]]; then
gl_archive_location=$2
Expand Down Expand Up @@ -3584,6 +3609,7 @@ grab_cli_data()
# Define user options
#
ARGUMENT_LIST=(
"ansible_noise_level"
"archive"
"cloud_os_id"
"create_attempts"
Expand Down
17 changes: 16 additions & 1 deletion bin/kick_off.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ spot_recover=1
create_attempts=5
remove_dirs=0
ssh_key_file=""
while getopts "a:c:d:f:s:rS:t:" o; do
ansible_noise_level="normal"
while getopts "a:c:d:f:s:rS:t:l:" o; do
case "${o}" in
a)
create_attempts=${OPTARG}
Expand All @@ -103,6 +104,9 @@ while getopts "a:c:d:f:s:rS:t:" o; do
f)
tune_file=${OPTARG}
;;
l)
ansible_noise_level=${OPTARG}
;;
r)
remove_dirs=1
;;
Expand Down Expand Up @@ -167,6 +171,17 @@ done
export ANSIBLE_HOST_KEY_CHECKING=False
echo "[defaults]" >> ansible.cfg
echo "roles_path = ~/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:~/.ansible/collections/ansible_collections/pbench/agent/roles" >> ansible.cfg
echo "log_path=${curdir}/ansible_log" >> ansible.cfg
if [[ $ansible_noise_level != "normal" ]]; then
if [[ $ansible_noise_level == "silence" ]]; then
#
# Ansible option for no output is null.
#
echo "stdout_callback = null" >> ansible.cfg
else
echo "stdout_callback = $ansible_noise_level" >> ansible.cfg
fi
fi
current_test=0
for sys_config in ${individual};
do
Expand Down
4 changes: 4 additions & 0 deletions documentation/zathras_doc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ $ ./burden --verbose
Usage: ./bin/burden
Version: 3.0
General options
--ansible_noise_level: &lt;level&gt;: How much information ansible is to output.
normal: standard ansible output
dense: just report the task executed
silence: nothing reported
--archive &lt;dir&gt;/&lt;results&gt;: location to save the archive information to
--child: tells burden it is a child of another burden process and not to
perform the initial setup work
Expand Down