added informations for templating
This commit is contained in:
		
					parent
					
						
							
								53ca7e7aca
							
						
					
				
			
			
				commit
				
					
						2b22e5de24
					
				
			
		
					 1 changed files with 34 additions and 0 deletions
				
			
		| 
						 | 
					@ -153,6 +153,40 @@ implement this scenario with a gateway host and sudo:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
For more details consult sudoers(5)
 | 
					For more details consult sudoers(5)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TEMPLATING
 | 
				
			||||||
 | 
					----------
 | 
				
			||||||
 | 
					* create directory templates/ in your type (convention)
 | 
				
			||||||
 | 
					* create the template as an executable file like templates/basic.conf.sh, it will output text using shell variables for the values
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					# in the template, use cat << eof (here document) to output the text
 | 
				
			||||||
 | 
					# and use standard shell variables in the template
 | 
				
			||||||
 | 
					# output everything in the template script to stdout
 | 
				
			||||||
 | 
					cat << EOF
 | 
				
			||||||
 | 
					server {
 | 
				
			||||||
 | 
					  listen                          80;
 | 
				
			||||||
 | 
					  server_name                     $SERVERNAME;
 | 
				
			||||||
 | 
					  root                            $ROOT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  access_log /var/log/nginx/$SERVERNAME_access.log
 | 
				
			||||||
 | 
					  error_log /var/log/nginx/$SERVERNAME_error.log
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* in the manifest, export the relevant variables and add the following lines in your manifest:
 | 
				
			||||||
 | 
					--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					# export variables needed for the template
 | 
				
			||||||
 | 
					  export SERVERNAME='test"
 | 
				
			||||||
 | 
					  export ROOT='/var/www/test'
 | 
				
			||||||
 | 
					# render the template
 | 
				
			||||||
 | 
					  mkdir -p "$__object/files"
 | 
				
			||||||
 | 
					  "$__type/templates/collectd.conf" > "$__object/files/collectd.conf"
 | 
				
			||||||
 | 
					# send the rendered template 
 | 
				
			||||||
 | 
					  __file /etc/collectd.conf  --state present   --source "$__object/files/collectd.conf"
 | 
				
			||||||
 | 
					--------------------------------------------------------------------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SEE ALSO
 | 
					SEE ALSO
 | 
				
			||||||
--------
 | 
					--------
 | 
				
			||||||
- cdist(1)
 | 
					- cdist(1)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue