Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/logstash_plugin/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Check if logstash-plugin is available
12 ansible.builtin.stat:
13 path: /usr/share/logstash/bin/logstash-plugin
14 register: logstash_plugin_bin
15
16 - name: Run logstash_plugin tests
17 when: logstash_plugin_bin.stat.exists
18 block:
19 - name: Install plugin without version (should succeed)
20 community.general.logstash_plugin:
21 name: logstash-filter-dissect
22 state: present
23 register: install_no_version
24
25 - name: Assert plugin installed
26 ansible.builtin.assert:
27 that:
28 - install_no_version is changed
29
30 - name: Install same plugin again (idempotency)
31 community.general.logstash_plugin:
32 name: logstash-filter-dissect
33 state: present
34 register: install_no_version_again
35
36 - name: Assert idempotency without version
37 ansible.builtin.assert:
38 that:
39 - install_no_version_again is not changed
40
41 - name: Remove plugin for version test
42 community.general.logstash_plugin:
43 name: logstash-filter-dissect
44 state: absent
45
46 - name: Install plugin with specific version
47 community.general.logstash_plugin:
48 name: logstash-filter-dissect
49 state: present
50 version: "3.2.0"
51 register: install_with_version
52
53 - name: Assert plugin with version installed
54 ansible.builtin.assert:
55 that:
56 - install_with_version is changed
57
58 - name: Verify command has correct argument order
59 ansible.builtin.assert:
60 that:
61 # The cmd output should show --version before plugin name
62 - "'--version' in install_with_version.cmd"
63 - "'3.2.0' in install_with_version.cmd"
64 - "install_with_version.cmd.index('--version') < install_with_version.cmd.index('logstash-filter-dissect')"
65
66 always:
67 - name: Cleanup - remove test plugin
68 community.general.logstash_plugin:
69 name: logstash-filter-dissect
70 state: absent
71 when: logstash_plugin_bin.stat.exists
72 ignore_errors: true