Debian Codegraph @

docs/dev/logs/2010-11-09

raw
1 Rethinking ideas of last talk.
2
3 What if types are formal / have formal arguments?
4 What if cdist can do all the parsing stuff and the real
5 functionality comes out of the library (similar to cfengine)?
6
7 What if the library is integral part of cdist?
8
9
10 conf/lib/$name/
11 attributes/
12 a
13 b
14 c
15
16
17 --------------------------------------------------------------------------------
18 I'm not sure whether this design is in fact helpful.
19 But it's clearly necessary to have a directory per type, so a type can
20 have helpers.
21
22
23 conf/lib/$name/
24 init?
25
26
27 Prepare some very minimal (non functional) framework for library integration?
28 Like parsing for command line arguments?
29
30 --------------------------------------------------------------------------------
31 Real configurations versus types:
32
33 Types are reusable code: For instance etc_resolv.
34
35 Configurations are types used and configured.
36
37
38 --------------------------------------------------------------------------------
39
40 Style
41
42 __type <id> --option1 <arg1>
43
44 <id> = everything your filesystem permits, but may not start with a period (".").
45 If <id> == ., it setups the standard attributes.
46
47 seems to be quite good usable. cdist can easily -----parse--- this.
48
49 Nope. We don't parse. We let the shell execute.
50
51 So whatever is __type will get executed.
52
53 __type must probably be part of some cdist specific path.
54
55 Which again could be
56
57 conf/lib/$name
58
59 Which could result in the directory
60
61 conf/lib/.$name for helpers
62
63 That style could include a mandority --help, --args arguments
64 and would thus be independent of the language used (can, but does
65 not must be shell).
66
67 How to solve standard configurations that way?
68
69 EASY AS WELL!
70
71 __type <either option or magic> --option1 <arg1>
72
73 for instance
74
75 __type . --option1 <arg1>
76
77
78 --------------------------------------------------------------------------------
79 Type paths
80 At least (at maximum)? 2:
81 user + system
82
83 Easy to do.
84
85 --------------------------------------------------------------------------------
86 Types: Name types types or name types modules?
87
88 --------------------------------------------------------------------------------
89
90 Where to place/start the configuration?
91
92 wherever it is: name it configuration!
93
94
95 --------------------------------------------------------------------------------
96 cdist installation / paths:
97
98 /etc/cdist/ # CDISTBASEDIR
99 config/ # CDISTCONFIGDIR
100 types/ # CDISTUSERTYPEDIR
101
102 $prefix/lib/cdist/types/ # CDISTSYSTYPEDIR
103
104
105 cdist environment:
106 $__loaded_from # path where $type has been loaded from
107 PATH=$CDISTUSERTYPEDIR:$CDISTSYSTYPEDIR:$PATH
108
109 --------------------------------------------------------------------------------
110 Recommendation (not a must):
111 Put helpers for types into the typedir/.$typename
112
113 All types should be prefixed by "__" to prevent clashes with the system
114 binaries.
115 --------------------------------------------------------------------------------
116 Type commands (__bla) could get generated by cdist and cdist could use that
117 to generate the actual cconfig part.
118
119 This leads up to the next section
120
121 --------------------------------------------------------------------------------
122 How to write my own type named "coffee":
123
124 Create the directory /etc/cdist/types/coffee/
125 Create the file /etc/cdist/types/coffee/README containing a description of the type.
126 If your type supports attributes, create the directory /etc/cdist/types/coffee/attributes.
127 For each attribute, create the file
128 /etc/cdist/types/coffee/attributes/$attribute_name which contains
129
130 a short description on the first line
131 then a blank line
132 then a long description (probably over several lines)
133
134 If you think your type may be useful for others, submit it for inclusion
135 into cdist at cdist -- at -- l.schottelius.org.
136
137 Create /etc/cdist/types/coffee/init which reads $configinput
138 (either via cconfig or via environment) and outputs a block of
139 shell code suitable for running on the client.
140
141
142 --------------------------------------------------------------------------------
143
144 cdist exec steps:
145
146 - check for valid types, abort if user (re-)defined system types
147 - generate __type binaries (aliases?), which contains cdist logic
148 to analyse types and check for correct arguments
149 - execute /etc/cdist/config/init (MAIN CONFIG) which in turn
150 calls __type binaries
151 - __type binaries (which are all the same, multicall!) generate
152 cconfig
153 - Run real type/init binaries with respective cconfig dir as path,
154 which must generate shellcode to be executed.
155 - Create the temporary shellscript containing all the code and execute
156 it on the client.
157
158 --------------------------------------------------------------------------------
159 Support metaargs like --depends?
160 If so, they need to be forbidden for types.
161 --------------------------------------------------------------------------------
162 Shell code generator:
163
164 - use subshells for each shellcodeblock
165 - create one main function (to ensure transfer is complete)
166
167 Example:
168
169 cdist_apply_$hostname()
170 {
171
172 # repeat this block for every type/id defined
173 echo "Executing block from $type_$id ..."
174 (
175 code
176 )
177
178 }
179
180 cdist_apply_$hostname