summaryrefslogtreecommitdiff
path: root/update.cf
blob: 127e6258c25973906cb38abe3de3d6eab35097d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
body common control
{
    any::
        bundlesequence => {
            main,
        };
        inputs => {};
}

bundle agent main
{
    vars:
        any::
            "input_name_patterns" slist => {
                ".*\.cf",
                ".*\.cftpl",
                ".*\.dat",
                ".*\.txt",
                ".*\.cfg",
                ".*\.conf",
                ".*\.json",
                ".*\.local",
                ".*\.mustache",
                ".*\.pl",
                ".*\.py",
                ".*\.rb",
                ".*\.sh",
                ".*\.yaml",
            };
    files:
        !am_policy_hub::
            "$(sys.inputdir)/cf_promises_validated"
                copy_from => secure_cp("$(sys.masterdir)/cf_promises_validated"),
                action => immediate,
                classes => if_repaired("validated_updates_ready");
            "$(sys.workdir)/modules"
                copy_from => secure_cp("modules"),
                depth_search => recurse("inf"),
                perms => m("755"),
                action => immediate,
                file_select => exclude_vcs_files;
        am_policy_hub::
            "$(sys.masterdir)/."
                perms => m(700),
                depth_search => recurse_basedir("inf"),
                action => immediate;
        am_policy_hub|validated_updates_ready::
            "$(sys.inputdir)"
                copy_from => secure_cp("$(sys.masterdir)"),
                depth_search => recurse("inf"),
                file_select  => input_files,
                action => immediate,
                classes => results("bundle", "update_inputs");
        update_inputs_not_kept::
           "$(sys.inputdir)/cf_promises_validated"
                delete => tidy;
}

body file_select exclude_vcs_files
{
    leaf_name => { "\.git.*" };
    file_result => "!leaf_name";
}

body file_select input_files
{
    leaf_name => { @(main.input_name_patterns) };
    file_result => "leaf_name";
}

body perms m(mode)
{
    mode => "$(mode)";
}

body copy_from secure_cp(from)
{
    any::
        source => "$(from)";
        compare => "digest";
        encrypt => "true";
        verify => "true";
        copy_backup => "false";
        purge       => "true";
    !am_policy_hub::
        servers => { "$(sys.policy_hub)" };
        portnumber => "$(sys.policy_hub_port)";
}

body action immediate
{
    ifelapsed => "0";
}

body classes if_repaired(x)
{
    promise_repaired => { "$(x)" };
}

body depth_search recurse(d)
{
    depth => "$(d)";
    xdev  => "true";
}

body depth_search recurse_basedir(d)
{
    include_basedir => "true";
    depth => "$(d)";
    exclude_dirs => { "\.svn", "\.git", "git-core" };
}

body delete tidy
{
    dirlinks => "delete";
    rmdirs   => "true";
}

body classes results(scope, class_prefix)
{
    scope => "$(scope)";

    promise_kept => { "$(class_prefix)_reached",
                      "$(class_prefix)_kept" };
    promise_repaired => { "$(class_prefix)_reached",
                          "$(class_prefix)_repaired" };
    repair_failed => { "$(class_prefix)_reached",
                       "$(class_prefix)_error",
                       "$(class_prefix)_not_kept",
                       "$(class_prefix)_failed" };
    repair_denied => { "$(class_prefix)_reached",
                       "$(class_prefix)_error",
                       "$(class_prefix)_not_kept",
                       "$(class_prefix)_denied" };
    repair_timeout => { "$(class_prefix)_reached",
                        "$(class_prefix)_error",
                        "$(class_prefix)_not_kept",
                        "$(class_prefix)_timeout" };
}