Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
3301300
Merge pull request #24 from albatrossflavour/master
albatrossflavour Aug 10, 2018
a38dbdd
more detailed example on using query
albatrossflavour Aug 12, 2018
c1fc7ae
workaround for old windows agents that do not support aggregate facts
albatrossflavour Aug 13, 2018
dea3a15
Ensure fact cache generation is run when the cache directory is creat…
albatrossflavour Aug 13, 2018
1dd8ca5
exclude all 3.3.2 clients
albatrossflavour Aug 13, 2018
8bdefe7
Catch all non-v2 facter versions and exit
albatrossflavour Aug 13, 2018
f314de3
rubocop
albatrossflavour Aug 13, 2018
4d80278
rubocop
albatrossflavour Aug 13, 2018
5627410
rubocop
albatrossflavour Aug 13, 2018
0b0776d
Fix incorrect boolean check
albatrossflavour Aug 13, 2018
bffdef4
remove path for yum for now
albatrossflavour Aug 13, 2018
4380827
lockfile for fact generation
albatrossflavour Aug 14, 2018
d88f12a
RHEL6 logic
albatrossflavour Aug 14, 2018
7b1c48c
lockfile
albatrossflavour Aug 14, 2018
2832887
RHEL6 code
albatrossflavour Aug 14, 2018
1c0720c
RHEL6 code
albatrossflavour Aug 14, 2018
590889f
RHEL6 code
albatrossflavour Aug 14, 2018
7bef0e0
RHEL6 code
albatrossflavour Aug 14, 2018
9446bcc
RHEL6 code
albatrossflavour Aug 14, 2018
26fde99
RHEL6 code
albatrossflavour Aug 14, 2018
1183506
RHEL6 code
albatrossflavour Aug 14, 2018
a24f16b
RHEL6 code
albatrossflavour Aug 14, 2018
e4e67c5
RHEL6 code
albatrossflavour Aug 14, 2018
1a251fa
RHEL6 code
albatrossflavour Aug 14, 2018
7221bf6
RHEL6 code
albatrossflavour Aug 14, 2018
4949005
RHEL6 code
albatrossflavour Aug 14, 2018
f78809b
RHEL6 code
albatrossflavour Aug 14, 2018
0b5c9bf
RHEL6 code
albatrossflavour Aug 14, 2018
cb6452b
RHEL6 code
albatrossflavour Aug 14, 2018
097427c
buffer issues
albatrossflavour Aug 14, 2018
59f1fee
buffer issues
albatrossflavour Aug 14, 2018
05f6502
buffer issues
albatrossflavour Aug 14, 2018
7a14da8
buffer issues
albatrossflavour Aug 14, 2018
fcda2a8
buffer issues
albatrossflavour Aug 14, 2018
151ec8d
buffer issues
albatrossflavour Aug 14, 2018
2be519d
buffer issues
albatrossflavour Aug 14, 2018
cb0518d
buffer issues
albatrossflavour Aug 14, 2018
f2f5051
fix RHEL6
albatrossflavour Aug 14, 2018
2b506c5
Remove patching code
albatrossflavour Aug 14, 2018
4494e11
todo updates
albatrossflavour Aug 14, 2018
30347b4
fix issue with locking causing cascade failure
albatrossflavour Aug 14, 2018
0dcdfb2
new timeout code
albatrossflavour Aug 14, 2018
c5c6a4a
new timeout code
albatrossflavour Aug 14, 2018
597298c
new timeout code
albatrossflavour Aug 14, 2018
3114e3e
new timeout code
albatrossflavour Aug 14, 2018
51c6916
new timeout code
albatrossflavour Aug 14, 2018
6f607b0
new timeout code
albatrossflavour Aug 14, 2018
47c1d47
new timeout code
albatrossflavour Aug 14, 2018
29250d7
new timeout code
albatrossflavour Aug 14, 2018
afcac13
Clean up post timeout code rewrite
albatrossflavour Aug 14, 2018
eb61d87
bug with app restart code
albatrossflavour Aug 15, 2018
8d3e55c
Merge pull request #25 from albatrossflavour/feature/timeouts
albatrossflavour Aug 15, 2018
4b9da7d
rubocop fixen
albatrossflavour Aug 15, 2018
348fd98
rubocop fixen
albatrossflavour Aug 15, 2018
e94be12
rubocop
albatrossflavour Aug 15, 2018
982a776
added in RHEL5 "logic"
albatrossflavour Aug 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .done.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,4 @@ x 2018-08-09 2018-08-09 security issues with the yum_params options
x 2018-08-10 How many kernels should be installed? @Questions
x 2018-08-10 Should we check that the kernel version installed is the same as the one running? @Questions
x 2018-08-10 2018-08-10 Get rid of awk and grep
x 2018-08-10 Do we need to ensure the state of the yum config on the servers prior to patching? @Questions
1 change: 0 additions & 1 deletion .todo.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
Do we need to ensure the state of the yum config on the servers prior to patching? @Questions
Should we ensure that the last puppet run was green before continuing? @Questions
Should we ensure that the last puppet run was within X hours before starting patching? @Questions
Should we do a puppet run prior to kicking off the patching to ensure state? @Questions
10 changes: 10 additions & 0 deletions examples/running_patching_and_capturing_json_output.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Patch nodes and capture live json output

## Selecting the nodes to patch
You can use the query parameter to `puppet task` to determine which nodes you wish to act upon. The easiest example of this is to limit the patching to just nodes assigned to the 'Week3' patch window.:

```bash
puppet task run os_patching::patch_server --query='nodes[certname] { facts.os_patching.patch_window = "Week3" }'
```

More details on using queries within tasks can [be found on Puppet's website](https://puppet.com/docs/pe/2018.1/running_tasks_from_the_command_line.html#task-8683)

## Capturing and parsing resuls
If you want to patch using a script which will parse the results, you can do something similar to this:

```bash
Expand Down
46 changes: 37 additions & 9 deletions files/os_patching_fact_generation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@

PATH=/usr/bin:/usr/sbin:/bin:/usr/local/bin

LOCKFILE=/var/run/os_patching_fact_generation.lock

if [ -f "$LOCKFILE" ]
then
echo "Locked, exiting" >&2
exit 0
else
echo "$$" > $LOCKFILE
fi

case $(/usr/local/bin/facter osfamily) in
RedHat)
PKGS=$(yum -q check-update | awk '/^[a-z]/ {print $1}')
Expand All @@ -15,6 +25,7 @@ case $(/usr/local/bin/facter osfamily) in
SECPKGS=$(apt upgrade -s 2>/dev/null | awk '$1 == "Inst" && /security/ {print $2}')
;;
*)
rm $LOCKFILE
exit 1
;;
esac
Expand All @@ -26,6 +37,7 @@ SECUPDATEFILE="$DATADIR/security_package_updates"
if [ ! -d "${DATADIR}" ]
then
/usr/bin/logger -p error -t os_patching_fact_generation.sh "Can't find ${DATADIR}, exiting"
rm $LOCKFILE
exit 1
fi

Expand All @@ -41,19 +53,35 @@ do
echo "$UPDATE" >> ${SECUPDATEFILE} || exit 1
done

if [ -f '/bin/needs-restarting' ]
if [ -f '/usr/bin/needs-restarting' ]
then
/bin/needs-restarting -r 2>/dev/null 1>/dev/null
if [ $? -gt 0 ]
then
echo "true" > /etc/os_patching/reboot_required
else
echo "false" > /etc/os_patching/reboot_required
fi
/bin/needs-restarting 2>/dev/null >/etc/os_patching/apps_to_restart
case $(facter os.release.major) in
7)
/usr/bin/needs-restarting -r 2>/dev/null 1>/dev/null
if [ $? -gt 0 ]
then
echo "true" > /etc/os_patching/reboot_required
else
echo "false" > /etc/os_patching/reboot_required
fi
/usr/bin/needs-restarting 2>/dev/null >/etc/os_patching/apps_to_restart
;;
6)
OUTPUT=`/usr/bin/needs-restarting`
if [ -n "$OUTPUT" ]
then
echo "true" > /etc/os_patching/reboot_required
/usr/bin/needs-restarting > /etc/os_patching/apps_to_restart
else
echo "false" > /etc/os_patching/reboot_required
cat /dev/null > /etc/os_patching/apps_to_restart
fi
;;
esac
fi

/opt/puppetlabs/bin/puppet facts upload 2>/dev/null 1>/dev/null
/usr/bin/logger -p info -t os_patching_fact_generation.sh "patch data fact refreshed"

rm $LOCKFILE
exit 0
Loading