AWS using Ansible? Yes, it's possible!

  Although, I've used Ansible extensively for a lot of automation and orchestration tasks, using Ansible for AWS was indeed, a new territory for me.  This turned out to be a blessing, since along with using Ansible for AWS tasks, I also learnt how to use WSL (Windows Subsystem for Linux) on a Windows machine. Though WSL's been around for some time, I still hadn't come around to using it since I was mostly using my Macbook pro. Not anymore, though!  Anyway, I have listed below the steps to: Install WSL on Windows 11 23H2 patch Install AWS CLI on Ubuntu 22.04 (Exact version - 22.04.3 LTS) Install Ansible and the amazon.aws collection Use AWS CLI to get the list of  VPCs in the region - us-east-1 (or a region of your choice) Create a python file/script to get the list of VPCs in the region - us-east-1 (or a region of your choice) Create an Ansible playbook to get the list of VPCs in the region - us-east-1 (or a region of your choice.   You may download the comple...

WGET shell Script for downloading patches

What I have to offer this time is a script using which you can download patches using WGET from Meta.....oops, from My Oracle Support, I should say!


This script needs (or accepts) the following parameters:


1. Me...oops...MOS Username
2. MOS (I got it right this time!) password
3. Patch file name
4. ARU Number

You can get 3 and 4 in the following way:


Using MOS:

Query for the particular patch, click on the download link, click on WGET Options on the left side bottom corner and then copy the WGET script to clipboard. That script will have both the patch name and the ARU number.


Using HTML (supporthtml.oracle.com):

Query for the particular patch, click on the patch, then RIGHT CLICK on the patch zip file link and click on copy shortcut in IE (or copy link location in Mozilla Firefox). This link will have both the patch file name and the ARU number.

Using the classic patches window:

Query for the particular patch, then RIGHT CLICK on the DOWNLOAD button and click on copy shortcut in IE (or copy link location in Mozilla Firefox). This link will have both the patch file name and the ARU number.


I do understand that this is a roundabout process but I believe it is better than downloading the file to your desktop and then uploading to the server.

I am also working on a script to retrieve the aru number and the patch file name given the patch number. But I have had no success so far. If anyone has that script or any better script to download patches, please do not hesitate to share it.

WGET SCRIPT:

#!/bin/sh



# Start of user configurable variables

#



# SSO username and password

printf "\n\nEnter the SSO USERNAME for Metalink:\t"

read SSO_USERNAME

printf "\n\n\n\nEnter the SSO PASSWORD for Metalink:\t"

##SSO_PASSWORD="password"

stty -echo

read SSO_PASSWORD

stty echo



# E-Delivery token

EPD_TOKEN=







# Path to wget command

WGET=/usr/bin/wget



# Location of cookie file

COOKIE_FILE=/tmp/$$.cookies



# Log directory and file

LOGDIR=.

LOGFILE=$LOGDIR/wgetlog-`date +%d-%b-%y-%H-%M`.log



# Output directory and file

OUTPUT_DIR=.



## Added by Praveen B K, for customising the script.

printf "\n\nEnter the PATCH FILE NAME:\t"

read PATCH_FILE_NAME



printf "\n\nEnter the aru number:\t"

read ARU



#

# End of user configurable variable

#



if [ "$SSO_USERNAME " = " " ]

then

printf "\n\nSSO USERNAME cannot be null. Exiting............\n\n\n"

exit 1

fi



if [ "$SSO_PASSWORD " = " " ]

then

printf "\n\nSSO PASSWORD cannot be null. Exiting............\n\n\n"

exit 1

fi



if [ "$PATCH_FILE_NAME " = " " ]

then

printf "\n\nPATCH FILE NAME cannot be blank. Exiting............\n\n\n"

exit 1

fi



if [ "$ARU " = " " ]

then

printf "\n\naru number cannot be blank. Exiting............\n\n\n"

exit 1

fi



# Contact updates site so that we can get SSO Params for logging in

SSO_RESPONSE=$($WGET https://updates.oracle.com/Orion/Services/download 2>&1grep Location)



# Extract request parameters for SSO

SSO_TOKEN=`echo $SSO_RESPONSE cut -d '=' -f 2cut -d ' ' -f 1`

SSO_SERVER=`echo $SSO_RESPONSE cut -d ' ' -f 2cut -d 'p' -f 1,2`

SSO_AUTH_URL=sso/auth

AUTH_DATA="ssousername=$SSO_USERNAME&password=$SSO_PASSWORD&site2pstoretoken=$SSO_TOKEN"



# The following command to authenticate uses HTTPS. This will work only if the wget in the environment

# where this script will be executed was compiled with OpenSSL. Remove the --secure-protocol option

# if wget was not compiled with OpenSSL

# Depending on the preference, the other options are --secure-protocol= autoSSLv2SSLv3TLSv1

$WGET --secure-protocol=auto --post-data $AUTH_DATA --save-cookies=$COOKIE_FILE --keep-session-cookies $SSO_SERVER$SSO_AUTH_URL -O sso.out >> $LOGFILE 2>&1



rm -f sso.out



$WGET --load-cookies=$COOKIE_FILE --save-cookies=$COOKIE_FILE --keep-session-cookies "https://updates.oracle.com/Orion/Services/download/${PATCH_FILE_NAME}?aru=${ARU}&patch_file=${PATCH_FILE_NAME}" -O $OUTPUT_DIR/${PATCH_FILE_NAME} >> $LOGFILE 2>&1





# Cleanup

rm -f $COOKIE_FILE



Comments

Popular posts from this blog

Check if UTL_FILE and FND_FILE are working fine

Modify retention period of workflow queues

Clone database home (clone.pl) deprecated in Oracle 19c