Corey Osman
2011-Aug-08 21:49 UTC
[Puppet Users] Help with retrieving a user''s environment variable
Hi, 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? Corey -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Matthias Saou
2011-Aug-09 13:02 UTC
Re: [Puppet Users] Help with retrieving a user''s environment variable
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?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 Matthias -- Clean custom Red Hat Linux rpm packages : http://freshrpms.net/ Fedora release 14 (Laughlin) - Linux kernel 2.6.35.13-91.fc14.x86_64 Load : 0.01 0.35 0.52 -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Daniel Pittman
2011-Aug-09 13:19 UTC
Re: [Puppet Users] Help with retrieving a user''s environment variable
On Tue, Aug 9, 2011 at 06:02, Matthias Saou <thias@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 > fiDaniel -- ⎋ 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Corey Osman
2011-Aug-09 20:49 UTC
[Puppet Users] Re: Help with retrieving a user''s environment variable
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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Scott Smith
2011-Aug-09 23:58 UTC
Re: [Puppet Users] Re: Help with retrieving a user''s environment variable
oraclesids = "proddb1,proddb2" oracle_home_proddb1 = "/oracle/product/10.2.0" ... On Tue, Aug 9, 2011 at 1:49 PM, Corey Osman <corey@logicminds.biz> wrote:> 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+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > >-- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.