mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-17 01:11:28 +00:00
Bump version of main to 12.0.0; execute announced deprecations (#10883)
* Bump version to 12.0.0. * Remove deprecated modules and plugins. * state is now required. * Change default of prepend_hash from auto to never. * Remove support for force=''. * Always delegate 'debug'. * Remove ignore_value_none and ctx_ignore_none parameters. * Remove parameters on_success and on_failure. * Update BOTMETA. * Adjust docs reference. * Forgot required=True. * Fix changelog fragment. * Adjust unit tests. * Fix changelog. Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
f34842b7b2
commit
0b72737cab
22 changed files with 43 additions and 901 deletions
|
|
@ -1,176 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2016, Jiangge Zhang <tonyseek@gmail.com>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
module: bearychat
|
||||
short_description: Send BearyChat notifications
|
||||
description:
|
||||
- The M(community.general.bearychat) module sends notifications to U(https://bearychat.com) using the Incoming Robot integration.
|
||||
deprecated:
|
||||
removed_in: 12.0.0
|
||||
why: Chat service is no longer available.
|
||||
alternative: There is none.
|
||||
author: "Jiangge Zhang (@tonyseek)"
|
||||
extends_documentation_fragment:
|
||||
- community.general.attributes
|
||||
attributes:
|
||||
check_mode:
|
||||
support: none
|
||||
diff_mode:
|
||||
support: none
|
||||
options:
|
||||
url:
|
||||
type: str
|
||||
description:
|
||||
- BearyChat WebHook URL. This authenticates you to the bearychat service. It looks like
|
||||
V(https://hook.bearychat.com/=ae2CF/incoming/e61bd5c57b164e04b11ac02e66f47f60).
|
||||
required: true
|
||||
text:
|
||||
type: str
|
||||
description:
|
||||
- Message to send.
|
||||
markdown:
|
||||
description:
|
||||
- If V(true), text is parsed as markdown.
|
||||
default: true
|
||||
type: bool
|
||||
channel:
|
||||
type: str
|
||||
description:
|
||||
- Channel to send the message to. If absent, the message goes to the default channel selected by the O(url).
|
||||
attachments:
|
||||
type: list
|
||||
elements: dict
|
||||
description:
|
||||
- Define a list of attachments. For more information, see
|
||||
U(https://github.com/bearyinnovative/bearychat-tutorial/blob/master/robots/incoming.md#attachments).
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
- name: Send notification message via BearyChat
|
||||
local_action:
|
||||
module: bearychat
|
||||
url: |
|
||||
https://hook.bearychat.com/=ae2CF/incoming/e61bd5c57b164e04b11ac02e66f47f60
|
||||
text: "{{ inventory_hostname }} completed"
|
||||
|
||||
- name: Send notification message via BearyChat all options
|
||||
local_action:
|
||||
module: bearychat
|
||||
url: |
|
||||
https://hook.bearychat.com/=ae2CF/incoming/e61bd5c57b164e04b11ac02e66f47f60
|
||||
text: "{{ inventory_hostname }} completed"
|
||||
markdown: false
|
||||
channel: "#ansible"
|
||||
attachments:
|
||||
- title: "Ansible on {{ inventory_hostname }}"
|
||||
text: "May the Force be with you."
|
||||
color: "#ffffff"
|
||||
images:
|
||||
- http://example.com/index.png
|
||||
"""
|
||||
|
||||
RETURN = r"""
|
||||
msg:
|
||||
description: Execution result.
|
||||
returned: success
|
||||
type: str
|
||||
sample: "OK"
|
||||
"""
|
||||
|
||||
try:
|
||||
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlunparse
|
||||
HAS_URLPARSE = True
|
||||
except Exception:
|
||||
HAS_URLPARSE = False
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.urls import fetch_url
|
||||
|
||||
|
||||
def build_payload_for_bearychat(module, text, markdown, channel, attachments):
|
||||
payload = {}
|
||||
if text is not None:
|
||||
payload['text'] = text
|
||||
if markdown is not None:
|
||||
payload['markdown'] = markdown
|
||||
if channel is not None:
|
||||
payload['channel'] = channel
|
||||
if attachments is not None:
|
||||
payload.setdefault('attachments', []).extend(
|
||||
build_payload_for_bearychat_attachment(
|
||||
module, item.get('title'), item.get('text'), item.get('color'),
|
||||
item.get('images'))
|
||||
for item in attachments)
|
||||
payload = 'payload=%s' % module.jsonify(payload)
|
||||
return payload
|
||||
|
||||
|
||||
def build_payload_for_bearychat_attachment(module, title, text, color, images):
|
||||
attachment = {}
|
||||
if title is not None:
|
||||
attachment['title'] = title
|
||||
if text is not None:
|
||||
attachment['text'] = text
|
||||
if color is not None:
|
||||
attachment['color'] = color
|
||||
if images is not None:
|
||||
target_images = attachment.setdefault('images', [])
|
||||
if not isinstance(images, (list, tuple)):
|
||||
images = [images]
|
||||
for image in images:
|
||||
if isinstance(image, dict) and 'url' in image:
|
||||
image = {'url': image['url']}
|
||||
elif hasattr(image, 'startswith') and image.startswith('http'):
|
||||
image = {'url': image}
|
||||
else:
|
||||
module.fail_json(
|
||||
msg="BearyChat doesn't have support for this kind of "
|
||||
"attachment image")
|
||||
target_images.append(image)
|
||||
return attachment
|
||||
|
||||
|
||||
def do_notify_bearychat(module, url, payload):
|
||||
response, info = fetch_url(module, url, data=payload)
|
||||
if info['status'] != 200:
|
||||
url_info = urlparse(url)
|
||||
obscured_incoming_webhook = urlunparse(
|
||||
(url_info.scheme, url_info.netloc, '[obscured]', '', '', ''))
|
||||
module.fail_json(
|
||||
msg=" failed to send %s to %s: %s" % (
|
||||
payload, obscured_incoming_webhook, info['msg']))
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(argument_spec={
|
||||
'url': dict(type='str', required=True, no_log=True),
|
||||
'text': dict(type='str'),
|
||||
'markdown': dict(default=True, type='bool'),
|
||||
'channel': dict(type='str'),
|
||||
'attachments': dict(type='list', elements='dict'),
|
||||
})
|
||||
|
||||
if not HAS_URLPARSE:
|
||||
module.fail_json(msg='urlparse is not installed')
|
||||
|
||||
url = module.params['url']
|
||||
text = module.params['text']
|
||||
markdown = module.params['markdown']
|
||||
channel = module.params['channel']
|
||||
attachments = module.params['attachments']
|
||||
|
||||
payload = build_payload_for_bearychat(
|
||||
module, text, markdown, channel, attachments)
|
||||
do_notify_bearychat(module, url, payload)
|
||||
|
||||
module.exit_json(msg="OK")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright (c) 2012, Michael DeHaan <michael.dehaan@gmail.com>
|
||||
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = r"""
|
||||
module: facter
|
||||
short_description: Runs the discovery program C(facter) on the remote system
|
||||
description:
|
||||
- Runs the C(facter) discovery program (U(https://github.com/puppetlabs/facter)) on the remote system, returning JSON data
|
||||
that can be useful for inventory purposes.
|
||||
deprecated:
|
||||
removed_in: 12.0.0
|
||||
why: The module has been replaced by M(community.general.facter_facts).
|
||||
alternative: Use M(community.general.facter_facts) instead.
|
||||
extends_documentation_fragment:
|
||||
- community.general.attributes
|
||||
attributes:
|
||||
check_mode:
|
||||
support: none
|
||||
diff_mode:
|
||||
support: none
|
||||
options:
|
||||
arguments:
|
||||
description:
|
||||
- Specifies arguments for facter.
|
||||
type: list
|
||||
elements: str
|
||||
requirements:
|
||||
- facter
|
||||
- ruby-json
|
||||
author:
|
||||
- Ansible Core Team
|
||||
- Michael DeHaan
|
||||
"""
|
||||
|
||||
EXAMPLES = r"""
|
||||
# Example command-line invocation
|
||||
# ansible www.example.net -m facter
|
||||
|
||||
- name: Execute facter no arguments
|
||||
community.general.facter:
|
||||
|
||||
- name: Execute facter with arguments
|
||||
community.general.facter:
|
||||
arguments:
|
||||
- -p
|
||||
- system_uptime
|
||||
- timezone
|
||||
- is_virtual
|
||||
"""
|
||||
import json
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
arguments=dict(type='list', elements='str')
|
||||
)
|
||||
)
|
||||
|
||||
facter_path = module.get_bin_path(
|
||||
'facter',
|
||||
opt_dirs=['/opt/puppetlabs/bin'])
|
||||
|
||||
cmd = [facter_path, "--json"]
|
||||
if module.params['arguments']:
|
||||
cmd += module.params['arguments']
|
||||
|
||||
rc, out, err = module.run_command(cmd, check_rc=True)
|
||||
module.exit_json(**json.loads(out))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -13,7 +13,7 @@ DOCUMENTATION = r"""
|
|||
module: ohai
|
||||
short_description: Returns inventory data from I(Ohai)
|
||||
description:
|
||||
- Similar to the M(community.general.facter) module, this runs the I(Ohai) discovery program (U(https://docs.chef.io/ohai.html))
|
||||
- Similar to the M(community.general.facter_facts) module, this runs the I(Ohai) discovery program (U(https://docs.chef.io/ohai.html))
|
||||
on the remote host and returns JSON inventory data. I(Ohai) data is a bit more verbose and nested than I(facter).
|
||||
extends_documentation_fragment:
|
||||
- community.general.attributes
|
||||
|
|
|
|||
|
|
@ -43,10 +43,7 @@ options:
|
|||
force:
|
||||
description:
|
||||
- The C(opkg --force) parameter used.
|
||||
- State V("") is deprecated and will be removed in community.general 12.0.0. Please omit the parameter O(force) to obtain
|
||||
the same behavior.
|
||||
choices:
|
||||
- ""
|
||||
- "depends"
|
||||
- "maintainer"
|
||||
- "reinstall"
|
||||
|
|
@ -128,7 +125,7 @@ class Opkg(StateModuleHelper):
|
|||
argument_spec=dict(
|
||||
name=dict(aliases=["pkg"], required=True, type="list", elements="str"),
|
||||
state=dict(default="present", choices=["present", "installed", "absent", "removed"]),
|
||||
force=dict(choices=["", "depends", "maintainer", "reinstall", "overwrite", "downgrade", "space",
|
||||
force=dict(choices=["depends", "maintainer", "reinstall", "overwrite", "downgrade", "space",
|
||||
"postinstall", "remove", "checksum", "removal-of-dependent-packages"]),
|
||||
update_cache=dict(default=False, type='bool'),
|
||||
executable=dict(type="path"),
|
||||
|
|
@ -147,15 +144,6 @@ class Opkg(StateModuleHelper):
|
|||
removed="remove",
|
||||
)
|
||||
|
||||
def _force(value):
|
||||
# 12.0.0 function _force() to be removed entirely
|
||||
if value == "":
|
||||
self.deprecate('Value "" is deprecated. Simply omit the parameter "force" to prevent any --force-X argument when running opkg',
|
||||
version="12.0.0",
|
||||
collection_name="community.general")
|
||||
value = None
|
||||
return cmd_runner_fmt.as_optval("--force-")(value, ctx_ignore_none=True)
|
||||
|
||||
dir, cmd = os.path.split(self.vars.executable) if self.vars.executable else (None, "opkg")
|
||||
|
||||
self.runner = CmdRunner(
|
||||
|
|
@ -164,7 +152,7 @@ class Opkg(StateModuleHelper):
|
|||
arg_formats=dict(
|
||||
package=cmd_runner_fmt.as_list(),
|
||||
state=cmd_runner_fmt.as_map(state_map),
|
||||
force=cmd_runner_fmt.as_func(_force), # 12.0.0 replace with cmd_runner_fmt.as_optval("--force-")
|
||||
force=cmd_runner_fmt.as_optval("--force-"),
|
||||
update_cache=cmd_runner_fmt.as_bool("update"),
|
||||
version=cmd_runner_fmt.as_fixed("--version"),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ options:
|
|||
- The value V(maintenance) has been added in community.general 11.1.0.
|
||||
choices: [cleanup, offline, online, restart, maintenance]
|
||||
type: str
|
||||
required: true
|
||||
name:
|
||||
description:
|
||||
- Specify which node of the cluster you want to manage. V(null) == the cluster status itself, V(all) == check the status
|
||||
|
|
@ -74,7 +75,7 @@ class PacemakerCluster(StateModuleHelper):
|
|||
module = dict(
|
||||
argument_spec=dict(
|
||||
state=dict(type='str', choices=[
|
||||
'cleanup', 'offline', 'online', 'restart', 'maintenance']),
|
||||
'cleanup', 'offline', 'online', 'restart', 'maintenance'], required=True),
|
||||
name=dict(type='str', aliases=['node']),
|
||||
timeout=dict(type='int', default=300),
|
||||
force=dict(type='bool', default=True)
|
||||
|
|
@ -106,13 +107,6 @@ class PacemakerCluster(StateModuleHelper):
|
|||
collection_name='community.general'
|
||||
)
|
||||
|
||||
if not self.module.params['state']:
|
||||
self.module.deprecate(
|
||||
'Parameter "state" values not set is being deprecated. Make sure to provide a value for "state"',
|
||||
version='12.0.0',
|
||||
collection_name='community.general'
|
||||
)
|
||||
|
||||
def __quit_module__(self):
|
||||
self.vars.set('value', self._get()['out'])
|
||||
|
||||
|
|
|
|||
|
|
@ -143,10 +143,10 @@ options:
|
|||
prefixes only cover a small set of the prefixes that should not have a V(#) prepended. Since an exact condition which
|
||||
O(channel) values must not have the V(#) prefix is not known, the value V(auto) for this option is deprecated in the
|
||||
future. It is best to explicitly set O(prepend_hash=always) or O(prepend_hash=never) to obtain the needed behavior.
|
||||
- The B(current default) is V(auto), which has been B(deprecated) since community.general 10.2.0. It is going to change
|
||||
to V(never) in community.general 12.0.0. To prevent deprecation warnings you can explicitly set O(prepend_hash) to
|
||||
the value you want. We suggest to only use V(always) or V(never), but not V(auto), when explicitly setting a value.
|
||||
# when the default changes in community.general 12.0.0, add deprecation for the `auto` value for 14.0.0
|
||||
- Before community.general 12.0.0, the default was V(auto). It has been deprecated since community.general 10.2.0.
|
||||
- Note that V(auto) will be deprecated in a future version.
|
||||
# TODO: Deprecate 'auto' in community.general 13.0.0
|
||||
default: never
|
||||
choices:
|
||||
- 'always'
|
||||
- 'never'
|
||||
|
|
@ -466,7 +466,7 @@ def main():
|
|||
attachments=dict(type='list', elements='dict'),
|
||||
blocks=dict(type='list', elements='dict'),
|
||||
message_id=dict(type='str'),
|
||||
prepend_hash=dict(type='str', choices=['always', 'never', 'auto']),
|
||||
prepend_hash=dict(type='str', choices=['always', 'never', 'auto'], default='never'),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
|
@ -487,15 +487,6 @@ def main():
|
|||
message_id = module.params['message_id']
|
||||
prepend_hash = module.params['prepend_hash']
|
||||
|
||||
if prepend_hash is None:
|
||||
module.deprecate(
|
||||
"The default value 'auto' for 'prepend_hash' is deprecated and will change to 'never' in community.general 12.0.0."
|
||||
" You can explicitly set 'prepend_hash' in your task to avoid this deprecation warning",
|
||||
version="12.0.0",
|
||||
collection_name="community.general",
|
||||
)
|
||||
prepend_hash = 'auto'
|
||||
|
||||
color_choices = ['normal', 'good', 'warning', 'danger']
|
||||
if color not in color_choices and not is_valid_hex_color(color):
|
||||
module.fail_json(msg="Color value specified should be either one of %r "
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue