TemplateWriting » History » Version 13
Justin Sherrill, 02/02/2011 09:51 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 | 13 | Justin Sherrill | Only a single template of each type may be rendered for a system. Foreman determines which template to use following these rules: |
16 | 1 | Justin Sherrill | |
17 | 13 | Justin Sherrill | 1. Only the templates of the appropriate kind and associated with the hosts operating system are considered |
18 | 2. If a template has a hostgroup/environment combination that matches that of the host, use this template else |
||
19 | 3. If a template is associated with the environment of the host, use this template, else |
||
20 | 4. Use the first template found associated with the operating system associated with the host. |
||
21 | 1 | Justin Sherrill | |
22 | 13 | Justin Sherrill | So essentially, the hostgroup/environment combination is used first, then just the environment, and finally just the operating system of the host. |
23 | |||
24 | |||
25 | 1 | Justin Sherrill | To access a template of a certain type simply use this url: |
26 | |||
27 | 13 | Justin Sherrill | @/unattended/KIND_NAME@ |
28 | 1 | Justin Sherrill | |
29 | 13 | Justin Sherrill | For example: @/unattended/provision@ |
30 | 12 | Justin Sherrill | 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: |
31 | |||
32 | 13 | Justin Sherrill | @/unattended/provision?spoof=192.168.0.1@ |
33 | 12 | Justin Sherrill | |
34 | 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. |
||
35 | 8 | Justin Sherrill | |
36 | |||
37 | h3. Hostgroup-based rendering |
||
38 | 9 | Justin Sherrill | |
39 | 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: |
40 | |||
41 | /unattended/template/Template Name/Hostgroup Name |
||
42 | |||
43 | For example, a hostgroup of name Finance, and a template named WebServerKickstart could be rendered using the url: |
||
44 | |||
45 | 11 | Justin Sherrill | /unattended/template/WebServerKickstart/Finance |
46 | 1 | Justin Sherrill | |
47 | 10 | Justin Sherrill | h4. PXE Menus |
48 | |||
49 | Pxe Menus can be deployed to smart proxies from the Config Tempalates. |
||
50 | 8 | Justin Sherrill | |
51 | h2. Writing templates |
||
52 | |||
53 | |||
54 | |||
55 | h2. Functions and macros: |
||
56 | |||
57 | 1 | Justin Sherrill | |_.Name|_.Description|_.Example| |
58 | |root_pass |The root password configured for the system| | |
||
59 | 7 | Justin Sherrill | |ks_console | | | |
60 | 6 | Justin Sherrill | |snippets(name) | Renders the specified snippet | | |
61 | 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 | |
62 | |@host |The name of the host| | |
||
63 | |@host.name |The name of the host| | |
||
64 | |@host.diskLayout |The disklayout of the host (could come from the operating system)| | |
||
65 | |@host.puppetmaster |The puppetmaster the host should use | | |
||
66 | |@host.architecture |The arch of the host (i.e. x86_64)| | |
||
67 | |@host.operatingsystem|The operating system name| | |
||
68 | |@host.operatingsystem.media_url ||| |
||
69 | |@host.operatingsystem.major |The major version of the OS|| |
||
70 | |@host.operatingsystem.minor |The minor version of the OS|| |
||
71 | |@host.operatingsystem.family |The OS Family (I.e. redhat, debian, etc.)|| |
||
72 | |@host.url_for_boot(:kernel) ||| |
||
73 | |@host.url_for_boot(:initrd) ||| |
||
74 | |||
75 | |||
76 | 2 | Justin Sherrill | |
77 | 8 | Justin Sherrill | h3. Kickstart only variables: |
78 | 1 | Justin Sherrill | |
79 | |_.Name|_.Description|_.Example| |
||
80 | |@dynamic ||| |
||
81 | |@osver ||| |
||
82 | |@arch ||| |
||
83 | |@mediapath ||| |
||
84 | |@epel ||| |
||
85 | |@yumrepo ||| |
||
86 | |@static ||| |
||
87 | |||
88 | 8 | Justin Sherrill | h3. Preseed attributes: |
89 | 6 | Justin Sherrill | |
90 | 1 | Justin Sherrill | |_.Name|_.Description|_.Example| |
91 | |@preseed_path ||| |
||
92 | |@preseed_server ||| |