Good suggestions. How about this: Create a fact that parses /etc/oratab for the SID. For multiple SIDS defined in oratab, is it possible to define an array in facter? If not I think comma separated values would do just fine which I would then use sid.split(',') in the puppet manifest to get each SID.
# Entries are of the form: # $ORACLE_SID:$ORACLE_HOME:<N|Y>: proddb1:/oracle/product/10.2.0/db:N proddb2:/oracle/product/10.2.0/db:N Corey On Aug 9, 6:19 am, Daniel Pittman <dan...@puppetlabs.com> wrote: > On Tue, Aug 9, 2011 at 06:02, Matthias Saou > <th...@spam.spam.spam.spam.spam.spam.spam.egg.and.spam.freshrpms.net> > wrote: > > > Corey Osman wrote : > > >> I need to get the environment variable ORACLE_SID from the OS. I know > >> this can be done with the following: > > >> $blah = env("PATH") > > >> However, the ORACLE_SID variable is only set under the oracle user > >> account. So I would need a way to login as the oracle account first to > >> retrieve the ORACLE_SID variable. Is there anyway to get the environment > >> variable from a user's account instead of the default account puppet runs > >> under? > > Only horrible ways, I fear: you would need to run something that > extracts the data. There are two obvious ways, one is to `su` or > equivalent into the Oracle account, then run something to extract the > value. The other is to extract it from the appropriate configuration > file, ala `grep ORACLE_SID /path/to/oracle/.bashrc`. > > The best way is to define that value out of Puppet, or some external > data store, and extract it in both places, exactly as Matthias > suggests: > > > > > > > > > > > I'm sorry to not actually be of much help regarding your original > > question... The thing is that puppet is usually used the other way > > around, hence this way I use to pre-configure RHEL servers for our > > bash-using Oracle DBAs : > > > # Oracle profile sourced file > > file { '/etc/profile.d/oracle.sh': > > mode => '0755', > > content => template('/path/to/oracle.sh.erb'), > > } > > > And the template contains the following : > > > export ORACLE_BASE=/u01/app/oracle > > export ORACLE_HOME=/u01/app/oracle/oracle/product/<%= version %>/<%= > > title %><%= oracle_home_suffix %> > > export ORACLE_SID=<%= oracle_sid %> > > export TNS_ADMIN=$ORACLE_HOME/network/admin > > > if [ `/usr/bin/id -un` == "oracle" ]; then > > export PATH=$PATH:$ORACLE_HOME/bin > > fi > > Daniel > -- > ⎋ Puppet Labs Developer –http://puppetlabs.com > ♲ Made with 100 percent post-consumer electrons -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.