Skip to content

Commit

Permalink
Allow simple inventory files to use ~ in paths (#408)
Browse files Browse the repository at this point in the history
  • Loading branch information
ktbyers authored and dbarrosop committed Jun 27, 2019
1 parent f4a4925 commit 929fcde
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nornir/plugins/inventory/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ def __init__(
) -> None:
if hosts is None:
yml = ruamel.yaml.YAML(typ="safe")
with open(host_file, "r") as f:
with open(os.path.expanduser(host_file), "r") as f:
hosts = yml.load(f)

if groups is None:
groups = {}
if group_file:
group_file = os.path.expanduser(group_file)
if os.path.exists(group_file):
with open(group_file, "r") as f:
groups = yml.load(f) or {}
Expand All @@ -44,6 +45,7 @@ def __init__(
if defaults is None:
defaults = {}
if defaults_file:
defaults_file = os.path.expanduser(defaults_file)
if os.path.exists(defaults_file):
with open(defaults_file, "r") as f:
defaults = yml.load(f) or {}
Expand Down

0 comments on commit 929fcde

Please sign in to comment.