Project

General

Profile

TemplateWriting » History » Version 12

Justin Sherrill, 02/02/2011 09:31 AM

1 1 Justin Sherrill
h1. Templates
2
3
4
5 4 Justin Sherrill
The following functions and macros can be used within templates.  These are guaranteed to work via the safemode rendering, to ensure a template can do nothing harmful.  With safemode disabled ($$ADD instructions here$$), other macros may work, but are not supported at this time.
6 1 Justin Sherrill
7
8 8 Justin Sherrill
h2. Accessing Templates
9 1 Justin Sherrill
10 10 Justin Sherrill
There are two ways to render a template, based on a single host, or based on a Hostgroup.  The host or hostgroup provides all the details with which to render the template.  
11 1 Justin Sherrill
12 10 Justin Sherrill
13 8 Justin Sherrill
h3. Host-based Rendering
14
15 12 Justin Sherrill
Only a single template of each type may be rendered for a system.  
16 8 Justin Sherrill
17 12 Justin Sherrill
18
To access a template of a certain type simply use this url:
19
20
/unattended/KIND_NAME 
21
22
for example:    /unattended/provision  
23
would render the provisioning template.  The host will be based on the IP Address it is accessed from.  To spoof a template simply access the url in this manner:
24
25
/unattended/provision?spoof=192.168.0.1 
26
27
where 192.168.0.1 is the ip address of the system you want to spoof. This allows you to view a template for a particular system from anywhere.  
28 8 Justin Sherrill
29
30
h3. Hostgroup-based rendering
31 9 Justin Sherrill
32 8 Justin Sherrill
Allows any template to be rendered for any Hostgroup.  When rendering using a hostgroup, @host is actually the hostgroup instead of a defined host. The default values for the hostgroup are used for templated values.  This means if a value is not set in the hostgroup, you may get an error when rendering the template.  To access a template using a Hostgroup to render, simply use this URL:
33
34
/unattended/template/Template Name/Hostgroup Name
35
36
For example, a hostgroup of name Finance, and a template named WebServerKickstart could be rendered using the url:
37
38 11 Justin Sherrill
/unattended/template/WebServerKickstart/Finance
39 1 Justin Sherrill
40 10 Justin Sherrill
h4.  PXE Menus
41
42
Pxe Menus can be deployed to smart proxies from the Config Tempalates.
43 8 Justin Sherrill
44
h2. Writing templates
45
46
47
48
h2. Functions and macros:
49
50 1 Justin Sherrill
|_.Name|_.Description|_.Example|
51
|root_pass  |The root password configured for the system| |
52 7 Justin Sherrill
|ks_console | | |
53 6 Justin Sherrill
|snippets(name)   | Renders the specified snippet | |
54 1 Justin Sherrill
|foreman_url(kind)| Provides the full URL to a host-rendered template of the given kind  | foreman_url("provision") =>  http://HOST/unattended/provision |
55
|@host                |The name of the host| |
56
|@host.name                |The name of the host| |
57
|@host.diskLayout     |The disklayout of the host (could come from the operating system)| |
58
|@host.puppetmaster   |The puppetmaster the host should use | |
59
|@host.architecture   |The arch of the host (i.e. x86_64)| |
60
|@host.operatingsystem|The operating system name| |
61
|@host.operatingsystem.media_url |||
62
|@host.operatingsystem.major |The major version of the OS||
63
|@host.operatingsystem.minor |The minor version of the OS||
64
|@host.operatingsystem.family |The OS Family (I.e. redhat, debian, etc.)||
65
|@host.url_for_boot(:kernel) |||
66
|@host.url_for_boot(:initrd) |||
67
68
69 2 Justin Sherrill
70 8 Justin Sherrill
h3. Kickstart only variables:
71 1 Justin Sherrill
72
|_.Name|_.Description|_.Example|
73
|@dynamic |||
74
|@osver |||
75
|@arch |||
76
|@mediapath |||
77
|@epel |||
78
|@yumrepo |||
79
|@static |||
80
81 8 Justin Sherrill
h3. Preseed attributes:
82 6 Justin Sherrill
83 1 Justin Sherrill
|_.Name|_.Description|_.Example|
84
|@preseed_path |||
85
|@preseed_server |||