Skip to content

Commit 270e8f5

Browse files
authored
Inventory: Add follow_redirects option (#323)
1 parent 602e0ec commit 270e8f5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

plugins/inventory/nb_inventory.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
- Allows connection when SSL certificates are not valid. Set to C(false) when certificates are not trusted.
3636
default: True
3737
type: boolean
38+
follow_redirects:
39+
description:
40+
- Determine how redirects are followed.
41+
- By default, I(follow_redirects) is set to uses urllib2 default behavior.
42+
default: urllib2
43+
choices: ['urllib2', 'all', 'yes', 'safe', 'none']
3844
config_context:
3945
description:
4046
- If True, it adds config_context in host vars.
@@ -264,6 +270,7 @@ def _fetch_information(self, url):
264270
headers=self.headers,
265271
timeout=self.timeout,
266272
validate_certs=self.validate_certs,
273+
follow_redirects=self.follow_redirects,
267274
)
268275
except urllib_error.HTTPError as e:
269276
"""This will return the response body when we encounter an error.
@@ -1357,6 +1364,7 @@ def parse(self, inventory, loader, path, cache=True):
13571364
self.timeout = self.get_option("timeout")
13581365
self.max_uri_length = self.get_option("max_uri_length")
13591366
self.validate_certs = self.get_option("validate_certs")
1367+
self.follow_redirects = self.get_option("follow_redirects")
13601368
self.config_context = self.get_option("config_context")
13611369
self.flatten_config_context = self.get_option("flatten_config_context")
13621370
self.flatten_local_context_data = self.get_option("flatten_local_context_data")

0 commit comments

Comments
 (0)