@@ -1,7 +1,6 @@
|
||||
[defaults]
|
||||
#inventory = /home/user06/hosts
|
||||
inventory = ./ansible_inv_main.py
|
||||
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S on {host}
|
||||
private_key_file = /home/jonnybravo/.ssh/ansible-test
|
||||
gathering = smart
|
||||
fact_caching = yaml
|
||||
|
||||
@@ -44,7 +44,11 @@ def scan_csv(csvfile=str, colm="hostname"):
|
||||
with open(csvfile) as csv_file:
|
||||
csv_reader = csv.DictReader(csv_file, delimiter=",")
|
||||
for count, row in enumerate(csv_reader, 1):
|
||||
hostlist.append(row[colm])
|
||||
hostname = row[colm]
|
||||
if port_open(address=hostname):
|
||||
hostlist.append(hostname)
|
||||
else:
|
||||
print(f"INFO: Host {hostname} not reachable.", file=sys.stderr)
|
||||
else:
|
||||
raise FileNotFoundError(
|
||||
errno.ENOENT, os.strerror(errno.ENOENT), csvfile)
|
||||
|
||||
Reference in New Issue
Block a user