From 7f2337014811526123c939442ed47d9b4ec9c305 Mon Sep 17 00:00:00 2001 From: "Ganesh B. Nalawade" Date: Wed, 18 Aug 2021 13:48:53 +0530 Subject: [PATCH 1/4] Make setting ansible_network_os optional --- plugins/action/eos.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/action/eos.py b/plugins/action/eos.py index 03d317f09..dddc8695d 100644 --- a/plugins/action/eos.py +++ b/plugins/action/eos.py @@ -25,6 +25,7 @@ import copy from ansible import constants as C +from ansible.module_utils.connection import Connection from ansible_collections.arista.eos.plugins.module_utils.network.eos.eos import ( eos_provider_spec, ) @@ -48,6 +49,9 @@ def run(self, tmp=None, task_vars=None): True if module_name in ["eos_config", "config"] else False ) persistent_connection = self._play_context.connection.split(".")[-1] + conn = Connection(self._connection.socket_path) + conn.load_platfrom_type('arista.eos.eos') + conn.set_options(var_options=task_vars) warnings = [] if persistent_connection in ("network_cli", "httpapi"): From ca658be5f1e23208cdb9450b3145102e87053b69 Mon Sep 17 00:00:00 2001 From: "Ganesh B. Nalawade" Date: Wed, 18 Aug 2021 13:51:37 +0530 Subject: [PATCH 2/4] update method name --- plugins/action/eos.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/action/eos.py b/plugins/action/eos.py index dddc8695d..2b79aa41f 100644 --- a/plugins/action/eos.py +++ b/plugins/action/eos.py @@ -50,7 +50,7 @@ def run(self, tmp=None, task_vars=None): ) persistent_connection = self._play_context.connection.split(".")[-1] conn = Connection(self._connection.socket_path) - conn.load_platfrom_type('arista.eos.eos') + conn.load_platfrom_plugins('arista.eos.eos') conn.set_options(var_options=task_vars) warnings = [] From c29e36b01e8fa3408ee887c3ba9fad71a5581f0b Mon Sep 17 00:00:00 2001 From: "Ganesh B. Nalawade" Date: Wed, 18 Aug 2021 16:08:29 +0530 Subject: [PATCH 3/4] fix method not defined error --- plugins/action/eos.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/action/eos.py b/plugins/action/eos.py index 2b79aa41f..d022067fc 100644 --- a/plugins/action/eos.py +++ b/plugins/action/eos.py @@ -25,6 +25,7 @@ import copy from ansible import constants as C +from ansible.module_utils._text import to_text from ansible.module_utils.connection import Connection from ansible_collections.arista.eos.plugins.module_utils.network.eos.eos import ( eos_provider_spec, @@ -49,9 +50,17 @@ def run(self, tmp=None, task_vars=None): True if module_name in ["eos_config", "config"] else False ) persistent_connection = self._play_context.connection.split(".")[-1] + conn = Connection(self._connection.socket_path) - conn.load_platfrom_plugins('arista.eos.eos') - conn.set_options(var_options=task_vars) + try: + conn.load_platfrom_plugins('arista.eos.eos') + conn.set_options(var_options=task_vars) + except ConnectionError as exc: + if "Method not found" in to_text(exc): + display.vvvv('load_platfrom_plugins not defined') + else: + raise + warnings = [] if persistent_connection in ("network_cli", "httpapi"): From 0f9202cbf66d0c524d65723977936754868d58e2 Mon Sep 17 00:00:00 2001 From: "Ganesh B. Nalawade" Date: Thu, 19 Aug 2021 10:13:13 +0530 Subject: [PATCH 4/4] fix typo --- plugins/action/eos.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/action/eos.py b/plugins/action/eos.py index d022067fc..81320e8ac 100644 --- a/plugins/action/eos.py +++ b/plugins/action/eos.py @@ -26,7 +26,7 @@ from ansible import constants as C from ansible.module_utils._text import to_text -from ansible.module_utils.connection import Connection +from ansible.module_utils.connection import Connection, ConnectionError from ansible_collections.arista.eos.plugins.module_utils.network.eos.eos import ( eos_provider_spec, ) @@ -53,11 +53,11 @@ def run(self, tmp=None, task_vars=None): conn = Connection(self._connection.socket_path) try: - conn.load_platfrom_plugins('arista.eos.eos') + conn.load_platform_plugins('arista.eos.eos') conn.set_options(var_options=task_vars) except ConnectionError as exc: if "Method not found" in to_text(exc): - display.vvvv('load_platfrom_plugins not defined') + display.vvvv('load_platform_plugins not defined') else: raise