Skip to content

Commit

Permalink
Reducs Ansible verbosity and use DIY callback
Browse files Browse the repository at this point in the history
The DIY callback plugin is configured to print only the status of k8s
resources instead of everything (but otherwise work as before).
Ansible verbosity is turned down to default.
  • Loading branch information
lentzi90 committed Jun 24, 2021
1 parent 311c5fd commit cc03f55
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 01_prepare_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "metal3_dir=$SCRIPTDIR" \
-e "virthost=$HOSTNAME" \
-i vm-setup/inventory.ini \
-b -vvv vm-setup/install-package-playbook.yml
-b vm-setup/install-package-playbook.yml

# shellcheck disable=SC1091
source lib/network.sh
Expand Down
4 changes: 2 additions & 2 deletions 02_configure_host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "nodes_file=$NODES_FILE" \
-e "node_hostname_format=$NODE_HOSTNAME_FORMAT" \
-i vm-setup/inventory.ini \
-b -vvv vm-setup/setup-playbook.yml
-b vm-setup/setup-playbook.yml

# Usually virt-manager/virt-install creates this: https://www.redhat.com/archives/libvir-list/2008-August/msg00179.html
if ! sudo virsh pool-uuid default > /dev/null 2>&1 ; then
Expand Down Expand Up @@ -108,7 +108,7 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "{use_firewalld: $USE_FIREWALLD}" \
-e "external_subnet_v4: ${EXTERNAL_SUBNET_V4}" \
-i vm-setup/inventory.ini \
-b -vvv vm-setup/firewall.yml
-b vm-setup/firewall.yml

# FIXME(stbenjam): ansbile firewalld module doesn't seem to be doing the right thing
if [ "$USE_FIREWALLD" == "True" ]; then
Expand Down
22 changes: 22 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[defaults]
stdout_callback=community.general.diy

[callback_diy]
; Note that the action can be both k8s_info and community.kubernetes.k8s_info
runner_retry_msg='
FAILED: {{ ansible_callback_diy.task.name }}
{{ ("FAILED: " + ansible_callback_diy.task.name) | length * "-" }}
{% if ansible_callback_diy.task.action is search("k8s_info") %}
{% for r in ansible_callback_diy.result.output.resources %}
kind: {{ r.kind }}
name: {{ r.metadata.name }}
{% if r.kind == "BareMetalHost" %}
status.provisioning:
{{ r.status.provisioning | to_nice_yaml | indent(2, first=True) }}
{% else %}
status:
{{ r.status | to_nice_yaml | indent(2, first=True) }}
{% endif %}
{% endfor %}
{% endif %}
RETRYING: {{ ansible_callback_diy.task.name }} {{ ansible_callback_diy.result.output.attempts }}/{{ ansible_callback_diy.task.retries }}'
4 changes: 2 additions & 2 deletions host_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "manage_baremetal=$MANAGE_BR_BRIDGE" \
-e "nodes_file=$NODES_FILE" \
-i vm-setup/inventory.ini \
-b -vvv vm-setup/teardown-playbook.yml
-b vm-setup/teardown-playbook.yml

if [ "$USE_FIREWALLD" == "False" ]; then
ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "{use_firewalld: $USE_FIREWALLD}" \
-e "external_subnet_v4: ${EXTERNAL_SUBNET_V4}" \
-e "firewall_rule_state=absent" \
-i vm-setup/inventory.ini \
-b -vvv vm-setup/firewall.yml
-b vm-setup/firewall.yml
fi

# There was a bug in this file, it may need to be recreated.
Expand Down
2 changes: 1 addition & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ ANSIBLE_FORCE_COLOR=true ansible-playbook \
-e "metal3_dir=$SCRIPTDIR" \
-e "v1aX_integration_test_action=${ACTION}" \
-i "${METAL3_DIR}/vm-setup/inventory.ini" \
-b -vvv "${METAL3_DIR}/vm-setup/v1aX_integration_test.yml"
-b "${METAL3_DIR}/vm-setup/v1aX_integration_test.yml"

0 comments on commit cc03f55

Please sign in to comment.