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 23, 2021
1 parent 311c5fd commit cd23e08
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 8 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
21 changes: 21 additions & 0 deletions ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[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 }}
{% 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"
29 changes: 27 additions & 2 deletions vm-setup/roles/v1aX_integration_test/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,34 @@
namespace: "{{ NAMESPACE }}"
when: v1aX_integration_test_action in provision_workers_actions

- name: verify deployment
include_tasks: verify.yml
- name: Verify provisioning
block:
- name: verify deployment
include_tasks: verify.yml
when: v1aX_integration_test_action in verify_actions
rescue:
- name: Gather debug info
community.kubernetes.k8s_info:
api_version: "{{ item.api_version }}"
kind: "{{ item.kind }}"
register: resources
loop:
- api_version: cluster.x-k8s.io/v1alpha3
kind: Cluster
- api_version: metal3.io/v1alpha1
kind: BareMetalHost
- api_version: cluster.x-k8s.io/v1alpha3
kind: Machine
- api_version: v1
kind: Node
- api_version: v1
kind: Pod
- name: Print debug info
debug:
msg: "{{ resources }}"
- name: Fail due to earlier error
ansible.builtin.fail:
msg: Failed due to earlier errors

- name: pivot
include_tasks: move.yml
Expand Down

0 comments on commit cd23e08

Please sign in to comment.