Skip to content

add reject_category_names filter to enable rejecting updates based on single categories - #969

Open
rezemble wants to merge 1 commit into
ansible-collections:mainfrom
rezemble:main
Open

rezemble wants to merge 1 commit into
ansible-collections:mainfrom
rezemble:main

Conversation

@rezemble

Copy link
Copy Markdown
SUMMARY

This MR implements a new filter reject_category_names that allows rejecting updates based on categories.
Currently this behaviour is not possible since generating a positive allow list does not enable rejecting updates in a desired reject category that are matched through a selected category:

Example:
I want to install Security Updates but reject Office 2016
But, for example, KB5002934 has both categories.

ISSUE TYPE

Feature Pull Request

COMPONENT NAME

win_updates

@github-actions

Copy link
Copy Markdown

Docs Build 📝

Thank you for contribution!✨

The docsite for this PR is available for download as an artifact from this run:
https://github.com/ansible-collections/ansible.windows/actions/runs/44125945267

You can compare to the docs for the main branch here:
https://ansible-collections.github.io/ansible.windows/branch/main

File changes:

  • M win_updates_module.html
Click to see the diff comparison.

NOTE: only file modifications are shown here. New and deleted files are excluded.
See the file list and check the published docs to see those files.

diff --git a/home/runner/work/ansible.windows/ansible.windows/docsbuild/base/win_updates_module.html b/home/runner/work/ansible.windows/ansible.windows/docsbuild/head/win_updates_module.html
index 8cb65d0..4cfeb4e 100644
--- a/home/runner/work/ansible.windows/ansible.windows/docsbuild/base/win_updates_module.html
+++ b/home/runner/work/ansible.windows/ansible.windows/docsbuild/head/win_updates_module.html
@@ -322,6 +322,15 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </div></td>
 </tr>
 <tr class="row-even"><td><div class="ansible-option-cell">
+<div class="ansibleOptionAnchor" id="parameter-reject_category_names"></div><p class="ansible-option-title" id="ansible-collections-ansible-windows-win-updates-module-parameter-reject-category-names"><strong>reject_category_names</strong></p>
+<a class="ansibleOptionLink" href="#parameter-reject_category_names" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
+</div></td>
+<td><div class="ansible-option-cell"><p>A scalar or list of categories to reject updates from. To get the list of categories, run the module with <code class="docutils literal notranslate"><span class="pre">state=searched</span></code>. The category must be the full category string, but is case insensitive.</p>
+<p>Some possible categories are Application, Connectors, Critical Updates, Definition Updates, Developer Kits, Feature Packs, Guidance, Security Updates, Service Packs, Tools, Update Rollups, Updates, and Upgrades.</p>
+<p class="ansible-option-line"><strong class="ansible-option-default-bold">Default:</strong> <code class="ansible-option-default docutils literal notranslate"><span class="pre">[]</span></code></p>
+</div></td>
+</tr>
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-reject_list"></div><p class="ansible-option-title" id="ansible-collections-ansible-windows-win-updates-module-parameter-reject-list"><strong>reject_list</strong></p>
 <a class="ansibleOptionLink" href="#parameter-reject_list" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">list</span> / <span class="ansible-option-elements">elements=string</span></p>
 </div></td>
@@ -330,7 +339,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p>Each entry can either be the KB article or Update title as a regex according to the PowerShell regex rules.</p>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-server_selection"></div><p class="ansible-option-title" id="ansible-collections-ansible-windows-win-updates-module-parameter-server-selection"><strong>server_selection</strong></p>
 <a class="ansibleOptionLink" href="#parameter-server_selection" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -346,7 +355,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-even"><td><div class="ansible-option-cell">
+<tr class="row-odd"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-skip_optional"></div><p class="ansible-option-title" id="ansible-collections-ansible-windows-win-updates-module-parameter-skip-optional"><strong>skip_optional</strong></p>
 <a class="ansibleOptionLink" href="#parameter-skip_optional" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">boolean</span></p>
 <p><em class="ansible-option-versionadded">added in ansible.windows 1.8.0</em></p>
@@ -360,7 +369,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 </ul>
 </div></td>
 </tr>
-<tr class="row-odd"><td><div class="ansible-option-cell">
+<tr class="row-even"><td><div class="ansible-option-cell">
 <div class="ansibleOptionAnchor" id="parameter-state"></div><p class="ansible-option-title" id="ansible-collections-ansible-windows-win-updates-module-parameter-state"><strong>state</strong></p>
 <a class="ansibleOptionLink" href="#parameter-state" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
 </div></td>
@@ -428,6 +437,18 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <span class="w">    </span><span class="c1"># connection.</span>
 <span class="w">    </span><span class="nt">ansible_ssh_args</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">-o ControlMaster=no -o ServerAliveInterval=30</span>
 
+<span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Install all security, critical, and rollup updates except Office 2016 updates without a scheduled task</span>
+<span class="w">  </span><span class="nt">ansible.windows.win_updates</span><span class="p">:</span>
+<span class="w">    </span><span class="nt">category_names</span><span class="p">:</span>
+<span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">SecurityUpdates</span>
+<span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">CriticalUpdates</span>
+<span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">UpdateRollups</span>
+<span class="w">    </span><span class="nt">reject_category_names</span><span class="p">:</span>
+<span class="w">      </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Office 2016</span>
+<span class="w">  </span><span class="nt">become</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">true</span>
+<span class="w">  </span><span class="nt">become_method</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">runas</span>
+<span class="w">  </span><span class="nt">become_user</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">SYSTEM</span>
+
 <span class="p p-Indicator">-</span><span class="w"> </span><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">Install all security, critical, and rollup updates without a scheduled task</span>
 <span class="w">  </span><span class="nt">ansible.windows.win_updates</span><span class="p">:</span>
 <span class="w">    </span><span class="nt">category_names</span><span class="p">:</span>
@@ -503,7 +524,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <div class="ansibleOptionAnchor" id="return-filtered_updates"></div><p class="ansible-option-title" id="ansible-collections-ansible-windows-win-updates-module-return-filtered-updates"><strong>filtered_updates</strong></p>
 <a class="ansibleOptionLink" href="#return-filtered_updates" title="Permalink to this return value"></a><p class="ansible-option-type-line"><span class="ansible-option-type">dictionary</span></p>
 </div></td>
-<td><div class="ansible-option-cell"><p>Updates that were found but were filtered based on <em>blacklist</em>, <em>whitelist</em> or <em>category_names</em>. The return value is in the same form as <em>updates</em>.</p>
+<td><div class="ansible-option-cell"><p>Updates that were found but were filtered based on <em>blacklist</em>, <em>whitelist</em>, <em>category_names</em> or <em>reject_category_names</em>. The return value is in the same form as <em>updates</em>.</p>
 <p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> success</p>
 <p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-option-sample docutils literal notranslate"><span class="pre">&quot;see</span> <span class="pre">the</span> <span class="pre">updates</span> <span class="pre">return</span> <span class="pre">value&quot;</span></code></p>
 </div></td>
@@ -514,7 +535,7 @@ To check whether it is installed, run <code class="code docutils literal notrans
 <p><em class="ansible-option-versionadded">added in ansible.windows 1.7.0</em></p>
 </div></td>
 <td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell"><p>A list of reasons why the update has been filtered.</p>
-<p>Can be <code class="docutils literal notranslate"><span class="pre">accept_list</span></code>, <code class="docutils literal notranslate"><span class="pre">reject_list</span></code>, <code class="docutils literal notranslate"><span class="pre">hidden</span></code>, <code class="docutils literal notranslate"><span class="pre">category_names</span></code>, or <code class="docutils literal notranslate"><span class="pre">skip_optional</span></code>.</p>
+<p>Can be <code class="docutils literal notranslate"><span class="pre">accept_list</span></code>, <code class="docutils literal notranslate"><span class="pre">reject_list</span></code>, <code class="docutils literal notranslate"><span class="pre">hidden</span></code>, <code class="docutils literal notranslate"><span class="pre">category_names</span></code>, <code class="docutils literal notranslate"><span class="pre">reject_category_names</span></code> or <code class="docutils literal notranslate"><span class="pre">skip_optional</span></code>.</p>
 <p class="ansible-option-line"><strong class="ansible-option-returned-bold">Returned:</strong> success</p>
 <p class="ansible-option-line ansible-option-sample"><strong class="ansible-option-sample-bold">Sample:</strong> <code class="ansible-option-sample docutils literal notranslate"><span class="pre">[&quot;category_names&quot;,</span> <span class="pre">&quot;accept_list&quot;]</span></code></p>
 </div></td>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant