Sunday, February 10, 2019

Updating Oracle Opatch with AWS Systems Manager Run Command at Scale

AWS Systems Manager (SSM) is a managed service by AWS, which is used to configure and manage EC2 instances, other AWS resources, and on-premise VMs/servers at scale. SSM frees you up from having ssh or bastion host access to the remote resources.

Pre-requisites of SSM:

The managed instances need to have SSM agent running.
The managed instances need to be assigned an IAM role with policy AmazonEC2RoleforSSM.
The managed insatnces need to have a meaningful tag assigned to them to make it possible to manage them in bulk.


This example assumes that above pre-requisites are already there. For step by step instructions as how to do that, check this resource ( This also assumes that all the instances
have been assigned tags like Env=Prod or Env=Dev.

Following is the script which was already bootstrapped to the EC2 instance at time of creation in userdata,
so its already present at /u01/scripts/

#/usr/bin/env bash -x
ORACLE_SID=`ps -ef | grep pmon | grep -v asm | awk '{print $NF}' | sed s'/pmon_//' | egrep "^[+]"`
. oraenv > /dev/null 2>&1
mv $ORACLE_HOME/OPatch $ORACLE_HOME/OPatch.$(date)
curl -T /tmp/ -u ftps://
mv /tmp/ $ORACLE_HOME

Now just running following command in Systems Manager will update opatch on all the managed instances with tag Prod.

aws ssm send-command --document-name "AWS-RunShellScript" --comment "" --parameters Key=tag:Env,Values=Prod


Kerrthika K said...

Nice blog!Thanks for sharing this information with us..
film making courses in chennai
part time film making courses in chennai
videography courses in chennai
video editing course in chennai
best film school in chennai
part time film editing courses in chennai
film editing courses in chennai

Deva Dev said...

Nice Post
AWS training in bangalore
AWS training in kalyan nagar
AWS training in marathahalli
AWS training in bellandur

vijay said...

Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
Oracle training in Chennai
| Best Oracle training in Chennai | Top oracle training in Chennai |Oracle training Institute in Chennai | Oracle training in KK nagar

Laura Bush said...

Excellent post. I always check this type of blog, and I’m impressed with Extremely useful info, I care for such information a lot. I am exploring this particular info for a long time. Thanks to this blog my exploration has ended. Best AWS Training in Delhi