Skip to content

Commit 1f3cada

Browse files
committed
Make setting ansible_network_os optional
1 parent 71900b5 commit 1f3cada

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

plugins/connection/httpapi.py

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@
145145
platform_type:
146146
description:
147147
- Set type of platform.
148+
ini:
149+
- section: persistent_connetion
150+
key: platform_type
148151
env:
149152
- name: ANSIBLE_PLATFORM_TYPE
150153
vars:
@@ -177,40 +180,40 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
177180

178181
self._auth = None
179182
if self._network_os:
180-
self.load_platform_plugins(self._network_os)
183+
self.load_platform_plugins(self._network_os)
181184

182185
def load_platform_plugins(self, platform_type=None):
183-
platform_type = platform_type or self.get_option("platform_type")
186+
platform_type = platform_type or self.get_option("platform_type")
184187

185-
if platform_type:
186-
self.httpapi = httpapi_loader.get(platform_type, self)
187-
if self.httpapi:
188-
self._sub_plugin = {
189-
"type": "httpapi",
190-
"name": self.httpapi._load_name,
191-
"obj": self.httpapi,
192-
}
193-
self.queue_message(
194-
"vvvv",
195-
"loaded API plugin %s from path %s for platform type %s"
196-
% (
197-
self.httpapi._load_name,
198-
self.httpapi._original_path,
199-
platform_type,
200-
),
201-
)
202-
else:
203-
raise AnsibleConnectionFailure(
204-
"unable to load API plugin for platform type %s"
205-
% platform_type
206-
)
188+
if platform_type:
189+
self.httpapi = httpapi_loader.get(platform_type, self)
190+
if self.httpapi:
191+
self._sub_plugin = {
192+
"type": "httpapi",
193+
"name": self.httpapi._load_name,
194+
"obj": self.httpapi,
195+
}
196+
self.queue_message(
197+
"vvvv",
198+
"loaded API plugin %s from path %s for platform type %s"
199+
% (
200+
self.httpapi._load_name,
201+
self.httpapi._original_path,
202+
platform_type,
203+
),
204+
)
205+
else:
206+
raise AnsibleConnectionFailure(
207+
"unable to load API plugin for platform type %s"
208+
% platform_type
209+
)
207210

208-
else:
209-
raise AnsibleConnectionFailure(
210-
"Unable to automatically determine host platform type. Please "
211-
"manually configure platform_type value for this host"
212-
)
213-
self.queue_message("log", "platform_type is set to %s" % platform_type)
211+
else:
212+
raise AnsibleConnectionFailure(
213+
"Unable to automatically determine host platform type. Please "
214+
"manually configure platform_type value for this host"
215+
)
216+
self.queue_message("log", "platform_type is set to %s" % platform_type)
214217

215218
@property
216219
def _url(self):
@@ -331,4 +334,4 @@ def transport_test(self, connect_timeout):
331334
request the root URL with no error handling.
332335
"""
333336

334-
open_url(self._url, timeout=connect_timeout)
337+
open_url(self._url, timeout=connect_timeout)

0 commit comments

Comments
 (0)