hostname module - fix TypeError in FileStrategy (#77025) (#77074)

* Use file_get_content() to read the file containing the host name
pull/77140/head
Emmanuel Benoît 3 years ago committed by GitHub
parent 6a7009a84f
commit d60efd9768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- hostname - use ``file_get_content()`` to read the file containing the host name in the ``FileStrategy.get_permanent_hostname()`` method. This prevents a ``TypeError`` from being raised when the strategy is used (https://github.com/ansible/ansible/issues/77025).

@ -257,7 +257,7 @@ class FileStrategy(BaseStrategy):
return '' return ''
try: try:
return get_file_lines(self.FILE) return get_file_content(self.FILE, default='', strip=True)
except Exception as e: except Exception as e:
self.module.fail_json( self.module.fail_json(
msg="failed to read hostname: %s" % to_native(e), msg="failed to read hostname: %s" % to_native(e),

Loading…
Cancel
Save