in Blog

Solaris SMF

Isn’t it always the case, a drought then a couple of interesting pieces of work come along at the same time!

Following an urgent requirement to load balance 2 unstable app servers (not my doing, I should add!).
I started configuring a Mod Proxy version of Apache, which took no time at all in fact.
However I then used my sandpit server to try and test controlling it using Solaris SMF.
Note to self: Check already half configured SMF services prior to installing new ones!

I inadvertently attempted to install an additional instance of an already defined http service, without realising that’s what I had done.
NB, take a step away and re-think the problem…just disconvered teapigs Darjeeling earl grey – fantastic!

Subsequently ended up with an apche instance running and I couldn’t figure out why?
Turns out, I’d removed the service definition before the application was shutdown and subsequently couldn’t use SMF commands to control the application or kill it as the already installed service was restarting the http daemon!
Yes you’ve guessed it….re install the previous SMF service and then stop the application, make sure its all stopped, then delete the service:

svccfg -v import ApacheModJK.xml
svcadm disable ApacheModJK
ps -ef|grep httpd
svccfg delete ApacheModJK

While all this was going on I was trying to configure the installer and test the deployment.
So while I was executing the SMF method directly to start and stop the http daemon it worked fine, however as soon as I try to run the SMF command to enable/disable the service it was a no go?
I wa getting the following:

[ Aug 4 11:03:59 Executing start method (“/opt/apache/httpd-2.2.4/bin/Apache.ksh start”) ]
svc.startd could not set context for method: chdir: No such file or directory
[ Aug 4 11:03:59 Method “start” exited with status 96 ]

I had also configured RBAC to enable the service to be started/stopped as a different user, however I was testing starting and stopping the SMF method directly as superuser, however as soon as i tried to use the SMF service commands it was a no go?

Its during these times of need that google is your friend!
I came accross the following as one of the first posts:
Which didn’t solve the problem but it certainly pointed me in the correct direction.

I hadn’t actually su’d to that user, DOH! When I did, I discovered the error….no home directory. Bloody school boy error 🙁

So the answer lies in two stages, creating the RBAC privileges required:

grep webservd /etc/user_attr
webservd::::type=normal;auths=solaris.smf.manage.site/apache
grep apache /etc/security/auth_attr
solaris.smf.manage.site/apache:::Apache restart authority::

And the Solaris manifest file used to configure SMF which lists the roles required to control apache as user ‘webservd’ (which nee dto be preconfigured in RBAC files:

SMF user guide here…

  1.  
  2. <?xml version="1.0"?>
  3. <!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
  4. <!–
  5.     Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  6.     Use is subject to license terms.
  7.  
  8.     ident       "@(#)http-apache2.xml   1.3     06/03/27 SMI"
  9. –>
  10.  
  11. <service_bundle type=‘manifest’ name=‘ApacheProxy:apache’>
  12.  
  13. <service
  14.         name=‘site/http’
  15.         type=‘service’
  16.         version=‘1’>
  17.  
  18.         <!–
  19.           Because we may have multiple instances of network/http
  20.           provided by different implementations, we keep dependencies
  21.           and methods within the instance.
  22.         –>
  23.  
  24.         <instance name=‘ApacheProxy’ enabled=‘false’>
  25.                 <!–
  26.                   Wait for network interfaces to be initialized.
  27.                 –>
  28.                 <dependency name=‘network’
  29.                     grouping=‘require_all’
  30.                     restart_on=‘error’
  31.                     type=‘service’>
  32.                     <service_fmri value=‘svc:/milestone/network:default’/>
  33.                 </dependency>
  34.  
  35.                 <!–
  36.                   Wait for all local filesystems to be mounted.
  37.                 –>
  38.                 <dependency name=‘filesystem-local’
  39.                     grouping=‘require_all’
  40.                     restart_on=‘none’
  41.                     type=‘service’>
  42.                     <service_fmri
  43.                         value=‘svc:/system/filesystem/local:default’/>
  44.                 </dependency>
  45.  
  46.                 <!–
  47.                   Wait for automounting to be available, as we may be
  48.                   serving data from home directories or other remote
  49.                   filesystems.
  50.                 –>
  51.                 <dependency name=‘autofs’
  52.                     grouping=‘optional_all’
  53.                     restart_on=‘error’
  54.                     type=‘service’>
  55.                     <service_fmri
  56.                         value=‘svc:/system/filesystem/autofs:default’/>
  57.                 </dependency>
  58.  
  59.                 <exec_method
  60.                         type=‘method’
  61.                         name=‘start’
  62.                         exec=‘/opt/apache/httpd-2.2.4/bin/Apache.ksh start’
  63.                         timeout_seconds=’60’ >
  64.                         <method_context>
  65.                                <method_credential
  66.                                        user="webservd"
  67.                                        group="webservd"
  68.                                        privileges="basic,net_privaddr" />
  69.                         </method_context>
  70.                 </exec_method>
  71.  
  72.                 <exec_method
  73.                         type=‘method’
  74.                         name=‘stop’
  75.                         exec=‘/opt/apache/httpd-2.2.4/bin/Apache.ksh stop’
  76.                         timeout_seconds=’60’ />
  77.  
  78.                 <exec_method
  79.                         type=‘method’
  80.                         name=‘refresh’
  81.                         exec=‘/opt/apache/httpd-2.2.4/bin/Apache.ksh refresh’
  82.                         timeout_seconds=’60’ >
  83.                         <method_context>
  84.                                <method_credential
  85.                                        user="webservd"
  86.                                        group="webservd"
  87.                                        privileges="basic,net_privaddr" />
  88.                         </method_context>
  89.                 </exec_method>
  90.  
  91.                 <property_group name=‘start’ type=‘method’>
  92.                         <propval
  93.                                 name=‘action_authorization’
  94.                                 type=‘astring’
  95.                                 value=‘solaris.smf.manage.site/apache’ />
  96.                         <propval
  97.                                 name=‘modify_authorization’
  98.                                 type=‘astring’
  99.                                 value=‘solaris.smf.manage.site/apache’ />
  100.                         <propval
  101.                                 name=‘value_authorization’
  102.                                 type=‘astring’
  103.                                 value=‘solaris.smf.manage.site/apache’ />
  104.                 </property_group>
  105.  
  106.                 <property_group name=‘stop’ type=‘method’>
  107.                         <propval
  108.                                 name=‘action_authorization’
  109.                                 type=‘astring’
  110.                                 value=‘solaris.smf.manage.site/apache’ />
  111.                         <propval
  112.                                 name=‘modify_authorization’
  113.                                 type=‘astring’
  114.                                 value=‘solaris.smf.manage.site/apache’ />
  115.                         <propval
  116.                                 name=‘value_authorization’
  117.                                 type=‘astring’
  118.                                 value=‘solaris.smf.manage.site/apache’ />
  119.                 </property_group>
  120.  
  121.                 <property_group name=‘restart’ type=‘method’>
  122.                         <propval
  123.                                 name=‘action_authorization’
  124.                                 type=‘astring’
  125.                                 value=‘solaris.smf.manage.site/apache’ />
  126.                         <propval
  127.                                 name=‘modify_authorization’
  128.                                 type=‘astring’
  129.                                 value=‘solaris.smf.manage.site/apache’ />
  130.                         <propval
  131.                                 name=‘value_authorization’
  132.                                 type=‘astring’
  133.                                 value=‘solaris.smf.manage.site/apache’ />
  134.                 </property_group>
  135.  
  136.                 <property_group name=‘general’ type=‘framework’>
  137.                         <propval
  138.                                 name=‘action_authorization’
  139.                                 type=‘astring’
  140.                                 value=‘solaris.smf.manage.site/apache’ />
  141.                         <propval
  142.                                 name=‘modify_authorization’
  143.                                 type=‘astring’
  144.                                 value=‘solaris.smf.manage.site/apache’ />
  145.                         <propval
  146.                                 name=‘value_authorization’
  147.                                 type=‘astring’
  148.                                 value=‘solaris.smf.manage.site/apache’ />
  149.                 </property_group>
  150.  
  151.  
  152.  
  153.                 <property_group name=‘httpd’ type=‘application’>
  154.                         <stability value=‘Evolving’ />
  155.                         <propval name=‘ssl’ type=‘boolean’ value=‘false’ />
  156.                 </property_group>
  157.  
  158.                 <property_group name=‘startd’ type=‘framework’>
  159.                         <!– sub-process core dumps shouldn’t restart
  160.                                 session –>
  161.                         <propval name=‘ignore_error’ type=‘astring’
  162.                                 value=‘core,signal’ />
  163.                 </property_group>
  164.  
  165.         </instance>
  166.  
  167.         <stability value=‘Evolving’ />
  168.  
  169.         <template>
  170.                 <common_name>
  171.                         <loctext xml:lang=‘C’>
  172.                                 Apache 2.2.4 HTTP server with Mod Proxy
  173.                         </loctext>
  174.                 </common_name>
  175.                 <documentation>
  176.                         <manpage title=‘httpd’ section=‘8’
  177.                                 manpath=‘/opt/apache/httpd-2.2.4/man’ />
  178.                         <doc_link name=‘apache.org’
  179.                                 uri=‘http://httpd.apache.org’ />
  180.                 </documentation>
  181.         </template>
  182. </service>
  183.  
  184. </service_bundle>
  185.  
  186.  

Write a Comment

Comment