passed to `/bin/sh`.
When files with the same path are present in multiple groups of a host, an
-explicit _group order_ must be configured to resolve the conflict. Conflicts
-do not apply to packages and services which are simply merged from all groups.
-Commands are appended so that the same command can be executed multiple times.
+explicit _group priority_ must be configured to resolve the conflict.
+Conflicts do not apply to packages and services which are simply merged from
+all groups. Commands are appended so that the same command can be executed
+multiple times.
To sync the configuration to a remote host, the local `safcm` binary connects
to it via `ssh`. It then copies a _remote helper_ binary to `/tmp` on the
SshConfig string `yaml:"-"` // set via command line
DetectGroups []string `yaml:"detect_groups"`
- GroupOrder []string `yaml:"group_order"`
+ GroupPriority []string `yaml:"group_priority"`
}
func LoadConfig() (*Config, error) {
}
// Sanity check for global configuration
- for _, x := range cfg.GroupOrder {
- const errPrefix = "config.yaml: group_order:"
+ for _, x := range cfg.GroupPriority {
+ const errPrefix = "config.yaml: group_priority:"
if x == GroupAll {
continue
{
"../testdata/project",
&Config{
- GroupOrder: []string{
+ GroupPriority: []string{
"detected_linux",
"detected_freebsd",
},
{
"../testdata/project",
&Config{
- GroupOrder: []string{
+ GroupPriority: []string{
"detected_freebsd",
"does-not-exist",
},
},
hosts,
nil,
- fmt.Errorf("config.yaml: group_order: group \"does-not-exist\" does not exist"),
+ fmt.Errorf("config.yaml: group_priority: group \"does-not-exist\" does not exist"),
},
{
"../testdata/project",
&Config{
- GroupOrder: []string{
+ GroupPriority: []string{
"detected_freebsd",
"special:group",
},
},
hosts,
nil,
- fmt.Errorf("config.yaml: group_order: invalid group name \"special:group\""),
+ fmt.Errorf("config.yaml: group_priority: invalid group name \"special:group\""),
},
{
"../testdata/project",
&Config{
- GroupOrder: []string{
+ GroupPriority: []string{
"detected_freebsd",
"group:remove",
},
},
hosts,
nil,
- fmt.Errorf("config.yaml: group_order: invalid group name \"group:remove\""),
+ fmt.Errorf("config.yaml: group_priority: invalid group name \"group:remove\""),
},
{
[]string{"-log", "verbose", "no-settings.example.org"},
`<LOG>[info] [no-settings.example.org] remote helper upload in progress
<LOG>[verbose] [no-settings.example.org] host groups: all <DET> <DET> no-settings.example.org
-<LOG>[verbose] [no-settings.example.org] host group priorities (desc. order): no-settings.example.org
+<LOG>[verbose] [no-settings.example.org] host group priorities (desc. priority): no-settings.example.org
<LOG>[info] [no-settings.example.org] no changes
`,
nil,
[]string{"-log", "debug2", "no-settings.example.org"},
`<LOG>[info] [no-settings.example.org] remote helper upload in progress
<LOG>[verbose] [no-settings.example.org] host groups: all <DET> <DET> no-settings.example.org
-<LOG>[verbose] [no-settings.example.org] host group priorities (desc. order): no-settings.example.org
+<LOG>[verbose] [no-settings.example.org] host group priorities (desc. priority): no-settings.example.org
<LOG>[info] [no-settings.example.org] no changes
`,
nil,
return empty, err
}
{
- // Don't leak internal group order which is confusing without
- // knowing the implementation details.
+ // Don't leak internal group priority which is confusing
+ // without knowing the implementation details.
groupsSorted := make([]string, len(groups))
copy(groupsSorted, groups)
sort.Strings(groupsSorted)
b := priorities[j]
return groupPriority[a] < groupPriority[b]
})
- s.logVerbosef("host group priorities (desc. order): %v",
+ s.logVerbosef("host group priorities (desc. priority): %v",
strings.Join(priorities, " "))
}
// Early entries have higher priorities
groupPriority := make(map[string]int)
- for i, x := range s.config.GroupOrder {
+ for i, x := range s.config.GroupPriority {
groupPriority[x] = math.MinInt32 + i + 1
}
// Host itself always has highest priority
}
return fmt.Errorf("groups %s and %s both provide file %q\n"+
- "Use 'group_order' in config.yaml to declare preference",
+ "Use 'group_priority' in config.yaml to declare preference",
group, old.OrigGroup, path)
}
const sep = string(filepath.Separator)
- // Remove invalid paths which can result from group_order overriding
- // paths from another group (e.g. "/foo" as file from one group and
- // "/foo/bar" from another).
+ // Remove invalid paths which can result from group_priority
+ // overriding paths from another group (e.g. "/foo" as file from one
+ // group and "/foo/bar" from another).
var last *safcm.File
for _, x := range paths {
file := files[x]
},
[]string{
"host1.example.org: <nil> 3 host groups: all group group3 host1.example.org remove",
- "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org",
+ "host1.example.org: <nil> 3 host group priorities (desc. priority): host1.example.org",
},
nil,
},
safcm.MsgSyncReq{},
[]string{
"host1.example.org: <nil> 3 host groups: all dns host1.example.org",
- "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org",
+ "host1.example.org: <nil> 3 host group priorities (desc. priority): host1.example.org",
},
- fmt.Errorf("groups dns and all both provide file \"/etc/resolv.conf\"\nUse 'group_order' in config.yaml to declare preference"),
+ fmt.Errorf("groups dns and all both provide file \"/etc/resolv.conf\"\nUse 'group_priority' in config.yaml to declare preference"),
},
{
"conflict: file from detected group",
safcm.MsgSyncReq{},
[]string{
"host2.example.org: <nil> 3 host groups: all detected_other host2.example.org other",
- "host2.example.org: <nil> 3 host group priorities (desc. order): host2.example.org",
+ "host2.example.org: <nil> 3 host group priorities (desc. priority): host2.example.org",
},
- fmt.Errorf("groups other and all both provide file \"/etc/resolv.conf\"\nUse 'group_order' in config.yaml to declare preference"),
+ fmt.Errorf("groups other and all both provide file \"/etc/resolv.conf\"\nUse 'group_priority' in config.yaml to declare preference"),
},
{
safcm.MsgSyncReq{},
[]string{
"host1.example.org: <nil> 3 host groups: all dns host1.example.org",
- "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org",
+ "host1.example.org: <nil> 3 host group priorities (desc. priority): host1.example.org",
},
- fmt.Errorf("groups dns and all both provide file \"/etc\"\nUse 'group_order' in config.yaml to declare preference"),
+ fmt.Errorf("groups dns and all both provide file \"/etc\"\nUse 'group_priority' in config.yaml to declare preference"),
},
{
"conflict: dir from detected group",
safcm.MsgSyncReq{},
[]string{
"host2.example.org: <nil> 3 host groups: all detected_other host2.example.org other",
- "host2.example.org: <nil> 3 host group priorities (desc. order): host2.example.org",
+ "host2.example.org: <nil> 3 host group priorities (desc. priority): host2.example.org",
},
- fmt.Errorf("groups other and all both provide file \"/etc\"\nUse 'group_order' in config.yaml to declare preference"),
+ fmt.Errorf("groups other and all both provide file \"/etc\"\nUse 'group_priority' in config.yaml to declare preference"),
},
{
},
{
- "group_order",
- "project-group_order",
+ "group_priority",
+ "project-group_priority",
"host1.example.org",
nil,
safcm.LogDebug3,
},
[]string{
"host1.example.org: <nil> 3 host groups: all group-a group-b host1.example.org",
- "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org group-a group-b all",
+ "host1.example.org: <nil> 3 host group priorities (desc. priority): host1.example.org group-a group-b all",
`host1.example.org: <nil> 4 files: "/etc": group group-a overwrites triggers from group group-b`,
`host1.example.org: <nil> 4 files: "/etc": group host1.example.org overwrites triggers from group group-a`,
},
},
{
- "group_order (single group)",
- "project-group_order-single",
+ "group_priority (single group)",
+ "project-group_priority-single",
"host1.example.org",
nil,
safcm.LogDebug3,
},
[]string{
"host1.example.org: <nil> 3 host groups: all group-a group-b host1.example.org",
- "host1.example.org: <nil> 3 host group priorities (desc. order): host1.example.org group-a",
+ "host1.example.org: <nil> 3 host group priorities (desc. priority): host1.example.org group-a",
},
nil,
},
+++ /dev/null
-group_order:
- - group-a
--- /dev/null
+group_priority:
+ - group-a
-group_order:
+group_priority:
- group-a
- group-b
- all