mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-06 00:14:02 -07:00
parent
f12c6e0946
commit
72bdf7aa7e
6 changed files with 41 additions and 41 deletions
|
@ -27,8 +27,7 @@ EXAMPLES = r'''
|
|||
import os
|
||||
|
||||
from ansible.errors import AnsibleError, AnsibleParserError
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_bytes, to_text, to_native
|
||||
from ansible.module_utils._text import to_bytes, to_native
|
||||
from ansible.parsing.utils.addresses import parse_address
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
|
||||
|
@ -40,9 +39,9 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
def verify_file(self, host_list):
|
||||
|
||||
valid = False
|
||||
b_path = to_bytes(host_list)
|
||||
b_path = to_bytes(host_list, errors='surrogate_or_strict')
|
||||
if not os.path.exists(b_path) and ',' in host_list:
|
||||
valid = True
|
||||
valid = True
|
||||
return valid
|
||||
|
||||
def parse(self, inventory, loader, host_list, cache=True):
|
||||
|
@ -64,4 +63,4 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
if host not in self.inventory.hosts:
|
||||
self.inventory.add_host(host, group='ungrouped', port=port)
|
||||
except Exception as e:
|
||||
raise AnsibleParserError("Invalid data from string, could not parse: %s" % str(e))
|
||||
raise AnsibleParserError("Invalid data from string, could not parse: %s" % to_native(e))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue