Skip to content

Commit 865b3ff

Browse files
authored
Merge pull request #49 from EncoreTechnologies/feature/report-format-flag
Added new configuration options patching_reboot_wait, paching_report_…
2 parents e07f0b5 + e88d3f9 commit 865b3ff

7 files changed

Lines changed: 324 additions & 53 deletions

File tree

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,26 @@ All notable changes to this project will be documented in this file.
2525
config value wasn't being honored. (Bug Fix)
2626

2727
Contributed by Nick Maludy (@nmaludy)
28+
29+
* Added new configuration options:
30+
* `patching_reboot_wait`: Parameter controls the `reboot_wait` option for the number of seconds
31+
to wait between reboots. Default = 300
32+
* `paching_report_file`: Customize the name of the report file to write to disk. You
33+
can disable writing the report files by specifying this as `'disabled'`.
34+
NOTE: for PE users writing files to disk throws an error, so you'll be happy you can
35+
now disable writing these files!
36+
Default = `patching_report.csv`
37+
* `patching_report_format`: Customize the format of the reports written to the report file.
38+
Default = `pretty`
39+
40+
(Enhancement)
41+
42+
Contributed by Nick Maludy (@nmaludy)
43+
44+
* To support the new configuration options above, the `patching::reboot_required` plan
45+
had its parameter `reboot_wait` renamed to `wait`. (Enhancement)
46+
47+
Contributed by Nick Maludy (@nmaludy)
2848

2949
## Release 1.0.1 (2020-03-04)
3050

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#### Table of Contents
1313

14-
- [Description](#description)
14+
- [Module description](#module-description)
1515
- [Setup](#setup)
1616
- [Setup Requirements](#setup-requirements)
1717
- [Quick Start](#quick-start)
@@ -33,7 +33,7 @@
3333
- [Contributors](#contributors)
3434

3535

36-
## Description
36+
## Module description
3737

3838
A framework for building patching workflows. This module is designed to be used as building
3939
blocks for complex patching environments of Windows and Linux (RHEL, Ubuntu) systems.

REFERENCE.md

Lines changed: 170 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
* [`patching::check_online`](#patchingcheck_online): Checks each node to see they're online.
5353
* [`patching::check_puppet`](#patchingcheck_puppet): Checks each node to see if Puppet is installed, then gather Facts on all targets.
5454
* [`patching::deploy_scripts`](#patchingdeploy_scripts):
55+
* [`patching::get_facts`](#patchingget_facts): Sets patching facts on targets
5556
* [`patching::get_targets`](#patchingget_targets): <code>get_targets()</code> except it also performs online checks and gathers facts in one step.
5657
* [`patching::monitoring_solarwinds`](#patchingmonitoring_solarwinds): Creates or deletes VM snapshots on targets in VMware.
5758
* [`patching::ordered_groups`](#patchingordered_groups): Takes a set of targets then groups and sorts them by the <code>patching_order</code> var set on the target.
@@ -60,6 +61,7 @@
6061
* [`patching::pre_update`](#patchingpre_update): Executes a custom pre-update script on each node.
6162
* [`patching::puppet_facts`](#patchingpuppet_facts): Plan thatr runs 'puppet facts' on the targets and sets them as facts on the Target objects.
6263
* [`patching::reboot_required`](#patchingreboot_required): Querys a targets operating system to determine if a reboot is required and then reboots the targets that require rebooting.
64+
* [`patching::set_facts`](#patchingset_facts): Sets patching facts on targets
6365
* [`patching::snapshot_vmware`](#patchingsnapshot_vmware): Creates or deletes VM snapshots on targets in VMware.
6466
* [`patching::update_history`](#patchingupdate_history): Collect update history from the results JSON file on the targets
6567

@@ -382,7 +384,7 @@ Type: Puppet Language
382384

383385
Returns an array of names, one for each target, based on the $name_property
384386

385-
#### `patching::target_names(TargetSpec $targets, Enum['name', 'uri'] $name_property)`
387+
#### `patching::target_names(TargetSpec $targets, Enum['hostname', 'name', 'uri'] $name_property)`
386388

387389
The patching::target_names function.
388390

@@ -396,7 +398,7 @@ List of targets to extract the name from
396398

397399
##### `name_property`
398400

399-
Data type: `Enum['name', 'uri']`
401+
Data type: `Enum['hostname', 'name', 'uri']`
400402

401403
Property in the Target to use as the name
402404

@@ -842,6 +844,14 @@ Name of the plan to use for executing the post-update step of the workflow.
842844

843845
Default value: `undef`
844846

847+
##### `reboot_message`
848+
849+
Data type: `Optional[String]`
850+
851+
Message displayed to the user prior to the system rebooting
852+
853+
Default value: `undef`
854+
845855
##### `reboot_strategy`
846856

847857
Data type: `Optional[Enum['only_required', 'never', 'always']]`
@@ -854,11 +864,18 @@ Determines the reboot strategy for the run.
854864

855865
Default value: `undef`
856866

857-
##### `reboot_message`
867+
##### `reboot_wait`
858868

859-
Data type: `Optional[String]`
869+
Data type: `Optional[Integer]`
860870

861-
Message displayed to the user prior to the system rebooting
871+
Time in seconds that the plan waits before continuing after a reboot. This is necessary in case one
872+
of the groups affects the availability of a previous group.
873+
Two use cases here:
874+
1. A later group is a hypervisor. In this instance the hypervisor will reboot causing the
875+
VMs to go offline and we need to wait for those child VMs to come back up before
876+
collecting history metrics.
877+
2. A later group is a linux router. In this instance maybe the patching of the linux router
878+
affects the reachability of previous hosts.
862879

863880
Default value: `undef`
864881

@@ -896,20 +913,24 @@ you can run the `patching::snapshot_vmware action=delete` sometime in the future
896913

897914
Default value: `undef`
898915

899-
##### `reboot_wait`
916+
##### `report_format`
900917

901-
Data type: `Optional[Integer]`
918+
Data type: `Optional[Enum['none', 'pretty', 'csv']]`
902919

903-
Time in seconds that the plan waits before continuing after a reboot. This is necessary in case one
904-
of the groups affects the availability of a previous group.
905-
Two use cases here:
906-
1. A later group is a hypervisor. In this instance the hypervisor will reboot causing the
907-
VMs to go offline and we need to wait for those child VMs to come back up before
908-
collecting history metrics.
909-
2. A later group is a linux router. In this instance maybe the patching of the linux router
910-
affects the reachability of previous hosts.
920+
The method of formatting the report data.
911921

912-
Default value: 300
922+
Default value: `undef`
923+
924+
##### `report_file`
925+
926+
Data type: `Optional[String]`
927+
928+
Path of the filename where the report should be written. Default = 'patching_report.csv'.
929+
If you would like to disable writing the report file, specify a value of 'disabled'.
930+
NOTE: If you're running PE, then you'll need to disable writing reports because it will
931+
fail when running from the console.
932+
933+
Default value: `undef`
913934

914935
##### `noop`
915936

@@ -1197,6 +1218,42 @@ Data type: `Optional[String]`
11971218

11981219
Default value: `undef`
11991220

1221+
### patching::get_facts
1222+
1223+
Sets patching facts on targets
1224+
1225+
#### Examples
1226+
1227+
##### Get the patching_group fact (default)
1228+
1229+
```puppet
1230+
bolt plan run patching::get_facts --targets xxx
1231+
```
1232+
1233+
##### Get different facts
1234+
1235+
```puppet
1236+
bolt plan run patching::get_facts --targets xxx names='["fact1", "fact2"]'
1237+
```
1238+
1239+
#### Parameters
1240+
1241+
The following parameters are available in the `patching::get_facts` plan.
1242+
1243+
##### `targets`
1244+
1245+
Data type: `TargetSpec`
1246+
1247+
Set of targets to run against.
1248+
1249+
##### `names`
1250+
1251+
Data type: `Variant[String, Array[String]]`
1252+
1253+
Name or list of fact names to retrieve from the targets
1254+
1255+
Default value: ['patching_group']
1256+
12001257
### patching::get_targets
12011258

12021259
A very common requirement when running individual plans from the commandline is that
@@ -1733,6 +1790,21 @@ Message displayed to the user prior to the system rebooting
17331790

17341791
Default value: 'NOTICE: This system is currently being updated.'
17351792

1793+
##### `wait`
1794+
1795+
Data type: `Integer`
1796+
1797+
Time in seconds that the plan waits before continuing after a reboot. This is necessary in case one
1798+
of the groups affects the availability of a previous group.
1799+
Two use cases here:
1800+
1. A later group is a hypervisor. In this instance the hypervisor will reboot causing the
1801+
VMs to go offline and we need to wait for those child VMs to come back up before
1802+
collecting history metrics.
1803+
2. A later group is a linux router. In this instance maybe the patching of the linux router
1804+
affects the reachability of previous hosts.
1805+
1806+
Default value: 300
1807+
17361808
##### `noop`
17371809

17381810
Data type: `Boolean`
@@ -1743,6 +1815,74 @@ will still be queried and returned.
17431815

17441816
Default value: `false`
17451817

1818+
### patching::set_facts
1819+
1820+
For Linux targets the facts will be written to <code>/etc/facter/facts.d/patching.yaml</code>.
1821+
For Windows targets the facts will be written to <code>'C:/ProgramData/PuppetLabs/facter/facts.d/patching.yaml'</code>.
1822+
1823+
The contents of the <code>patching.yaml</code> file will be overwritten by this plan.
1824+
TODO: Provide an option to merge with existing facts.
1825+
1826+
Once the facts are written, by default, the facts will be ran and uploaded to PuppetDB.
1827+
If you wish to disable this, simply set <code>upload=false</code>
1828+
1829+
#### Examples
1830+
1831+
##### Set the patching_group fact
1832+
1833+
```puppet
1834+
bolt plan run patching::set_facts --targets xxx patching_group=tuesday_night
1835+
```
1836+
1837+
##### Set the custom facts
1838+
1839+
```puppet
1840+
bolt plan run patching::set_facts --targets xxx custom_facts='{"fact1": "blah"}'
1841+
```
1842+
1843+
##### Don't upload facts to PuppetDB
1844+
1845+
```puppet
1846+
bolt plan run patching::set_facts --targets xxx patching_group=tuesday_night upload=false
1847+
```
1848+
1849+
#### Parameters
1850+
1851+
The following parameters are available in the `patching::set_facts` plan.
1852+
1853+
##### `targets`
1854+
1855+
Data type: `TargetSpec`
1856+
1857+
Set of targets to run against.
1858+
1859+
##### `patching_group`
1860+
1861+
Data type: `Optional[String]`
1862+
1863+
Name of the patching group that the targets are a member of. This will be the value for the
1864+
<code>patching_group</code> fact.
1865+
1866+
Default value: `undef`
1867+
1868+
##### `custom_facts`
1869+
1870+
Data type: `Hash`
1871+
1872+
Hash of custom facts that will be set on these targets. This can be anything you like
1873+
and will merged with the other facts above.
1874+
1875+
Default value: {}
1876+
1877+
##### `upload`
1878+
1879+
Data type: `Boolean`
1880+
1881+
After setting the facts, perform a <code>puppet facts upload</code> so the new
1882+
facts are stored in PuppetDB.
1883+
1884+
Default value: `true`
1885+
17461886
### patching::snapshot_vmware
17471887

17481888
Communicates to the vSphere API from the local Bolt control node using
@@ -1776,7 +1916,7 @@ What action to perform on the snapshots:
17761916

17771917
##### `target_name_property`
17781918

1779-
Data type: `Optional[Enum['name', 'uri']]`
1919+
Data type: `Optional[Enum['hostname', 'name', 'uri']]`
17801920

17811921
Determines what property on the Target object will be used as the VM name when
17821922
mapping the Target to a VM in vSphere.
@@ -1786,6 +1926,8 @@ mapping the Target to a VM in vSphere.
17861926
list is set as the `uri` and not the `name`, in this case `name` will be `undef`.
17871927
- `name` : use the `name` property on the Target, this is not preferred because
17881928
`name` is usually a short name or nickname.
1929+
- `hostname`: use the `hostname` value to use host component of `uri` property on the Target
1930+
this can be useful if VM name doesn't include domain name
17891931

17901932
Default value: `undef`
17911933

@@ -1883,6 +2025,14 @@ You can pass the ResultSet from that task into the `history` parameter of this
18832025
plan and we will skip retrieving the history from the targets and simply use
18842026
that data.
18852027

2028+
By default the report is also written to a file `patching_report.csv`.
2029+
If you would like to disable this you can pass in `undef` or `'disabled'` to
2030+
`report_file` parameter. You can also customize this as by specifying the
2031+
`patching_report_file` var on the target or group.
2032+
2033+
Patching format can also be customized using the inventory var `patching_report_format`
2034+
on the target or group.
2035+
18862036
#### Parameters
18872037

18882038
The following parameters are available in the `patching::update_history` plan.
@@ -1907,7 +2057,9 @@ Default value: `undef`
19072057
Data type: `Optional[String]`
19082058

19092059
Optional filename to save the formatted repot into.
1910-
If `undef` is passed, then no report file will be written.
2060+
If `undef` or `'disabled'` are passed, then no report file will be written.
2061+
NOTE: If you're running PE, then you'll need to disable writing reports because it will
2062+
fail when running from the console.
19112063

19122064
Default value: 'patching_report.csv'
19132065

0 commit comments

Comments
 (0)