diff --git a/lib/ansible/modules/network/iosxr/iosxr_system.py b/lib/ansible/modules/network/iosxr/iosxr_system.py index e0514a04ef..602d60edd3 100644 --- a/lib/ansible/modules/network/iosxr/iosxr_system.py +++ b/lib/ansible/modules/network/iosxr/iosxr_system.py @@ -252,7 +252,8 @@ class CliConfiguration(ConfigBase): def parse_hostname(self, config): match = re.search(r'^hostname (\S+)', config, re.M) - return match.group(1) + if match: + return match.group(1) def parse_domain_name(self, config): match = re.search(r'^domain name (\S+)', config, re.M) diff --git a/test/integration/targets/iosxr_config/tests/cli/misplaced_sublevel.yaml b/test/integration/targets/iosxr_config/tests/cli/misplaced_sublevel.yaml index 3688cfa455..6faa1e4d82 100644 --- a/test/integration/targets/iosxr_config/tests/cli/misplaced_sublevel.yaml +++ b/test/integration/targets/iosxr_config/tests/cli/misplaced_sublevel.yaml @@ -22,6 +22,6 @@ - assert: that: - - "result.changed == true" + - "result.changed == false" - debug: msg="END cli/misplaced_sublevel.yaml on connection={{ ansible_connection }}" diff --git a/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml b/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml index 0a9e7999bb..7a18ebaa7d 100644 --- a/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml +++ b/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml @@ -22,7 +22,6 @@ - assert: that: - result.changed == true - - result.commands|length == 3 - "'domain name-server 192.0.2.1' in result.commands" - "'domain name-server 192.0.2.2' in result.commands" - "'domain name-server 192.0.2.3' in result.commands"