forked from ungleich-public/cdist
Support comments in hostfile, skip empty lines.
This commit is contained in:
parent
f40e6659f7
commit
7aa4b2d40a
2 changed files with 10 additions and 2 deletions
|
@ -99,8 +99,15 @@ class Config(object):
|
||||||
import fileinput
|
import fileinput
|
||||||
try:
|
try:
|
||||||
for host in fileinput.input(files=(source)):
|
for host in fileinput.input(files=(source)):
|
||||||
# remove leading and trailing whitespace
|
# remove comment if present
|
||||||
yield host.strip()
|
comment_index = host.find('#')
|
||||||
|
if comment_index >= 0:
|
||||||
|
host = host[:comment_index]
|
||||||
|
# remove leading and trailing whitespaces
|
||||||
|
host = host.strip()
|
||||||
|
# skip empty lines
|
||||||
|
if host:
|
||||||
|
yield host
|
||||||
except (IOError, OSError) as e:
|
except (IOError, OSError) as e:
|
||||||
raise cdist.Error("Error reading hosts from \'{}\'".format(
|
raise cdist.Error("Error reading hosts from \'{}\'".format(
|
||||||
source))
|
source))
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
Changelog
|
Changelog
|
||||||
---------
|
---------
|
||||||
next:
|
next:
|
||||||
|
* Core: Improve hostfile: support comments, skip empty lines (Darko Poljak)
|
||||||
* Documentation: Add Parallelization chapter (Darko Poljak)
|
* Documentation: Add Parallelization chapter (Darko Poljak)
|
||||||
* Core: Add -b, --enable-beta option for enabling beta functionalities (Darko Poljak)
|
* Core: Add -b, --enable-beta option for enabling beta functionalities (Darko Poljak)
|
||||||
* Core: Add -j, --jobs option for parallel execution and add parallel support for global explorers (currently in beta) (Darko Poljak)
|
* Core: Add -j, --jobs option for parallel execution and add parallel support for global explorers (currently in beta) (Darko Poljak)
|
||||||
|
|
Loading…
Reference in a new issue