wazuh / qa-system-framework

GNU General Public License v2.0
1 stars 3 forks source link

HostManager: Include method to run ansible playbook directly to a host #37

Closed Rebits closed 1 year ago

Rebits commented 1 year ago

Description

The HostManager class enables the execution of low-level tasks on remote hosts. It leverages the testinfra framework for performing these tasks remotely. However, it would be beneficial to introduce a new method that utilizes the ansible-runner module, allowing the direct execution of playbooks within the environment.

This additional method would greatly assist in migrating system tests for installation and upgrades to the new framework. Furthermore, it would prove invaluable for handling more intricate tasks whenever the tests demand it.

Design

The proposed method can be defined as follows:

def run_playbook(playbook_path: str, str, extra_vars):
    runner = ansible_runner.run(
        playbook=playbook_path,
        inventory=self.inventory_path,
        extravars=extra_vars,
    )
    return runner.rc == 0

Note: The inventory used should be the one provided in the HostManager constructor.

Warning: It may be necessary to implement a method that handles exceptions in case the playbook fails, enhancing the readability of the error messages.

BelenValdivia commented 1 year ago

31/05/2023

BelenValdivia commented 1 year ago

05/06/2023

BelenValdivia commented 1 year ago

06/06/2023

BelenValdivia commented 1 year ago

21/06/2023