diff --git a/remote/serial.go b/remote/serial.go index b7742c6..3897893 100644 --- a/remote/serial.go +++ b/remote/serial.go @@ -241,7 +241,7 @@ execLoop: err = cmd.Run() signal.Reset() if err != nil { - term.Errorf("Error copying tempfile: %s\n", err) + term.Errorf("Error copying generated script file to remote host: %s\n", err) r.ErrorHosts = append(r.ErrorHosts, host) r.Codes[host] = ErrCopyFailed continue diff --git a/store/store.go b/store/store.go index bc4a6aa..bf33189 100644 --- a/store/store.go +++ b/store/store.go @@ -154,13 +154,14 @@ func (s *Store) HostList(expr []rune) ([]string, error) { return nil, err } - hostlist := make([]string, 0) + hostlist := make([][]string, 0) for _, token := range tokens { + singleTokenHosts := make([]string, 0) switch token.Type { case tTypeHostRegexp: for _, host := range s.matchHost(token.RegexpFilter) { - maybeAddHost(&hostlist, host, token.Exclude) + maybeAddHost(&singleTokenHosts, host, token.Exclude) } case tTypeHost: @@ -181,7 +182,7 @@ func (s *Store) HostList(expr []rune) ([]string, error) { } } } - maybeAddHost(&hostlist, host, token.Exclude) + maybeAddHost(&singleTokenHosts, host, token.Exclude) } case tTypeGroup: @@ -211,7 +212,7 @@ func (s *Store) HostList(expr []rune) ([]string, error) { continue } } - maybeAddHost(&hostlist, host.FQDN, token.Exclude) + maybeAddHost(&singleTokenHosts, host.FQDN, token.Exclude) } } @@ -261,14 +262,25 @@ func (s *Store) HostList(expr []rune) ([]string, error) { } } - maybeAddHost(&hostlist, host.FQDN, token.Exclude) + maybeAddHost(&singleTokenHosts, host.FQDN, token.Exclude) } } } + if len(singleTokenHosts) > 0 { + hostlist = append(hostlist, singleTokenHosts) + } } - // TODO: fix force sorting: sort inside the group/workgroup processing only - sort.Strings(hostlist) - return hostlist, nil + + results := make([]string, 0) + for _, sthosts := range hostlist { + // sorting withing one expression token only + // the order of tokens themselves should be respected + sort.Strings(sthosts) + for _, host := range sthosts { + results = append(results, host) + } + } + return results, nil } // apply is called after the raw data is loaded and creates relations