mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-02-04 07:51:50 +00:00
Logstash plugin version fix (#11440)
* logstash_plugin: fix argument order when using version parameter * logstash_plugin: add integration tests * logstash_plugin: add changelog fragment
This commit is contained in:
parent
c0df366471
commit
53e1e86bcc
4 changed files with 82 additions and 1 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
bugfixes:
|
||||||
|
- logstash_plugin - fix argument order when using ``version`` parameter. The plugin name must come after options like ``--version`` for the ``logstash-plugin`` CLI to work correctly (https://github.com/ansible-collections/community.general/issues/10745, https://github.com/ansible-collections/community.general/pull/11440).
|
||||||
|
|
@ -94,7 +94,7 @@ def parse_error(string):
|
||||||
|
|
||||||
|
|
||||||
def install_plugin(module, plugin_bin, plugin_name, version, proxy_host, proxy_port):
|
def install_plugin(module, plugin_bin, plugin_name, version, proxy_host, proxy_port):
|
||||||
cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"], plugin_name]
|
cmd_args = [plugin_bin, PACKAGE_STATE_MAP["present"]]
|
||||||
|
|
||||||
if version:
|
if version:
|
||||||
cmd_args.extend(["--version", version])
|
cmd_args.extend(["--version", version])
|
||||||
|
|
@ -102,6 +102,8 @@ def install_plugin(module, plugin_bin, plugin_name, version, proxy_host, proxy_p
|
||||||
if proxy_host and proxy_port:
|
if proxy_host and proxy_port:
|
||||||
cmd_args.extend([f"-DproxyHost={proxy_host}", f"-DproxyPort={proxy_port}"])
|
cmd_args.extend([f"-DproxyHost={proxy_host}", f"-DproxyPort={proxy_port}"])
|
||||||
|
|
||||||
|
cmd_args.append(plugin_name)
|
||||||
|
|
||||||
cmd = " ".join(cmd_args)
|
cmd = " ".join(cmd_args)
|
||||||
|
|
||||||
if module.check_mode:
|
if module.check_mode:
|
||||||
|
|
|
||||||
5
tests/integration/targets/logstash_plugin/aliases
Normal file
5
tests/integration/targets/logstash_plugin/aliases
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# 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
|
||||||
|
|
||||||
|
unsupported
|
||||||
72
tests/integration/targets/logstash_plugin/tasks/main.yml
Normal file
72
tests/integration/targets/logstash_plugin/tasks/main.yml
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
---
|
||||||
|
####################################################################
|
||||||
|
# WARNING: These are designed specifically for Ansible tests #
|
||||||
|
# and should not be used as examples of how to write Ansible roles #
|
||||||
|
####################################################################
|
||||||
|
|
||||||
|
# Copyright (c) Ansible Project
|
||||||
|
# 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
|
||||||
|
|
||||||
|
- name: Check if logstash-plugin is available
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: /usr/share/logstash/bin/logstash-plugin
|
||||||
|
register: logstash_plugin_bin
|
||||||
|
|
||||||
|
- name: Run logstash_plugin tests
|
||||||
|
when: logstash_plugin_bin.stat.exists
|
||||||
|
block:
|
||||||
|
- name: Install plugin without version (should succeed)
|
||||||
|
community.general.logstash_plugin:
|
||||||
|
name: logstash-filter-dissect
|
||||||
|
state: present
|
||||||
|
register: install_no_version
|
||||||
|
|
||||||
|
- name: Assert plugin installed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install_no_version is changed
|
||||||
|
|
||||||
|
- name: Install same plugin again (idempotency)
|
||||||
|
community.general.logstash_plugin:
|
||||||
|
name: logstash-filter-dissect
|
||||||
|
state: present
|
||||||
|
register: install_no_version_again
|
||||||
|
|
||||||
|
- name: Assert idempotency without version
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install_no_version_again is not changed
|
||||||
|
|
||||||
|
- name: Remove plugin for version test
|
||||||
|
community.general.logstash_plugin:
|
||||||
|
name: logstash-filter-dissect
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Install plugin with specific version
|
||||||
|
community.general.logstash_plugin:
|
||||||
|
name: logstash-filter-dissect
|
||||||
|
state: present
|
||||||
|
version: "3.2.0"
|
||||||
|
register: install_with_version
|
||||||
|
|
||||||
|
- name: Assert plugin with version installed
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- install_with_version is changed
|
||||||
|
|
||||||
|
- name: Verify command has correct argument order
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
# The cmd output should show --version before plugin name
|
||||||
|
- "'--version' in install_with_version.cmd"
|
||||||
|
- "'3.2.0' in install_with_version.cmd"
|
||||||
|
- "install_with_version.cmd.index('--version') < install_with_version.cmd.index('logstash-filter-dissect')"
|
||||||
|
|
||||||
|
always:
|
||||||
|
- name: Cleanup - remove test plugin
|
||||||
|
community.general.logstash_plugin:
|
||||||
|
name: logstash-filter-dissect
|
||||||
|
state: absent
|
||||||
|
when: logstash_plugin_bin.stat.exists
|
||||||
|
ignore_errors: true
|
||||||
Loading…
Add table
Add a link
Reference in a new issue