new to puppet - simple ordering question

68 views
Skip to first unread message

Phil Swenson

unread,
Sep 10, 2014, 10:42:07 AM9/10/14
to puppet...@googlegroups.com
Hi, I have a puppet file I'm running via vagrant that sets up oracle and changes the system password.

I need to make sure that the "oracle-xe" service is running before executing my password change script via sql plus.

Here is the code:

service {'oracle-xe':
 
ensure => running
}


service
{'iptables':
   
ensure => stopped
}


exec {"changeDbPassword":
  environment
=> ["ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe", "ORACLE_SID=XE"],
    command
=> "sqlplus -s /nolog <<EOF
connect sa/sa
ALTER USER system IDENTIFIED BY mypassword;
quit
EOF"
,
     path
=> "/u01/app/oracle/product/11.2.0/xe/bin/",
     logoutput
=> 'true'


}


This code works, but my understanding that the ordering isn't guaranteed, so how do I make sure that the exec command runs AFTER the oracle-xe service command?

Please let me know of other improvements - guessing that I can reference the environment variable instead of repeating it in the path => "/u01/app/oracle/product/11.2.0/xe/bin/"

Thanks!
phil


Stefan Heijmans

unread,
Sep 11, 2014, 6:34:02 AM9/11/14
to puppet...@googlegroups.com
Hi Phil,
 
checkout the resource ordering docs;
 
Stefan.
 

David Bryant-Moore

unread,
Sep 15, 2014, 9:36:20 AM9/15/14
to puppet...@googlegroups.com
Phil.

You're correct, you can reference the path as a Puppet variable by defining the variable at the head of your class:

$oracle_path = '/u01/app/oracle/product/11.2.0/xe/bin'

and referencing it like this in your exec resource: 

path => "${oracle_path}"

Note utilisation of the double quotes to allow variable expansion.


As Stefan suggests, have a look at the ordering metaparameters, before and require, which will solve your ordering problem.


Kind Regards.

David Bryant-Moore.
Reply all
Reply to author
Forward
0 new messages