From c16f89e8249dd163e64ad95fd782e0e75c66cd9e Mon Sep 17 00:00:00 2001 From: ambroise Date: Fri, 22 Dec 2023 11:38:14 +0100 Subject: [PATCH] - Fixe the integrations test to be correct - Fixe the config module to: - doesn't modify lines not indicated with the deleted and replaced profiles - take correctly in case the case where we have aux line present on device --- .../network/ios/argspec/line/line.py | 6 +- .../network/ios/config/line/line.py | 59 ++++--- plugins/modules/ios_line.py | 36 ++-- .../targets/ios_line/tasks/main.yaml | 2 +- .../ios_line/tests/cli/_populate_config.yaml | 18 +- .../tests/cli/_populate_config_replaced.yaml | 23 +-- .../targets/ios_line/tests/cli/deleted.yaml | 8 +- .../ios_line/tests/cli/empty_config.yaml | 4 +- .../targets/ios_line/tests/cli/gathered.yaml | 2 +- .../targets/ios_line/tests/cli/merged.yaml | 6 +- .../ios_line/tests/cli/overridden.yaml | 6 +- .../targets/ios_line/tests/cli/parsed.yaml | 7 +- .../targets/ios_line/tests/cli/rendered.yaml | 9 +- .../targets/ios_line/tests/cli/replaced.yaml | 6 +- .../targets/ios_line/vars/main.yml | 167 ++++++++---------- .../unit/modules/network/ios/test_ios_line.py | 5 +- 16 files changed, 172 insertions(+), 192 deletions(-) diff --git a/plugins/module_utils/network/ios/argspec/line/line.py b/plugins/module_utils/network/ios/argspec/line/line.py index 7de89f351..ba50b7d6c 100644 --- a/plugins/module_utils/network/ios/argspec/line/line.py +++ b/plugins/module_utils/network/ios/argspec/line/line.py @@ -5,6 +5,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type ############################################# @@ -29,8 +30,7 @@ class LineArgs(object): # pylint: disable=R0903 - """The arg spec for the ios_line module - """ + """The arg spec for the ios_line module""" argument_spec = { "config": { @@ -209,7 +209,7 @@ class LineArgs(object): # pylint: disable=R0903 }, }, }, - } + }, }, }, "running_config": {"type": "str"}, diff --git a/plugins/module_utils/network/ios/config/line/line.py b/plugins/module_utils/network/ios/config/line/line.py index 5cfc80a7f..24d4bd590 100644 --- a/plugins/module_utils/network/ios/config/line/line.py +++ b/plugins/module_utils/network/ios/config/line/line.py @@ -109,28 +109,28 @@ def generate_commands(self): want, have and desired state. """ wantd = deepcopy(self.want) - wantd["lines"] = self._convert_list_to_dict(data=wantd.get("lines", [])) + wantd["lines"] = self._list_to_dict(data=wantd.get("lines", [])) haved = deepcopy(self.have) - haved["lines"] = self._convert_list_to_dict(data=haved.get("lines", [])) + haved["lines"] = self._list_to_dict(data=haved.get("lines", [])) # if state is merged, merge want onto have and then compare if self.state == "merged": wantd = dict_merge(haved, wantd) # if state is deleted, empty out wantd and set haved to wantd - if self.state == "deleted": - haved = {k: v for k, v in haved.items() if k in wantd or not wantd} - wantd = {"lines": {"con 0": {"name": "con 0"}, "vty 0 4": {"name": "vty 0 4"}}} + if self.state == "deleted" and wantd["lines"] != {}: + haved["lines"] = {k: v for k, v in haved["lines"].items() if k in wantd["lines"]} # remove superfluous config if self.state in ["overridden", "deleted"]: for k, have in haved["lines"].items(): if k not in wantd["lines"]: - self._compare(want={}, have=have) + if k == "con 0" or k == "vty 0 4" or k.startswith("aux"): + self._compare(want={"name": k}, have=have) + else: + self._compare(want={}, have=have) elif self.state in ["replaced"]: - only_have_line_k = [k for k in haved["lines"].keys() if k not in wantd["lines"].keys()] - for k in only_have_line_k: - haved["lines"].pop(k) + haved["lines"] = {k: v for k, v in haved["lines"].items() if k in wantd["lines"]} for k, want in wantd["lines"].items(): self._compare(want=want, have=haved["lines"].pop(k, {})) @@ -171,10 +171,20 @@ def _compare(self, want, have): "motd": True, "privilege": 1, } + config_default_transport = { + "transport": { + "input": { + "name": "input", + "ssh": True, + }, + }, + } begin = len(self.commands) if want != {}: want = dict_merge(config_default, want) have = dict_merge(config_default, have) + if "vty 0" in want["name"] or want["name"].startswith("aux"): + want = dict_merge(config_default_transport, want) self._compare_lists(want=want, have=have) if len(self.commands) != begin: self.commands.insert(begin, self._tmplt.render(want or have, "line", False)) @@ -205,13 +215,11 @@ def _compare_lists(self, want, have): for p_key, p_h_entry in l1_h_entry.items(): self.addcmd(data={p_key: p_h_entry}, tmplt=self.parsers[l1], negate=True) elif l1_key == "commands": - l1_w_entry = self._convert_list_to_dict(data=l1_w_entry, key="level") - l1_h_entry = self._convert_list_to_dict( - data=l1_have.pop(l1_key, []), - key="level", - ) + l1_h_entry = l1_have.pop(l1_key, {}) for c_key, c_w_entry in l1_w_entry.items(): - c_h_entry = l1_h_entry.pop(c_key, {"level": c_w_entry["level"], "command": "default"}) + c_h_entry = l1_h_entry.pop( + c_key, {"level": c_w_entry["level"], "command": "default"} + ) self.compare( parsers=self.parsers[l1], want={l1_key: c_w_entry}, @@ -239,7 +247,6 @@ def _compare_lists(self, want, have): negate=True, ) elif l1_key == "commands": - l1_h_entry = self._convert_list_to_dict(data=l1_h_entry, key="level") for c_key, c_h_entry in l1_h_entry.items(): self.compare( parsers=self.parsers[l1], @@ -258,9 +265,7 @@ def _compare_lists(self, want, have): if key == "name": continue if key == "transport": - h_entry = have.pop(key, []) - w_entry = self._convert_list_to_dict(data=w_entry) - h_entry = self._convert_list_to_dict(data=h_entry) + h_entry = have.get(key, {}) for t_key, t_w_entry in w_entry.items(): t_h_entry = h_entry.pop(t_key, {}) self.compare( @@ -275,7 +280,6 @@ def _compare_lists(self, want, have): if key == "name": continue if key == "transport": - h_entry = self._convert_list_to_dict(data=h_entry) for t_key, t_h_entry in h_entry.items(): self.compare( parsers=self.parsers[key], @@ -287,3 +291,18 @@ def _compare_lists(self, want, have): def _convert_list_to_dict(self, data, key="name"): return {_k.get(key, ""): _k for _k in data} if data else {} + + def _list_to_dict(self, data): + l_result = self._convert_list_to_dict(data=data) + + for _name, _line in l_result.items(): + for k, v in _line.items(): + if k == "transport": + l_result[_name][k] = self._convert_list_to_dict(data=v) + elif k in ["accounting", "authorization", "exec"]: + for _sk, _sv in v.items(): + if _sk == "commands": + l_result[_name][k][_sk] = self._convert_list_to_dict( + data=_sv, key="level" + ) + return l_result diff --git a/plugins/modules/ios_line.py b/plugins/modules/ios_line.py index 3d2378f6c..a42f18124 100644 --- a/plugins/modules/ios_line.py +++ b/plugins/modules/ios_line.py @@ -10,6 +10,7 @@ from __future__ import absolute_import, division, print_function + __metaclass__ = type DOCUMENTATION = """ @@ -55,7 +56,7 @@ type: dict suboptions: arap: - description: + description: - For Appletalk Remote Access Protocol - Use an accounting list with this name - I(default) is the default name @@ -68,7 +69,7 @@ elements: dict suboptions: level: - description: + description: - Enable level type: int command: @@ -116,7 +117,7 @@ elements: dict suboptions: level: - description: + description: - Enable level type: int command: @@ -147,7 +148,7 @@ description: Set the soft escape character for this line type: bool value: - description: + description: - Escape character configured - I(BREAK) - Cause escape on BREAK - I(DEFAULT) - Use default escape character @@ -202,11 +203,11 @@ type: str choices: [ '0', '1', '2', '3', '4', '5', '6', '7', 'all'] limit: - description: + description: - Messages queue size (Value between C(<0-2147483647>)) type: int login: - description: + description: - Enable password checking for authentication - Use an authentication list with this name - I(default) is the default name @@ -256,10 +257,8 @@ value: description: The actual hashed password to be configured type: str - no_log: true - no_log: false privilege: - description: + description: - Change privilege level for line - The I(privilege) valu should be between C(0) and C(15) type: int @@ -275,7 +274,7 @@ description: Set maximum number of sessions (Between C(<0-4294967295>)) type: int timeout: - description: + description: - Set interval for closing connection when there is no input traffic - (Between C(<0-35791>)) type: int @@ -283,7 +282,7 @@ description: Set the transmit and receive speeds (Between C(<0-4294967295>)) type: int stopbits: - description: + description: - Set async line stop bits - I(1) - One stop bit - I(1.5) - One and one-half stop bits @@ -296,12 +295,12 @@ elements: dict suboptions: all: - description: + description: - All protocols are allowed - Not used if I(name) is configured at I(preferred) type: bool name: - description: + description: - Type of transport to configure - I(input) - Configure incomming connections - I(output) - Configure outgoing connections @@ -344,6 +343,7 @@ platform specific CLI commands which will be returned in the I(rendered) key within the result. For state I(rendered) active connection to remote host is not required. + - The state I(overridden) modify/add the lines defined, deleted all other lines. - The state I(replaced) will only override the configuration part of the defined lines. - The state I(gathered) will fetch the running configuration from device and transform it into structured data in the format as per the resource module argspec and @@ -351,9 +351,10 @@ - The state I(parsed) reads the configuration from C(running_config) option and transforms it into JSON format as per the resource module parameters and the value is returned in the I(parsed) key within the result. The value of C(running_config) - option should be the same format as the output of command I(show running-config - | sec ^line) executed on device. For state I(parsed) active connection to + option should be the same format as the output of command I(show running-config + | sec ^line) executed on device. For state I(parsed) active connection to remote host is not required. + - The state I(deleted), deletes only the specified lines, or all if not specified. type: str choices: - merged @@ -833,12 +834,11 @@ """ from ansible.module_utils.basic import AnsibleModule + from ansible_collections.cisco.ios.plugins.module_utils.network.ios.argspec.line.line import ( LineArgs, ) -from ansible_collections.cisco.ios.plugins.module_utils.network.ios.config.line.line import ( - Line, -) +from ansible_collections.cisco.ios.plugins.module_utils.network.ios.config.line.line import Line def main(): diff --git a/tests/integration/targets/ios_line/tasks/main.yaml b/tests/integration/targets/ios_line/tasks/main.yaml index a38b1212b..ba7233b9e 100644 --- a/tests/integration/targets/ios_line/tasks/main.yaml +++ b/tests/integration/targets/ios_line/tasks/main.yaml @@ -1,5 +1,5 @@ --- -- name: Main task for acls +- name: Main task for lines ansible.builtin.include_tasks: cli.yaml tags: - network_cli diff --git a/tests/integration/targets/ios_line/tests/cli/_populate_config.yaml b/tests/integration/targets/ios_line/tests/cli/_populate_config.yaml index e46dbc881..624dd12c0 100644 --- a/tests/integration/targets/ios_line/tests/cli/_populate_config.yaml +++ b/tests/integration/targets/ios_line/tests/cli/_populate_config.yaml @@ -1,20 +1,8 @@ --- - name: Populate configuration vars: - lines: | - line con 0 - session-timeout 15 - login authentication limited - escape-character 3 - stopbits 1 - line aux 0 - stopbits 1 - line vty 0 4 - session-timeout 15 - exec-timeout 60 0 - password 7 02050D480809 - login authentication remote - logging synchronous - transport input ssh telnet + lines: "line con 0\n session-timeout 15\n login authentication limited\n escape-character 3\n stopbits 1\n + line aux 0\n stopbits 1\n + line vty 0 4\n session-timeout 15\n exec-timeout 60 0\n password 7 02050D480809\n login authentication remote\n logging synchronous\n transport input ssh telnet" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/ios_line/tests/cli/_populate_config_replaced.yaml b/tests/integration/targets/ios_line/tests/cli/_populate_config_replaced.yaml index 77a1bd3f0..d15201c73 100644 --- a/tests/integration/targets/ios_line/tests/cli/_populate_config_replaced.yaml +++ b/tests/integration/targets/ios_line/tests/cli/_populate_config_replaced.yaml @@ -1,24 +1,9 @@ --- - name: Populate configuration vars: - lines: | - line con 0 - session-timeout 15 - login authentication limited - escape-character 3 - stopbits 1 - line aux 0 - stopbits 1 - line aux 0 - no exec - transport input ssh - stopbits 1 - line vty 0 4 - session-timeout 15 - exec-timeout 60 0 - password 7 02050D480809 - login authentication remote - logging synchronous - transport input ssh telnet + lines: + "line con 0\n session-timeout 15\n login authentication limited\n escape-character 3\n stopbits 1\n + line aux 0\n stopbits 1\n no exec\n transport input ssh\n stopbits 1\n + line vty 0 4\n session-timeout 15\n exec-timeout 60 0\n password 7 02050D480809\n login authentication remote\n logging synchronous\n transport input ssh telnet" ansible.netcommon.cli_config: config: "{{ lines }}" diff --git a/tests/integration/targets/ios_line/tests/cli/deleted.yaml b/tests/integration/targets/ios_line/tests/cli/deleted.yaml index b0a526609..dc2dabb85 100644 --- a/tests/integration/targets/ios_line/tests/cli/deleted.yaml +++ b/tests/integration/targets/ios_line/tests/cli/deleted.yaml @@ -18,7 +18,7 @@ - ansible.builtin.assert: that: - - result.commands|length == 4 + - result.commands|length == 5 - result.changed == true - result.commands|symmetric_difference(deleted.commands) == [] @@ -41,11 +41,11 @@ config: lines: - name: "vty 0 4" - state: deleted + state: deleted - ansible.builtin.assert: that: - - result.commands|length == 4 + - result.commands|length == 7 - result.changed == true - result.commands|symmetric_difference(deleted_line.commands) == [] @@ -69,7 +69,7 @@ - ansible.builtin.assert: that: - - result.commands|length == 15 + - result.commands|length == 12 - result.changed == true - result.commands|symmetric_difference(deleted_all.commands) == [] diff --git a/tests/integration/targets/ios_line/tests/cli/empty_config.yaml b/tests/integration/targets/ios_line/tests/cli/empty_config.yaml index a2cd618c9..ba00d6353 100644 --- a/tests/integration/targets/ios_line/tests/cli/empty_config.yaml +++ b/tests/integration/targets/ios_line/tests/cli/empty_config.yaml @@ -39,9 +39,9 @@ register: result ignore_errors: true cisco.ios.ios_line: - config: + running_config: state: parsed - ansible.builtin.assert: that: - - result.msg == 'value of config parameter must not be empty for state parsed' + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/tests/integration/targets/ios_line/tests/cli/gathered.yaml b/tests/integration/targets/ios_line/tests/cli/gathered.yaml index 83fdb86c1..04507df9d 100644 --- a/tests/integration/targets/ios_line/tests/cli/gathered.yaml +++ b/tests/integration/targets/ios_line/tests/cli/gathered.yaml @@ -15,7 +15,7 @@ - ansible.builtin.assert: that: - - gathered['config'] | symmetric_difference(result.gathered) == [] + - gathered['config'] == result.gathered - result['changed'] == false always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/ios_line/tests/cli/merged.yaml b/tests/integration/targets/ios_line/tests/cli/merged.yaml index ad0442235..309576844 100644 --- a/tests/integration/targets/ios_line/tests/cli/merged.yaml +++ b/tests/integration/targets/ios_line/tests/cli/merged.yaml @@ -8,7 +8,7 @@ - name: Merge initial configuration with device configuration cisco.ios.ios_line: config: - line: + lines: - name: "con 0" escape_character: value: "3" @@ -26,7 +26,7 @@ register: result cisco.ios.ios_line: &id001 config: - line: + lines: - name: "con 0" session: timeout: "5" @@ -68,7 +68,7 @@ - ansible.builtin.assert: that: - - result.commands|length == 17 + - result.commands|length == 16 - result.changed == true - result.commands|symmetric_difference(merged.commands) == [] diff --git a/tests/integration/targets/ios_line/tests/cli/overridden.yaml b/tests/integration/targets/ios_line/tests/cli/overridden.yaml index d2a182396..8e2b69361 100644 --- a/tests/integration/targets/ios_line/tests/cli/overridden.yaml +++ b/tests/integration/targets/ios_line/tests/cli/overridden.yaml @@ -11,7 +11,7 @@ register: result cisco.ios.ios_line: &id001 config: - line: + lines: - name: "con 0" exec: timeout: "60" @@ -66,13 +66,13 @@ - ansible.builtin.assert: that: - - result.commands|length == 20 + - result.commands|length == 21 - result.changed == true - result.commands|symmetric_difference(overridden.commands) == [] - name: Override device configuration of all interfaces with provided configuration (idempotent) register: result - cisco.ios.ios_acls: *id001 + cisco.ios.ios_line: *id001 - name: Assert that task was idempotent ansible.builtin.assert: that: diff --git a/tests/integration/targets/ios_line/tests/cli/parsed.yaml b/tests/integration/targets/ios_line/tests/cli/parsed.yaml index 70b4a7902..88c82a8ef 100644 --- a/tests/integration/targets/ios_line/tests/cli/parsed.yaml +++ b/tests/integration/targets/ios_line/tests/cli/parsed.yaml @@ -9,7 +9,12 @@ running_config: "{{ lookup('file', '_parsed.cfg') }}" state: parsed +- ansible.builtin.debug: + var: parsed['config'] +- ansible.builtin.debug: + var: result.parsed + - ansible.builtin.assert: that: - result.changed == false - - parsed['config']|symmetric_difference(result.parsed) == [] + - parsed['config'] == result.parsed diff --git a/tests/integration/targets/ios_line/tests/cli/rendered.yaml b/tests/integration/targets/ios_line/tests/cli/rendered.yaml index f7dc44dff..2c2221b8d 100644 --- a/tests/integration/targets/ios_line/tests/cli/rendered.yaml +++ b/tests/integration/targets/ios_line/tests/cli/rendered.yaml @@ -7,12 +7,13 @@ register: result cisco.ios.ios_line: config: - line: + lines: - name: "con 0" - stopbits: 1 - escape_character: 3 + stopbits: "1" + escape_character: + value: "3" - name: "aux 0" - stopbits: 1 + stopbits: "1" state: rendered - ansible.builtin.assert: diff --git a/tests/integration/targets/ios_line/tests/cli/replaced.yaml b/tests/integration/targets/ios_line/tests/cli/replaced.yaml index 4d0c18fb8..e9f03f62c 100644 --- a/tests/integration/targets/ios_line/tests/cli/replaced.yaml +++ b/tests/integration/targets/ios_line/tests/cli/replaced.yaml @@ -11,7 +11,7 @@ register: result cisco.ios.ios_line: &id001 config: - line: + lines: - name: "con 0" exec: timeout: "60" @@ -49,13 +49,13 @@ - ansible.builtin.assert: that: - - result.commands|length == 20 + - result.commands|length == 14 - result.changed == true - result.commands|symmetric_difference(replaced.commands) == [] - name: Replaced device configuration of all lines listed with provided configuration (idempotent) register: result - cisco.ios.ios_acls: *id001 + cisco.ios.ios_line: *id001 - name: Assert that task was idempotent ansible.builtin.assert: that: diff --git a/tests/integration/targets/ios_line/vars/main.yml b/tests/integration/targets/ios_line/vars/main.yml index b07c1eee3..4e9e3e984 100644 --- a/tests/integration/targets/ios_line/vars/main.yml +++ b/tests/integration/targets/ios_line/vars/main.yml @@ -2,114 +2,83 @@ deleted: commands: - "line con 0" + - "escape-character DEFAULT" + - "login authentication default" + - "no stopbits 1" - "no session-timeout 15" - - "no exec-timeout 60 0" - - "no authorization commands 1 console" - - "no authorization commands 15 console" - - "no authorization exec console" - - "no login authentication console" - - "no escape-character 3" - - "no line vty 5 15" deleted_line: commands: - "line vty 0 4" - - "no session-timeout 15" - - "no exec-timeout 60 0" + - "exec-timeout 10 0" + - "transport input ssh" + - "login authentication default" - "no logging synchronous" - - "default transport preferred" - - "default transport input" - - "default transport output" - - "no escape-character 3" + - "no password 7 ********" + - "no session-timeout 15" deleted_all: commands: - "line con 0" + - "escape-character DEFAULT" + - "login authentication default" - "no session-timeout 15" - - "no exec-timeout 60 0" - - "no authorization commands 1 console" - - "no authorization commands 15 console" - - "no authorization exec console" - - "no login authentication console" - - "no escape-character 3" - - "no line vty 5 15" + - "no stopbits 1" - "line vty 0 4" - - "no session-timeout 15" - - "no exec-timeout 60 0" + - "exec-timeout 10 0" + - "transport input ssh" + - "login authentication default" + - "no password 7 ********" - "no logging synchronous" - - "default transport preferred" - - "default transport input" - - "default transport output" - - "no escape-character 3" + - "no session-timeout 15" gathered: config: - line: + lines: - name: "con 0" - authorization: - exec: "console" - commands: - - level: 1 - command: console - - level: 15 - command: console - login: "console" - session: - timeout: "15" - exec: - timeout: "60" escape_character: value: "3" - stopbits: 1 - - name: "vty 0 4" - authorization: - exec: "default" - login: "default" + login: "limited" + motd: true session: - timeout: "15" - exec: - timeout: "60" - escape_character: - value: "3" + timeout: 15 + stopbits: "1" + - name: "aux 0" + login: "default" + motd: true transport: - - name: preferred - none: true - name: input ssh: true - - name: output - ssh: true - - name: "vty 5 15" - authorization: - exec: "default" - login: "default" - session: - timeout: "15" + - name: "vty 0 4" exec: - timeout: "60" - escape_character: - value: "3" + timeout: 60 + logging: + enable: true + login: "remote" + motd: true + password: + hash: 7 + value: "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER" + session: + timeout: 15 transport: - - name: preferred - none: true - name: input ssh: true - - name: output - ssh: true + telnet: true merged: commands: - "line con 0" - - "exec-timeout 60 0" - "authorization exec console" + - "exec-timeout 60 0" - "line vty 0 4" - - "session timeout 15" - "exec-timeout 60 0" - - "transport preferred none" - - "transport input ssh" - "transport output ssh" + - "transport preferred none" + - "session-timeout 15" - "line vty 5 15" + - "exec-timeout 60 0" - "escape-character 3" + - "session-timeout 15" - "stopbits 1" - - "session timeout 15" - - "exec-timeout 60 0" - "transport preferred none" - "transport input ssh" - "transport output ssh" @@ -117,22 +86,23 @@ merged: overridden: commands: - "line con 0" - - "exec-timeout 60 0" + - "authorization exec console" - "authorization commands 1 console" - "authorization commands 15 console" - - "authorization exec console" + - "exec-timeout 60 0" - "login authentication console" - "line vty 0 4" - - "escape-character 3" - - "login authentication default" - - "transport preferred none" - "transport input ssh" - "transport output ssh" - - "no password 7 02050D480809" + - "transport preferred none" + - "escape-character 3" + - "login authentication default" + - "no logging synchronous" + - "no password 7 ********" - "line vty 5 15" - - "session-timeout 15" - "exec-timeout 60 0" - "escape-character 3" + - "session-timeout 15" - "transport preferred none" - "transport input ssh" - "transport output ssh" @@ -140,10 +110,10 @@ overridden: replaced: commands: - "line con 0" - - "exec-timeout 60 0" + - "authorization exec console" - "authorization commands 1 console" - "authorization commands 15 console" - - "authorization exec console" + - "exec-timeout 60 0" - "login authentication console" - "line vty 0 4" - "escape-character 3" @@ -151,36 +121,45 @@ replaced: - "transport preferred none" - "transport input ssh" - "transport output ssh" - - "no password 7 02050D480809" + - "no password 7 ********" + - "no logging synchronous" parsed: config: - line: + lines: - name: "con 0" authorization: + arap: "default" exec: "console" commands: - level: 1 command: console - level: 15 command: console + reverse_access: "default" login: "console" + motd: true session: - timeout: "15" + timeout: 15 exec: - timeout: "60" + timeout: 60 escape_character: value: "3" - stopbits: 1 + stopbits: "1" + - name: "aux 0" + motd: true + login: "default" + stopbits: "1" - name: "vty 0 4" - authorization: - exec: "default" + motd: true login: "default" + logging: + enable: true length: 0 session: - timeout: "15" + timeout: 15 exec: - timeout: "60" + timeout: 60 escape_character: value: "3" transport: @@ -191,13 +170,12 @@ parsed: - name: output ssh: true - name: "vty 5 15" - authorization: - exec: "default" + motd: true login: "default" session: - timeout: "15" + timeout: 15 exec: - timeout: "60" + timeout: 60 escape_character: value: "3" transport: @@ -214,4 +192,5 @@ rendered: - "escape-character 3" - "stopbits 1" - "line aux 0" + - "transport input ssh" - "stopbits 1" diff --git a/tests/unit/modules/network/ios/test_ios_line.py b/tests/unit/modules/network/ios/test_ios_line.py index 6cb2f0c58..6152839db 100644 --- a/tests/unit/modules/network/ios/test_ios_line.py +++ b/tests/unit/modules/network/ios/test_ios_line.py @@ -854,6 +854,9 @@ def test_ios_line_deleted(self): login authentication CON escape-character 3 stopbits 1 + line aux 0 + no exec + transport input ssh line vty 0 4 session-timeout 5 exec-timeout 60 0 @@ -887,7 +890,7 @@ def test_ios_line_deleted(self): "exec-timeout 10 0", "no logging synchronous", "default transport preferred", - "default transport input", + "transport input ssh", "default transport output", "escape-character DEFAULT", "no line vty 5 15",