Hi Experts,
Just started learning ansible few weeks back. want to automate a shell script. Need your help badly. Any jinja template or any help would be greatly appreciated.
Here is the pseudocode for the shell script
RHEL7_ENTRY1 -= “Algorithim-abc-xyz”
RHEL7_ENTRY2 -= “Cipher- cxyx-dfas”
MULTIPLE_ENTRY1= grep -i Cipher /etc/ssh/sshd_config | wc -l
$SSHD_FILE = /etc/ssh/sshd_config
If (OS== RHEL7)
Print (Redhat 7 >> to the logfile)
If $RHEL7_ENTRY1 found in /etc/ssh/sshd_config file
print ( "Entry 1 found Ifgnoring changes " >> to the logfile)
if($MULTIPLE_ENTRY -gt 1)
-
Delete the old/duplicate entry of “Algorithm” from sshd_config file
sed -i ‘/Algothims/d’ $SSHD_FILE
sed -i ‘/Ciphers/d’ $SSHD_FILE -
Add the new key(RHEL7_ENTRY1 & RHEL_ENTRY2) to the sshd_cofig file
sed -i “$a $RHEL7_ENTRY1” $SSHD FILE
sed -i “$a $RHEL7_ENTRY2” $SSHD_FILEelse -
Print First entry does not match >> logfile
-
remove any line if match to the string “Cipher”
-
Add RHEL7_ENTRY1 to sshd_config file
if (RHEL7_ENTRY2) found in sshd_config file
Print Entry2 found Ignoring changes >> logfile
else
print "2nd Entry not an exact match updating the file >> logfile
remove the line containing the string “Cipher”
Add the new key(RHEL_ENTRY2) to the sshd_cofig file
fi
And I ve to run the same for RHEL6, 7, 8 and Amazon Linux
Regards