From c949f3a8341a291967dff3a0ba55e63d10a06cb0 Mon Sep 17 00:00:00 2001 From: Sam Potekhin Date: Tue, 9 May 2023 00:44:30 +0700 Subject: [PATCH] nmcli: added new module option 'slave_type' to allow create non-ethernet slave connections (#6108) * nmcli: added new module option 'slave_type' to allow create non-ethernet slave connections * argument specs updated * documentation updated * examples updated * added warning message when using type='bridge-slave' * remove trailing whitespace * Added warnings about rewrite 'slave-type' property when using type one of 'bond-slave', 'bridge-slave', 'team-slave'. Added module fails when user sets contradicting values of 'slave-type' for types 'bond-slave', 'bridge-slave', 'team-slave'. Returned back checking for types that can be a slave to assign 'master' and 'slave-type' properties. * Extending list of slave-conn-types * Update plugins/modules/nmcli.py Version updated Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update plugins/modules/nmcli.py Updated documentation for `slave_type` Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Updated argspec's 'required_by' for 'master' property. * Fixed mistake in property naming in module argspec. * changelog fragment and module docs updated * Validation of 'master', 'slave_type' options improved. (rebased) * Validation of 'master' and 'slave_type' separated to special method. * Wrote 6 tests for slave_type option behaviour * Removed erroneously added property 'hairpin' * Update version_added for 'slave_type' Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> * Update changelogs/fragments/473-nmcli-slave-type-implemented.yml Co-authored-by: Felix Fontein * Update plugins/modules/nmcli.py Co-authored-by: Felix Fontein * Let master be without slave_type --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Felix Fontein --- .../473-nmcli-slave-type-implemented.yml | 2 + plugins/modules/nmcli.py | 103 +++++- tests/unit/plugins/modules/test_nmcli.py | 292 ++++++++++++++++++ 3 files changed, 389 insertions(+), 8 deletions(-) create mode 100644 changelogs/fragments/473-nmcli-slave-type-implemented.yml diff --git a/changelogs/fragments/473-nmcli-slave-type-implemented.yml b/changelogs/fragments/473-nmcli-slave-type-implemented.yml new file mode 100644 index 0000000000..aa9dabe12e --- /dev/null +++ b/changelogs/fragments/473-nmcli-slave-type-implemented.yml @@ -0,0 +1,2 @@ +minor_changes: + - nmcli - new module option ``slave_type`` added to allow creation of various types of slave devices (https://github.com/ansible-collections/community.general/issues/473, https://github.com/ansible-collections/community.general/pull/6108). diff --git a/plugins/modules/nmcli.py b/plugins/modules/nmcli.py index 4c7920dd03..053182c2c0 100644 --- a/plugins/modules/nmcli.py +++ b/plugins/modules/nmcli.py @@ -66,6 +66,8 @@ options: - Type C(macvlan) is added in community.general 6.6.0. - Type C(wireguard) is added in community.general 4.3.0. - Type C(vpn) is added in community.general 5.1.0. + - Using C(bond-slave), C(bridge-slave) or C(team-slave) implies C(ethernet) connection type with corresponding I(slave_type) option. + - If you want to control non-ethernet connection attached to C(bond), C(bridge) or C(team) consider using C(slave_type) option. type: str choices: [ bond, bond-slave, bridge, bridge-slave, dummy, ethernet, generic, gre, infiniband, ipip, macvlan, sit, team, team-slave, vlan, vxlan, wifi, gsm, wireguard, vpn ] @@ -81,9 +83,16 @@ options: type: str choices: [ datagram, connected ] version_added: 5.8.0 + slave_type: + description: + - Type of the device of this slave's master connection (for example C(bond)). + type: str + choices: [ 'bond', 'bridge', 'team' ] + version_added: 7.0.0 master: description: - Master