Skip to content

Commit 71900b5

Browse files
authored
Make setting ansible_network_os optional (#329)
Make setting ansible_network_os optional SUMMARY Make setting ansible_network_os optional Depends-on: ansible/ansible-zuul-jobs#1139 ISSUE TYPE Feature Pull Request COMPONENT NAME httpapi ADDITIONAL INFORMATION Reviewed-by: Ganesh Nalawade <None> Reviewed-by: Sumit Jaiswal <[email protected]> Reviewed-by: Nathaniel Case <[email protected]> Reviewed-by: None <None>
1 parent c0ba21a commit 71900b5

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- Make ansible_network_os as optional param for httpapi connection plugin.

plugins/connection/httpapi.py

+20-9
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,13 @@
142142
- name: ANSIBLE_BECOME_METHOD
143143
vars:
144144
- name: ansible_become_method
145+
platform_type:
146+
description:
147+
- Set type of platform.
148+
env:
149+
- name: ANSIBLE_PLATFORM_TYPE
150+
vars:
151+
- name: ansible_platform_type
145152
"""
146153

147154
from io import BytesIO
@@ -169,10 +176,14 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
169176
)
170177

171178
self._auth = None
172-
173179
if self._network_os:
180+
self.load_platform_plugins(self._network_os)
181+
182+
def load_platform_plugins(self, platform_type=None):
183+
platform_type = platform_type or self.get_option("platform_type")
174184

175-
self.httpapi = httpapi_loader.get(self._network_os, self)
185+
if platform_type:
186+
self.httpapi = httpapi_loader.get(platform_type, self)
176187
if self.httpapi:
177188
self._sub_plugin = {
178189
"type": "httpapi",
@@ -181,25 +192,25 @@ def __init__(self, play_context, new_stdin, *args, **kwargs):
181192
}
182193
self.queue_message(
183194
"vvvv",
184-
"loaded API plugin %s from path %s for network_os %s"
195+
"loaded API plugin %s from path %s for platform type %s"
185196
% (
186197
self.httpapi._load_name,
187198
self.httpapi._original_path,
188-
self._network_os,
199+
platform_type,
189200
),
190201
)
191202
else:
192203
raise AnsibleConnectionFailure(
193-
"unable to load API plugin for network_os %s"
194-
% self._network_os
204+
"unable to load API plugin for platform type %s"
205+
% platform_type
195206
)
196207

197208
else:
198209
raise AnsibleConnectionFailure(
199-
"Unable to automatically determine host network os. Please "
200-
"manually configure ansible_network_os value for this host"
210+
"Unable to automatically determine host platform type. Please "
211+
"manually configure platform_type value for this host"
201212
)
202-
self.queue_message("log", "network_os is set to %s" % self._network_os)
213+
self.queue_message("log", "platform_type is set to %s" % platform_type)
203214

204215
@property
205216
def _url(self):

0 commit comments

Comments
 (0)