Skip to content

Commit

Permalink
Merge pull request #161 from mnasiadka/ignore_status_check
Browse files Browse the repository at this point in the history
Allow ignoring interface status checks
  • Loading branch information
markgoddard authored Jul 16, 2024
2 parents 58f01e9 + cf61c7d commit c941805
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ interfaces_setup_gather_subset: "{{ omit }}"
# An option to merge all configurations setup with merge: true
# in the global interfaces file (Debian-Family only)
interfaces_merge: false

# An option that does not fail interfaces bounce action when an
# error has occured - useful when you assume one of the interfaces
# to not have proper state.
interfaces_bounce_ignore_errors: false
```
Note: The values for the list are listed in the examples below.
Expand Down
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ interfaces_setup_filter: "{{ omit }}"
interfaces_setup_gather_subset: "{{ omit }}"
interfaces_bond_setup_slaves: true
interfaces_merge: false
interfaces_bounce_ignore_errors: false
2 changes: 1 addition & 1 deletion filter_plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _interface_check(context, interface, interface_type=None):
# secondary IP addresses on another interface.
if ':' not in device:
# State
if not fact.get("active"):
if not fact.get("active") and not bool(interface.get("ignore_status_check")):
return _fail("Interface %s is not active" % device)

# Type
Expand Down
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@
{% for interface in all_interfaces_changed %}
if ! nmcli connection up {{ interface }}; then
echo \"Failed to bring up interface {{ interface }}\";
{% if interfaces_bounce_ignore_errors | bool %}
returncode=1
{% endif %}
fi;
{% endfor %}
Expand All @@ -145,7 +147,9 @@
all_connected=false
if [ $i -eq 20 ]; then
echo 'Interface {{ interface }} failed to become active and have a connected carrier';
{% if interfaces_bounce_ignore_errors | bool %}
returncode=1
{% endif %}
fi
fi;
{% endfor %}
Expand Down Expand Up @@ -201,7 +205,9 @@
{% for interface in all_interfaces_changed %}
if ! ifup {% if ansible_facts.os_family == 'Debian' %}--allow auto {% endif %}{{ interface }}; then
echo \"Failed to bring up interface {{ interface }}\";
{% if interfaces_bounce_ignore_errors | bool %}
returncode=1
{% endif %}
fi;
{% endfor %}
Expand Down

0 comments on commit c941805

Please sign in to comment.