|
| 1 | +# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates |
| 2 | +# |
| 3 | +# Permission is hereby granted, free of charge, to any person obtaining a copy of |
| 4 | +# this software and associated documentation files (the "Software"), to deal in |
| 5 | +# the Software without restriction, including without limitation the rights to |
| 6 | +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of |
| 7 | +# the Software, and to permit persons to whom the Software is furnished to do so, |
| 8 | +# subject to the following conditions: |
| 9 | +# |
| 10 | +# The above copyright notice and this permission notice shall be included in all |
| 11 | +# copies or substantial portions of the Software. |
| 12 | +# |
| 13 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS |
| 15 | +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR |
| 16 | +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 17 | +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 18 | +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 19 | +# |
| 20 | +# SPDX-License-Identifier: MIT |
| 21 | + |
| 22 | +from __future__ import absolute_import, division, print_function |
| 23 | + |
| 24 | + |
| 25 | +__metaclass__ = type |
| 26 | + |
| 27 | +from ansible.utils.display import Display |
| 28 | +from ansible.plugins.action import ActionBase |
| 29 | + |
| 30 | +display = Display() |
| 31 | + |
| 32 | + |
| 33 | +class ActionModule(ActionBase): |
| 34 | + |
| 35 | + def run(self, tmp=None, task_vars=None): |
| 36 | + # self._supports_async = True |
| 37 | + results = super(ActionModule, self).run(tmp, task_vars) |
| 38 | + results['failed'] = False |
| 39 | + |
| 40 | + all_tags = self._task.args['all_tags'] |
| 41 | + play_tags = self._task.args['play_tags'] |
| 42 | + |
| 43 | + if 'all' in play_tags: |
| 44 | + return results |
| 45 | + |
| 46 | + for tag in play_tags: |
| 47 | + if tag not in all_tags: |
| 48 | + results['failed'] = True |
| 49 | + results['msg'] = "Tag '{0}' not found in list of supported tags".format(tag) |
| 50 | + results['supported_tags'] = all_tags |
| 51 | + |
| 52 | + return results |
0 commit comments