SysDirector is a tool that makes managing groups of systems simpler. Think about how many configuration files on your systems are identical except for a handful of lines. Now imagine being able to customize those lines automatically based on system attributes:
SysDirector allows you to stop focusing on editing file contents and start focusing on the interesting parts of system administration.
Make use of SysDirector's templating capabilities to template /etc/resolv.conf. While on the surface this would seem to be a trivial file, it offers the ability to demonstrate many of SysDirector's features without being too complex to serve as a good example.
Start by creating the objects necessary to describe a small network. We will start with two locations, Phoenix, Arizona, and Denver, Colorado. At each site, we will have two DNS servers and two web servers.
First create a demo environment:
> cd /env
> mkdir demo
And now checkout a copy of that environment to work with:
> cd /wc
> mkdir leap-cf
> cd /wc/leap-cf/demo
#set $dnssearchpaths = $data.dnssearchpaths
#if $dnssearchpaths
search#slurp
#for $domain in $dnssearchpaths
${domain}#slurp
#end for
#end if
#for $nameserver in $data.nameservers
nameserver ${nameserver}
#end for
## See resolv.conf(5) for options documentation
#set global $dnsoptions = $data.dnsoptions
#if $dnsoptions
options#slurp
#if $dnsoptions.has_key('debug')
debug#slurp
#end if
#if $dnsoptions.has_key('ndots')
ndots:${dnsoptions.ndots}#slurp
#end if
#if $dnsoptions.has_key('timeout')
timeout:${dnsoptions.timeout}#slurp
#end if
#if $dnsoptions.has_key('attempts')
attempts:${dnsoptions.attempts}#slurp
#end if
#if $dnsoptions.has_key('rotate')
rotate#slurp
#end if
#if $dnsoptions.has_key('nochecknames')
no-check-names#slurp
#end if
#if $dnsoptions.has_key('inet6')
inet6#slurp
#end if
#if $dnsoptions.has_key('ip6dotint')
ip6-dotint#slurp
#end if
#if $dnsoptions.has_key('ip6bytestring')
ip6-bytestring#slurp
#end if
#end if
> createvar dnssearchpaths [list,None] “Search list for host name lookup”
> createvar nameservers [list,None] “Nameserver IP addresses”
> createvar dnsoptions [dict,None] “Settings for internal resolver variables”
> cd /wc/leap-cf/demo/data/default
> mkdir dnssearchpaths
> cd /wc/leap-cf/demo/data/default/dnssearchpaths
> append example.com
> get /wc/leap-cf/demo/variables/ns-01.phx.example.com/dnssearchpaths
['example.com']
> cd /wc/leap-cf/demo/data/group
> mkdir name=phx
> mkdir name=den
> cd /wc/leap-cf/demo/data/group/name=phx
> mkdir dnssearchpaths
> mkdir nameservers
> cd /wc/leap-cf/demo/data/group/name=phx/nameservers
> append 192.0.2.1
> append 192.0.2.2
> cd /wc/leap-cf/demo/data/group/name=phx/dnssearchpaths
> append phx.example.com
> get /wc/leap-cf/demo/variables/ns-01.phx.example.com/dnssearchpaths
['example.com', 'phx.example.com']
> get /wc/leap-cf/demo/files/ns-01.phx.example.com/etc/resolv.conf
search phx.example.com example.com nameserver 192.0.2.1 nameserver 129.0.2.2
> get /wc/leap-cf/demo/files/ns-01.den.example.com/etc/resolv.conf
search den.example.com example.com nameserver 192.0.2.129 nameserver 129.0.2.130
> cd /wc/leap-cf/demo/data/group
> mkdir name=webservers
> cd /wc/leap-cf/demo/data/group/name=webservers
> mkdir dnsoptions
> cd /wc/leap-cf/demo/data/group/name=webservers/dnsoptions
> mkdir timeout
> set timeout 3
> get /wc/leap-cf/demo/files/www-01.phx.example.com/etc/resolv.conf
search phx.example.com example.com nameserver 192.0.2.1 nameserver 129.0.2.2 options timeout:3
Commit Message: Add a demonstration for creating and populating resolv.conf Changed Files: A /data/group/name=dnsservers/dnsoptions ... A /text/resolv.conf A /system-objects/posixpath/name=/etc/resolv.conf;operatingsystem=name=centos5 A /system-objects/posixservice/name=httpd Commit changes? [yes/No] yes
; do not edit by hand
; $sysutil.filename is dynamically generated by
; SysDirector for $sysutil.host.name
; Service: $sysutil.host.services("name=ntpd").name
#set $ntpservers = $sysutil.gethostbyname("0.pool.ntp.org")
#for $ipaddr in $ntpservers
server $ipaddr
#end for
; do not edit by hand ; /etc/ntp.conf is dynamically generated by ; SysDirector for test.example.com ; Service: ntpd server 8.15.10.42 server 66.187.233.4 server 66.250.45.2 server 69.10.36.3 server 74.53.198.146
> log
-------------------------------------------------------------------------------- r1063 | andrew | 2008-07-17 12:10:21 -0400 (Thu, 17 Jul 2008) | 1 line Add ntp.conf as a dynamic template example -------------------------------------------------------------------------------- r1062 | andrew | 2008-07-17 11:57:41 -0400 (Thu, 17 Jul 2008) | 1 line Add a demonstration for creating and populating resolv.conf -------------------------------------------------------------------------------- r1061 | andrew | 2008-07-17 11:11:51 -0400 (Thu, 17 Jul 2008) | 1 line Created demo environment --------------------------------------------------------------------------------
> diff /env/demo@1062/text/ntp.conf /wc/leap-cf/demo/text/ntp.conf
--- /env/demo@1062/text/ntp.conf Wed Dec 31 19:00:00 1969
+++ /wc/leap-cf/demo/text/ntp.conf Thu Jul 17 11:59:22 2008
@@ -1,0 +1,8 @@
+; do not edit by hand
+; $sysutil.filename is dynamically generated by
+; SysDirector for $sysutil.host.name
+; Service: $sysutil.host.services("name=ntpd").name
+#set $ntpservers = $sysutil.gethostbyname("0.pool.ntp.org")
+#for $ipaddr in $ntpservers
+server $ipaddr
+#end for