def hosts_append(hostsfile='/etc/hosts', ip_addr=None, entries=None):
 host_list = entries.split(',')
 hosts = parse_hosts(hostsfile=hostsfile)
 if (ip_addr in hosts):
  for host in host_list:
   if (host in hosts[ip_addr]):
    host_list.remove(host)
 if (not host_list):
  return 'No additional hosts were added to {0}'.format(hostsfile)
 append_line = '\n{0} {1}'.format(ip_addr, ' '.join(host_list))
 with salt.utils.fopen(hostsfile, 'a') as fp_:
  fp_.write(append_line)
 return 'The following line was added to {0}:{1}'.format(hostsfile, append_line)

def hosts_append ( hostsfile = '/etc/hosts' , ip_addr = None , entries = None ) : host_list = entries . split ( ',' ) hosts = parse_hosts ( hostsfile = hostsfile ) if ( ip_addr in hosts ) : for host in host_list : if ( host in hosts [ ip_addr ] ) : host_list . remove ( host ) if ( not host_list ) : return 'No additional hosts were added to {0}' . format ( hostsfile ) append_line = '\n{0} {1}' . format ( ip_addr , ' ' . join ( host_list ) ) with salt . utils . fopen ( hostsfile , 'a' ) as fp_ : fp_ . write ( append_line ) return 'The following line was added to {0}:{1}' . format ( hostsfile , append_line )
append a single line to the /etc/hosts file .