Skip to content

Commit

Permalink
Merge pull request #7 from Tronde/enhance-create-vars
Browse files Browse the repository at this point in the history
Patch installation in November went well in first stage and didn't show any issues. PR is ready to be merged.
  • Loading branch information
Tronde authored Nov 13, 2020
2 parents 2746138 + 9cb74db commit f577082
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Patchmanagement for Red Hat Enterprise Linux Server.
Use Case
--------

In our environment we deploy RHEL-Servers for our operating departments to run their applications.
In our environment we deploy RHEL-Servers for our departments to run their applications.

This role was written to provide a mechanism to install Red Hat Advisories on target nodes once a month. The Sysadmin could choose which Advisories should be installed, e.g. RHSA, RHBA and/or RHEA.

Expand Down
28 changes: 25 additions & 3 deletions create_vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,39 @@ get_advisories() {
yum updateinfo list all 2>/dev/null | awk '/RHSA-[0-9]{4}:[0-9]{4}/ {print $(NF-2)}' | sort -u
}

get_remote_advisories() {
rm "${REMOTE_ADVISORIES}" 2>/dev/null
for HOST in "${REMOTE_HOSTS}"
do
ssh -i "${SSH_KEY}" ${REMOTE_USER}@${HOST} "$(typeset -f get_advisories); get_advisories" >>"${REMOTE_ADVISORIES}" 2>/dev/null
done
}

create_patch_set() {
if [ ! -f "${BASELINE}" ]
then
get_advisories >"${BASELINE}" 2>/dev/null
if [ -n "$REMOTE_HOSTS" ]
then
get_remote_advisories
mv "${BASELINE}" "${TMPFILE}"
cat "${TMPFILE}" "${REMOTE_ADVISORIES}" | sort -u >"${BASELINE}" 2>/dev/null
rm "${REMOTE_ADVISORIES}" "${TMPFILE}"
fi
cp "${BASELINE}" "${CURRENT_PATCH_SET}" 2>/dev/null
else
if [ -f "${ADVISORIES}" ] && [ -s "${ADVISORIES}" ]
# if [ -f "${ADVISORIES}" ] && [ -s "${ADVISORIES}" ]
# then
# mv "${ADVISORIES}" "${BASELINE}"
# fi
get_advisories >"${ADVISORIES}"
if [ -n "$REMOTE_HOSTS" ]
then
mv "${ADVISORIES}" "${BASELINE}"
get_remote_advisories
mv "${ADVISORIES}" "${TMPFILE}"
cat "${TMPFILE}" "${REMOTE_ADVISORIES}" | sort -u >"${ADVISORIES}" 2>/dev/null
rm "${REMOTE_ADVISORIES}" "${TMPFILE}"
fi
get_advisories >"${ADVISORIES}"
comm -13 "${BASELINE}" "${ADVISORIES}" >"${CURRENT_PATCH_SET}"
fi
}
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ galaxy_info:
- name: EL
versions:
- 7
- 8

galaxy_tags:
- rhel
Expand Down
14 changes: 14 additions & 0 deletions variables.txt.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,17 @@ DATE1="`date --iso -d '+7 days'`T04:20"
DATE2="`date --iso -d '+14 days'`T04:20"
DATE3="`date --iso -d '+21 days'`T04:20"
DATE4="`date --iso -d '+22 days'`T04:20"
# Variables you need when using remote advisory sources ######################
# These are needed if you want to pull additional advisories from another
# RHEL version.
#
# Example:
# The host you installed this role on has access to the RHEL 7 advisories but
# you want to get the advisories for RHEL 8, too. In this case you need to
# fill the following variables in order to connect to an appropriate remote
# host.
REMOTE_USER=""
SSH_KEY=""
REMOTE_HOSTS=()
REMOTE_ADVISORIES="${BASEPATH}/remote_advisories.txt"
TMPFILE="${BASEPATH}/tmpfile.txt"

0 comments on commit f577082

Please sign in to comment.