| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  | This document is a brainstorming document, on how to integrate types. | 
					
						
							| 
									
										
										
										
											2011-01-15 14:47:43 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | Proposed/discussed structures: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 1) 2010-11-02 | 
					
						
							|  |  |  |    $basedir/$type/ | 
					
						
							|  |  |  |       properties/ | 
					
						
							|  |  |  |          name/ | 
					
						
							|  |  |  |             required # required | optional | 
					
						
							|  |  |  |          choices  # \n liste | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       meta/ | 
					
						
							|  |  |  |          default (shell script) | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |       types/ | 
					
						
							| 
									
										
										
										
											2011-01-15 14:47:43 +01:00
										 |  |  |          pukman/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 2) 2010-11-09 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | How to write my own type named "coffee": | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Create the directory /etc/cdist/types/coffee/ | 
					
						
							|  |  |  |    Create the file /etc/cdist/types/coffee/README containing a description of the  | 
					
						
							|  |  |  | type. | 
					
						
							|  |  |  |    If your type supports attributes, create the directory /etc/cdist/types/coffee/ | 
					
						
							|  |  |  | attributes. | 
					
						
							|  |  |  |    For each attribute, create the file | 
					
						
							|  |  |  |       /etc/cdist/types/coffee/attributes/$attribute_name which contains | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       a short description on the first line | 
					
						
							|  |  |  |       then a blank line | 
					
						
							|  |  |  |       then a long description (probably over several lines) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    If you think your type may be useful for others, submit it for inclusion | 
					
						
							|  |  |  |    into cdist at cdist -- at -- l.schottelius.org. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    Create /etc/cdist/types/coffee/init which reads $configinput | 
					
						
							|  |  |  |    (either via cconfig or via environment) and outputs a block of | 
					
						
							|  |  |  |    shell code suitable for running on the client. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  | -------------------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  | type layout: | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |    <name>/ | 
					
						
							|  |  |  |       config   # binary that is called to adjust cconfig tree | 
					
						
							|  |  |  |       change   # binary that is called on the remote host? | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  | -------------------------------------------------------------------------------- | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  | cdist view on types: | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  | How types are integrated/run: | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  |    First stage: | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |    - If cdist encounters type in manifest, | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  |      a wrapper script is run, that creates a | 
					
						
							|  |  |  |      new entry in the cconfig database and adds | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  |      attribute values. This defines a cconfig | 
					
						
							|  |  |  |      tree, that may look as follows: | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  |        | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |       <hostname>/<type>/<id>/<parameters>: | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       myhost/__file/cdist_bin/source | 
					
						
							|  |  |  |       myhost/__file/cdist_bin/destination | 
					
						
							|  |  |  |       ... | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |    - In this stage, no conflicts may occur, as | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |      no type code has been called (i.e. only | 
					
						
							| 
									
										
										
										
											2011-01-15 18:02:01 +01:00
										 |  |  |      manifests, which map config to hosts is | 
					
						
							|  |  |  |      applied). | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Second stage: | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |    - The "manifest" script of every used type | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  |      (i.e. the manifests created at least one object) | 
					
						
							|  |  |  |      is called, which again is able to call other | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |      types. All created objects may also be modified | 
					
						
							|  |  |  |      by the type. | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |      For instance a "httpd" type may call the | 
					
						
							|  |  |  |      "webroot" type with --path / ...  | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  |      # FIND CASE WHERE SENSEFUL => look through | 
					
						
							|  |  |  |      current puppet config | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    - The newly created objects are merged back into | 
					
						
							|  |  |  |      the existing tree. No conflicts may occur during | 
					
						
							|  |  |  |      the merge, because this would implicit that the | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |      type conflicts with other types. | 
					
						
							| 
									
										
										
										
											2011-01-15 18:21:07 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |      The idea of this that a type may expand another | 
					
						
							|  |  |  |      type with functionality, but may need to adjust | 
					
						
							|  |  |  |      ("overwrite") settings from the original type. | 
					
						
							| 
									
										
										
										
											2011-01-15 18:46:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Third stage: | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |    - Cdist calls the "gencode" binary of the types | 
					
						
							| 
									
										
										
										
											2011-01-15 18:46:44 +01:00
										 |  |  |      for every created object. This binary should create | 
					
						
							|  |  |  |      code to be executed on the target on stdout. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |      If the gencode binary fails, it must print diagnostic | 
					
						
							|  |  |  |      messages on stderr and exit non-zero. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |      A description of what the generated code may/must/should | 
					
						
							|  |  |  |      do can be found at the end of this document. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    - Cdist merges together the generated code | 
					
						
							| 
									
										
										
										
											2011-01-15 18:50:22 +01:00
										 |  |  |      (taking care of DEPENDENCIES (which are not | 
					
						
							|  |  |  |      yet defined (take care, double nested brackets))) | 
					
						
							| 
									
										
										
										
											2011-01-15 18:46:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |    Fourth stage: | 
					
						
							| 
									
										
										
										
											2011-01-15 18:50:22 +01:00
										 |  |  |    - The resulting shell script is transferred | 
					
						
							|  |  |  |      to the target and executed. | 
					
						
							| 
									
										
										
										
											2011-01-15 18:46:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | -------------------------------------------------------------------------------- | 
					
						
							|  |  |  | Scope of code execution on the client | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |    It should be assumed that the clients are pretty dumb | 
					
						
							|  |  |  |    and thus do not have high level tools like python | 
					
						
							|  |  |  |    installed. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-17 22:44:34 +01:00
										 |  |  |    If a type requires specific tools to be present | 
					
						
							|  |  |  |    on the target, there must be another type that | 
					
						
							|  |  |  |    provides this tool and the first type must create | 
					
						
							|  |  |  |    an object of the specific type. | 
					
						
							| 
									
										
										
										
											2011-01-15 18:46:44 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-01-15 18:48:35 +01:00
										 |  |  |    If the generated code fails on the client, it must | 
					
						
							|  |  |  |    print diagnostistic messages on stderr and call | 
					
						
							|  |  |  |    "exit 1", so the configuration is aborted. | 
					
						
							| 
									
										
										
										
											2011-01-15 18:46:44 +01:00
										 |  |  | 
 |