diff --git a/deployability/modules/allocation/static/specs/os.yml b/deployability/modules/allocation/static/specs/os.yml index 8c6396c95e..c493f3beb2 100644 --- a/deployability/modules/allocation/static/specs/os.yml +++ b/deployability/modules/allocation/static/specs/os.yml @@ -243,9 +243,9 @@ aws: zone: us-east-1 user: centos linux-centos-8-amd64: - ami: ami-0ee534f954d1b2c98 + ami: ami-05f2b469e504202f7 zone: us-east-1 - user: centos + user: cloud-user linux-centos-8-arm64: ami: ami-012947942cdc60db6 zone: us-east-1 diff --git a/deployability/modules/provision/playbooks/wazuh/package/install/set_repo.j2 b/deployability/modules/provision/playbooks/wazuh/package/install/set_repo.j2 index e7e820f401..3f9e6de437 100755 --- a/deployability/modules/provision/playbooks/wazuh/package/install/set_repo.j2 +++ b/deployability/modules/provision/playbooks/wazuh/package/install/set_repo.j2 @@ -11,7 +11,7 @@ shell: "curl -s https://{{ 'packages.wazuh.com' if live else 'packages-dev.wazuh.com' }}/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg" - name: Add Wazuh repository - shell: "echo \"deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://{{ 'packages.wazuh.com' if live else 'packages-dev.wazuh.com' }}/{{ '4.x' if live else 'pre-release' }}/apt/" {{ 'stable' if live else 'unstable' }} main\" | tee -a /etc/apt/sources.list.d/wazuh.list" + shell: "echo \"deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://{{ 'packages.wazuh.com' if live else 'packages-dev.wazuh.com' }}/{{ '4.x' if live else 'pre-release' }}/apt/ {{ 'stable' if live else 'unstable' }} main\" | tee -a /etc/apt/sources.list.d/wazuh.list" - name: Update package information command: "apt-get update" diff --git a/deployability/modules/testing/tests/helpers/generic.py b/deployability/modules/testing/tests/helpers/generic.py index 6375bcd87c..25308fd2cc 100644 --- a/deployability/modules/testing/tests/helpers/generic.py +++ b/deployability/modules/testing/tests/helpers/generic.py @@ -176,6 +176,31 @@ def get_internal_ip_from_aws_dns(dns_name): else: return None + @staticmethod + def get_client_keys(inventory_path) -> list[dict]: + """ + Get the client keys from the client.keys file in the host. + + Args: + inventory_path (str): host's inventory path + + Returns: + list: List of dictionaries with the client keys. + """ + clients = [] + client_key = Executor.execute_command(inventory_path, f'cat {CLIENT_KEYS}') + lines = client_key.split('\n')[:-1] + for line in lines: + _id, name, address, password = line.strip().split() + client_info = { + "id": _id, + "name": name, + "address": address, + "password": password + } + clients.append(client_info) + return clients + class HostConfiguration: diff --git a/deployability/modules/testing/tests/helpers/utils.py b/deployability/modules/testing/tests/helpers/utils.py index 814d0abbd1..211ee78b8f 100644 --- a/deployability/modules/testing/tests/helpers/utils.py +++ b/deployability/modules/testing/tests/helpers/utils.py @@ -18,13 +18,13 @@ class Utils: @staticmethod - def extract_ansible_host(file_path): + def extract_ansible_host(file_path) -> str: with open(file_path, 'r') as yaml_file: inventory_data = yaml.safe_load(yaml_file) return inventory_data.get('ansible_host') @staticmethod - def check_inventory_connection(inventory_path, attempts=10, sleep=30): + def check_inventory_connection(inventory_path, attempts=10, sleep=30) -> bool: if 'manager' in inventory_path: match = re.search(r'/manager-linux-([^-]+)-([^-]+)-', inventory_path) elif 'agent' in inventory_path: diff --git a/deployability/modules/testing/tests/test_agent/test_install.py b/deployability/modules/testing/tests/test_agent/test_install.py index cf398d0b1a..72a454bbef 100644 --- a/deployability/modules/testing/tests/test_agent/test_install.py +++ b/deployability/modules/testing/tests/test_agent/test_install.py @@ -13,7 +13,7 @@ from ..helpers.utils import Utils -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -30,7 +30,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs @@ -48,19 +48,30 @@ def setup_test_environment(wazuh_params): # If there are no indexers, we choose wazuh-1 by default if not wazuh_params['indexers']: wazuh_params['indexers'].append(wazuh_params['master']) - wazuh_params['managers'] = {key: value for key, value in targets_dict.items() if key.startswith('wazuh-')} wazuh_params['agents'] = {key + '-' + re.findall(r'agent-(.*?)/', value)[0].replace('.',''): value for key, value in targets_dict.items() if key.startswith('agent')} + updated_agents = {} + for agent_name, agent_params in wazuh_params['agents'].items(): + Utils.check_inventory_connection(agent_params) + if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params): + if HostInformation.get_client_keys(agent_params) != []: + client_name = HostInformation.get_client_keys(agent_params)[0]['name'] + updated_agents[client_name] = agent_params + else: + updated_agents[agent_name] = agent_params + if updated_agents != {}: + wazuh_params['agents'] = updated_agents + def test_installation(wazuh_params): # Checking connection for manager_name, manager_params in wazuh_params['managers'].items(): Utils.check_inventory_connection(manager_params) + + # Certs creation, firewall management and Manager installation for agent_name, agent_params in wazuh_params['agents'].items(): - Utils.check_inventory_connection(agent_params) HostConfiguration.disable_firewall(agent_params) - # Certs creation, firewall management and Manager installation if HostInformation.dir_exists(wazuh_params['master'], WAZUH_ROOT): logger.info(f'Manager is already installed in {HostInformation.get_os_name_and_version_from_inventory(wazuh_params["master"])}') else: diff --git a/deployability/modules/testing/tests/test_agent/test_registration.py b/deployability/modules/testing/tests/test_agent/test_registration.py index f13f253cd2..3d15ea5e15 100644 --- a/deployability/modules/testing/tests/test_agent/test_registration.py +++ b/deployability/modules/testing/tests/test_agent/test_registration.py @@ -9,9 +9,9 @@ from ..helpers.generic import HostInformation, GeneralComponentActions, Waits from ..helpers.manager import WazuhManager, WazuhAPI from ..helpers.logger.logger import logger +from ..helpers.utils import Utils - -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -28,7 +28,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs @@ -50,6 +50,18 @@ def setup_test_environment(wazuh_params): wazuh_params['managers'] = {key: value for key, value in targets_dict.items() if key.startswith('wazuh-')} wazuh_params['agents'] = {key + '-' + re.findall(r'agent-(.*?)/', value)[0].replace('.',''): value for key, value in targets_dict.items() if key.startswith('agent')} + updated_agents = {} + for agent_name, agent_params in wazuh_params['agents'].items(): + Utils.check_inventory_connection(agent_params) + if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params): + if HostInformation.get_client_keys(agent_params) != []: + client_name = HostInformation.get_client_keys(agent_params)[0]['name'] + updated_agents[client_name] = agent_params + else: + updated_agents[agent_name] = agent_params + if updated_agents != {}: + wazuh_params['agents'] = updated_agents + def test_registration(wazuh_params): for agent_names, agent_params in wazuh_params['agents'].items(): WazuhAgent.register_agent(agent_params, wazuh_params['master']) @@ -73,7 +85,7 @@ def test_isActive(wazuh_params): assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not active by API') expected_condition_func = lambda: 'active' == WazuhAgent.get_agent_status(wazuh_api, agent_names) - Waits.dynamic_wait(expected_condition_func, cycles=10, waiting_time=20) + Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30) def test_clientKeys(wazuh_params): diff --git a/deployability/modules/testing/tests/test_agent/test_restart.py b/deployability/modules/testing/tests/test_agent/test_restart.py index e3159381a2..5d7b4b5081 100644 --- a/deployability/modules/testing/tests/test_agent/test_restart.py +++ b/deployability/modules/testing/tests/test_agent/test_restart.py @@ -5,12 +5,12 @@ import pytest import re -from ..helpers.generic import GeneralComponentActions +from ..helpers.generic import GeneralComponentActions, HostInformation from ..helpers.logger.logger import logger from ..helpers.manager import WazuhManager +from ..helpers.utils import Utils - -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -27,7 +27,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs @@ -49,6 +49,18 @@ def setup_test_environment(wazuh_params): wazuh_params['managers'] = {key: value for key, value in targets_dict.items() if key.startswith('wazuh-')} wazuh_params['agents'] = {key + '-' + re.findall(r'agent-(.*?)/', value)[0].replace('.',''): value for key, value in targets_dict.items() if key.startswith('agent')} + updated_agents = {} + for agent_name, agent_params in wazuh_params['agents'].items(): + Utils.check_inventory_connection(agent_params) + if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params): + if HostInformation.get_client_keys(agent_params) != []: + client_name = HostInformation.get_client_keys(agent_params)[0]['name'] + updated_agents[client_name] = agent_params + else: + updated_agents[agent_name] = agent_params + if updated_agents != {}: + wazuh_params['agents'] = updated_agents + def test_restart(wazuh_params): for agent_names, agent_params in wazuh_params['agents'].items(): GeneralComponentActions.component_restart(agent_params, 'wazuh-agent') diff --git a/deployability/modules/testing/tests/test_agent/test_stop.py b/deployability/modules/testing/tests/test_agent/test_stop.py index 0b88562cb3..1463862510 100644 --- a/deployability/modules/testing/tests/test_agent/test_stop.py +++ b/deployability/modules/testing/tests/test_agent/test_stop.py @@ -6,11 +6,11 @@ import re from ..helpers.agent import WazuhAgent, WazuhAPI -from ..helpers.generic import GeneralComponentActions, Waits +from ..helpers.generic import GeneralComponentActions, Waits, HostInformation from ..helpers.logger.logger import logger +from ..helpers.utils import Utils - -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -31,7 +31,7 @@ def wazuh_params(request): for agent_names, agent_params in params['agents'].items(): GeneralComponentActions.component_restart(agent_params, 'wazuh-agent') -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs @@ -53,6 +53,18 @@ def setup_test_environment(wazuh_params): wazuh_params['managers'] = {key: value for key, value in targets_dict.items() if key.startswith('wazuh-')} wazuh_params['agents'] = {key + '-' + re.findall(r'agent-(.*?)/', value)[0].replace('.',''): value for key, value in targets_dict.items() if key.startswith('agent')} + updated_agents = {} + for agent_name, agent_params in wazuh_params['agents'].items(): + Utils.check_inventory_connection(agent_params) + if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params): + if HostInformation.get_client_keys(agent_params) != []: + client_name = HostInformation.get_client_keys(agent_params)[0]['name'] + updated_agents[client_name] = agent_params + else: + updated_agents[agent_name] = agent_params + if updated_agents != {}: + wazuh_params['agents'] = updated_agents + def test_stop(wazuh_params): wazuh_api = WazuhAPI(wazuh_params['master']) for agent_names, agent_params in wazuh_params['agents'].items(): @@ -63,4 +75,4 @@ def test_stop(wazuh_params): assert not GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is still active by command') expected_condition_func = lambda: 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names) - Waits.dynamic_wait(expected_condition_func, cycles=10, waiting_time=20) + Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30) diff --git a/deployability/modules/testing/tests/test_agent/test_uninstall.py b/deployability/modules/testing/tests/test_agent/test_uninstall.py index dcfd406faf..a5d44ac154 100644 --- a/deployability/modules/testing/tests/test_agent/test_uninstall.py +++ b/deployability/modules/testing/tests/test_agent/test_uninstall.py @@ -10,9 +10,9 @@ from ..helpers.generic import HostInformation, GeneralComponentActions, Waits from ..helpers.manager import WazuhManager, WazuhAPI from ..helpers.logger.logger import logger +from ..helpers.utils import Utils - -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -29,7 +29,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs @@ -51,6 +51,18 @@ def setup_test_environment(wazuh_params): wazuh_params['managers'] = {key: value for key, value in targets_dict.items() if key.startswith('wazuh-')} wazuh_params['agents'] = {key + '-' + re.findall(r'agent-(.*?)/', value)[0].replace('.',''): value for key, value in targets_dict.items() if key.startswith('agent')} + updated_agents = {} + for agent_name, agent_params in wazuh_params['agents'].items(): + Utils.check_inventory_connection(agent_params) + if GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent') and GeneralComponentActions.hasAgentClientKeys(agent_params): + if HostInformation.get_client_keys(agent_params) != []: + client_name = HostInformation.get_client_keys(agent_params)[0]['name'] + updated_agents[client_name] = agent_params + else: + updated_agents[agent_name] = agent_params + if updated_agents != {}: + wazuh_params['agents'] = updated_agents + def test_uninstall(wazuh_params): for agent_names, agent_params in wazuh_params['agents'].items(): assert GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not Active before the installation') @@ -76,4 +88,4 @@ def test_isActive(wazuh_params): assert not GeneralComponentActions.isComponentActive(agent_params, 'wazuh-agent'), logger.error(f'{agent_names} is not inactive by command') expected_condition_func = lambda: 'disconnected' == WazuhAgent.get_agent_status(wazuh_api, agent_names) - Waits.dynamic_wait(expected_condition_func, cycles=10, waiting_time=20) + Waits.dynamic_wait(expected_condition_func, cycles=20, waiting_time=30) \ No newline at end of file diff --git a/deployability/modules/testing/tests/test_manager/test_install.py b/deployability/modules/testing/tests/test_manager/test_install.py index a175edf1ea..408d1dcd7e 100644 --- a/deployability/modules/testing/tests/test_manager/test_install.py +++ b/deployability/modules/testing/tests/test_manager/test_install.py @@ -12,7 +12,7 @@ from ..helpers.utils import Utils -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -27,7 +27,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs diff --git a/deployability/modules/testing/tests/test_manager/test_restart.py b/deployability/modules/testing/tests/test_manager/test_restart.py index 3dbdc62ce7..96268071fb 100644 --- a/deployability/modules/testing/tests/test_manager/test_restart.py +++ b/deployability/modules/testing/tests/test_manager/test_restart.py @@ -8,7 +8,7 @@ from ..helpers.logger.logger import logger -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -23,7 +23,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs diff --git a/deployability/modules/testing/tests/test_manager/test_stop.py b/deployability/modules/testing/tests/test_manager/test_stop.py index 1f8912463e..7630c40fdc 100644 --- a/deployability/modules/testing/tests/test_manager/test_stop.py +++ b/deployability/modules/testing/tests/test_manager/test_stop.py @@ -8,7 +8,7 @@ from ..helpers.logger.logger import logger -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -26,7 +26,7 @@ def wazuh_params(request): GeneralComponentActions.component_restart(worker, 'wazuh-manager') -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs diff --git a/deployability/modules/testing/tests/test_manager/test_uninstall.py b/deployability/modules/testing/tests/test_manager/test_uninstall.py index 1dd78aef04..b246d8012a 100644 --- a/deployability/modules/testing/tests/test_manager/test_uninstall.py +++ b/deployability/modules/testing/tests/test_manager/test_uninstall.py @@ -10,7 +10,7 @@ from ..helpers.logger.logger import logger -@pytest.fixture +@pytest.fixture(scope="module", autouse=True) def wazuh_params(request): wazuh_version = request.config.getoption('--wazuh_version') wazuh_revision = request.config.getoption('--wazuh_revision') @@ -25,7 +25,7 @@ def wazuh_params(request): } -@pytest.fixture(autouse=True) +@pytest.fixture(scope="module", autouse=True) def setup_test_environment(wazuh_params): targets = wazuh_params['targets'] # Clean the string and split it into key-value pairs diff --git a/deployability/modules/workflow_engine/examples/dtt1-agents-aws.yaml b/deployability/modules/workflow_engine/examples/dtt1-agents-aws.yaml new file mode 100755 index 0000000000..52e8244c87 --- /dev/null +++ b/deployability/modules/workflow_engine/examples/dtt1-agents-aws.yaml @@ -0,0 +1,142 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 + - linux-debian-10-amd64 + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: aws + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + + # Generic agent provision task + - task: "provision-install-{agent}" + description: "Provision resources for the {agent} agent." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/agent-{agent}/inventory.yaml" + - dependencies: + - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-agent + type: package + version: 4.7.3 + live: True + depends-on: + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" + foreach: + - variable: agents-os + as: agent + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "install,registration,restart,stop,uninstall" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "provision-manager-{manager-os}" + - "allocate-agent-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/examples/dtt1-agents-vagrant.yaml b/deployability/modules/workflow_engine/examples/dtt1-agents-vagrant.yaml new file mode 100755 index 0000000000..ca320a07e2 --- /dev/null +++ b/deployability/modules/workflow_engine/examples/dtt1-agents-vagrant.yaml @@ -0,0 +1,138 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 + - linux-debian-10-amd64 + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: vagrant + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + + # Generic agent provision task + - task: "provision-install-{agent}" + description: "Provision resources for the {agent} agent." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/agent-{agent}/inventory.yaml" + - dependencies: + - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-agent + type: package + version: 4.7.3 + live: True + depends-on: + - "allocate-{agent}" + - "provision-manager-{manager-os}" + foreach: + - variable: agents-os + as: agent + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "install,registration,restart,stop,uninstall" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "provision-manager-{manager-os}" + - "allocate-agent-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/examples/dtt1-managers-poc-vagrant.yaml b/deployability/modules/workflow_engine/examples/dtt1-managers-poc-vagrant.yaml index 0767e30ee5..35817f2169 100644 --- a/deployability/modules/workflow_engine/examples/dtt1-managers-poc-vagrant.yaml +++ b/deployability/modules/workflow_engine/examples/dtt1-managers-poc-vagrant.yaml @@ -49,6 +49,14 @@ tasks: - track-output: "{working-dir}/manager-linux-ubuntu-20.04-amd64/track.yaml" - label-termination-date: "1d" - label-team: "qa" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-linux-centos-7-amd64/track.yaml" diff --git a/deployability/modules/workflow_engine/examples/test.yaml b/deployability/modules/workflow_engine/examples/test.yaml new file mode 100644 index 0000000000..9003f9d297 --- /dev/null +++ b/deployability/modules/workflow_engine/examples/test.yaml @@ -0,0 +1,137 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 + - linux-debian-10-amd64 + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: vagrant + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + + # Generic agent provision task + - task: "provision-install-{agent}" + description: "Provision resources for the {agent} agent." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/agent-{agent}/inventory.yaml" + - dependencies: + - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-agent + type: package + version: 4.7.3 + live: True + depends-on: + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" + foreach: + - variable: agent-os + as: agent + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "stop,restart,uninstall" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "provision-install-{agent}" diff --git a/deployability/modules/workflow_engine/examples/dtt1-agents-aws-1.yaml b/deployability/modules/workflow_engine/examples/test/aws/test-agent-complete.yaml similarity index 73% rename from deployability/modules/workflow_engine/examples/dtt1-agents-aws-1.yaml rename to deployability/modules/workflow_engine/examples/test/aws/test-agent-complete.yaml index 3d2e2545fd..e992dfdc08 100755 --- a/deployability/modules/workflow_engine/examples/dtt1-agents-aws-1.yaml +++ b/deployability/modules/workflow_engine/examples/test/aws/test-agent-complete.yaml @@ -1,31 +1,21 @@ -# Copyright (C) 2015, Wazuh Inc. -# Created by Wazuh, Inc. . -# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 version: 0.1 description: This workflow is used to test agents deployment por DDT1 PoC variables: - agents-os: - - linux-ubuntu-18.04-amd64 - - linux-ubuntu-20.04-amd64 - - linux-ubuntu-22.04-amd64 - - linux-debian-10-amd64 - - linux-debian-11-amd64 - - linux-debian-12-amd64 + agent-os: - linux-oracle-9-amd64 - - linux-opensuse-tumbleweed-amd64 - linux-centos-7-amd64 - linux-centos-8-amd64 - linux-redhat-7-amd64 - linux-redhat-8-amd64 - linux-redhat-9-amd64 - linux-amazon-2-amd64 - manager-os: linux-redhat-8-amd64 + manager-os: linux-ubuntu-22.04-amd64 infra-provider: aws working-dir: /tmp/dtt1-poc tasks: # Unique manager allocate task - - task: "allocate-manager" + - task: "allocate-manager-{manager-os}" description: "Allocate resources for the manager." do: this: process @@ -41,6 +31,14 @@ tasks: - track-output: "{working-dir}/manager-{manager-os}/track.yaml" - label-termination-date: "1d" - label-team: "qa" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" # Unique agent allocate task - task: "allocate-agent-{agent}" @@ -62,9 +60,19 @@ tasks: foreach: - variable: agent-os as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + depends-on: + - "provision-manager-{manager-os}" # Unique manager provision task - - task: "provision-manager" + - task: "provision-manager-{manager-os}" description: "Provision the manager." do: this: process @@ -75,15 +83,16 @@ tasks: - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" - install: - component: wazuh-manager - type: package + type: assistant version: 4.7.3 live: True depends-on: - - "allocate-manager" + - "allocate-manager-{manager-os}" + # Generic agent test task - - task: "run-agent-tests" - description: "Run tests install for the agent." + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." do: this: process with: @@ -91,16 +100,15 @@ tasks: args: - modules/testing/main.py - targets: - - wazuh: "{working-dir}/manager-{manager-os}/inventory.yaml" + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" - agent: "{working-dir}/agent-{agent}/inventory.yaml" - tests: "install,registration,restart,stop,uninstall" - component: "agent" - wazuh-version: "4.7.3" - wazuh-revision: "40714" - live: "True" - depends-on: - - "allocate-agent-{agent}" - - "allocate-manager" foreach: - variable: agent-os as: agent + depends-on: + - "allocate-agent-{agent}" diff --git a/deployability/modules/workflow_engine/examples/test/aws/test-agent-restart-ins-prov.yaml b/deployability/modules/workflow_engine/examples/test/aws/test-agent-restart-ins-prov.yaml new file mode 100755 index 0000000000..ad39a8b3c5 --- /dev/null +++ b/deployability/modules/workflow_engine/examples/test/aws/test-agent-restart-ins-prov.yaml @@ -0,0 +1,143 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 + - linux-debian-10-amd64 + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: aws + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + on-error: "abort-all" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + on-error: "abort-all" + + # Generic agent provision task + - task: "provision-install-{agent}" + description: "Provision resources for the {agent} agent." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/agent-{agent}/inventory.yaml" + - dependencies: + - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-agent + type: package + version: 4.7.3 + live: True + depends-on: + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" + foreach: + - variable: agent-os + as: agent + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "restart" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "provision-install-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/examples/test/aws/test-agent-stop-ins-prov.yaml b/deployability/modules/workflow_engine/examples/test/aws/test-agent-stop-ins-prov.yaml new file mode 100755 index 0000000000..74da24139b --- /dev/null +++ b/deployability/modules/workflow_engine/examples/test/aws/test-agent-stop-ins-prov.yaml @@ -0,0 +1,143 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 + - linux-debian-10-amd64 + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-20.04-amd64 + infra-provider: aws + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + on-error: "abort-all" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + on-error: "abort-all" + + # Generic agent provision task + - task: "provision-install-{agent}" + description: "Provision resources for the {agent} agent." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/agent-{agent}/inventory.yaml" + - dependencies: + - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-agent + type: package + version: 4.7.3 + live: True + depends-on: + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" + foreach: + - variable: agent-os + as: agent + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "stop" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "provision-install-{agent}" diff --git a/deployability/modules/workflow_engine/examples/test/aws/test-agent-uninstall-ins-prov.yaml b/deployability/modules/workflow_engine/examples/test/aws/test-agent-uninstall-ins-prov.yaml new file mode 100755 index 0000000000..8ab89589d6 --- /dev/null +++ b/deployability/modules/workflow_engine/examples/test/aws/test-agent-uninstall-ins-prov.yaml @@ -0,0 +1,143 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 + - linux-debian-10-amd64 + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: aws + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + on-error: "abort-all" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + on-error: "abort-all" + + # Generic agent provision task + - task: "provision-install-{agent}" + description: "Provision resources for the {agent} agent." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/agent-{agent}/inventory.yaml" + - dependencies: + - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-agent + type: package + version: 4.7.3 + live: True + depends-on: + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" + foreach: + - variable: agent-os + as: agent + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "uninstall" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "provision-install-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-complete.yaml b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-complete.yaml new file mode 100755 index 0000000000..a2cb5a2482 --- /dev/null +++ b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-complete.yaml @@ -0,0 +1,114 @@ +version: 0.1 +description: This workflow is used to test agents deployment por DDT1 PoC +variables: + agent-os: + - linux-oracle-9-amd64 + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: vagrant + working-dir: /tmp/dtt1-poc + +tasks: + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." + do: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + foreach: + - variable: agent-os + as: agent + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/agent-{agent}/track.yaml" + depends-on: + - "provision-manager-{manager-os}" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + + + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." + do: + this: process + with: + path: python3 + args: + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "install,registration,restart,stop,uninstall" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" + foreach: + - variable: agent-os + as: agent + depends-on: + - "allocate-agent-{agent}" diff --git a/deployability/modules/workflow_engine/examples/dtt1-agents-3.yaml b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-stop-ins-prov-2.yaml similarity index 56% rename from deployability/modules/workflow_engine/examples/dtt1-agents-3.yaml rename to deployability/modules/workflow_engine/examples/test/vagrant/test-agent-stop-ins-prov-2.yaml index 079d933bac..913dbaed3d 100755 --- a/deployability/modules/workflow_engine/examples/dtt1-agents-3.yaml +++ b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-stop-ins-prov-2.yaml @@ -1,37 +1,46 @@ -# Copyright (C) 2015, Wazuh Inc. -# Created by Wazuh, Inc. . -# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 version: 0.1 description: This workflow is used to test agents deployment por DDT1 PoC variables: - agents-os: - - linux-oracle-9-amd64 - manager-os: linux-oracle-9-amd64 + agent-os: + - linux-centos-7-amd64 + - linux-centos-8-amd64 + - linux-redhat-7-amd64 + - linux-redhat-8-amd64 + - linux-redhat-9-amd64 + - linux-amazon-2-amd64 + manager-os: linux-ubuntu-22.04-amd64 infra-provider: vagrant working-dir: /tmp/dtt1-poc tasks: - # Unique manager provision task - - task: "provision-manager" - description: "Provision the manager." + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." do: this: process with: path: python3 args: - - modules/provision/main.py - - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" - - install: - - component: wazuh-manager - type: package - version: 4.7.3 - live: True - depends-on: - - "allocate-manager" + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + on-error: "abort-all" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" - # Unique manager allocate task - - task: "allocate-manager" - description: "Allocate resources for the manager." + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." do: this: process with: @@ -40,12 +49,13 @@ tasks: - modules/allocation/main.py - action: create - provider: "{infra-provider}" - - size: large - - composite-name: "{manager-os}" - - inventory-output: "{working-dir}/manager-{manager-os}" - - track-output: "{working-dir}/manager-{manager-os}" - - label-termination-date: "1d" - - label-team: "QA" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + foreach: + - variable: agent-os + as: agent cleanup: this: process with: @@ -53,7 +63,26 @@ tasks: args: - modules/allocation/main.py - action: delete - - track-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + on-error: "abort-all" # Generic agent provision task - task: "provision-install-{agent}" @@ -67,44 +96,37 @@ tasks: - inventory: "{working-dir}/agent-{agent}/inventory.yaml" - dependencies: - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" - - agent: "{working-dir}/agent-{agent}/inventory.yaml" - install: - component: wazuh-agent type: package version: 4.7.3 live: True depends-on: - - "allocate-{agent}" - - "provision-manager" + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" foreach: - - variable: agents-os + - variable: agent-os as: agent - # Generic agent allocate task - - task: "allocate-{agent}" - description: "Allocate resources for the {agent} agent." + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." do: this: process with: path: python3 args: - - modules/allocation/main.py - - action: create - - provider: "{infra-provider}" - - size: small - - composite-name: "{agent}" - - inventory-output: "{working-dir}/agent-{agent}" - - track-output: "{working-dir}/agent-{agent}" - - label-termination-date: "1d" - - label-team: "QA" - cleanup: - this: process - with: - path: python3 - args: - - modules/allocation/main.py - - action: delete - - track-output: "{working-dir}/agent-{agent}/inventory.yaml" + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "stop" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" foreach: - - variable: agents-os - as: agent \ No newline at end of file + - variable: agent-os + as: agent + depends-on: + - "provision-install-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/examples/dtt1-agents-2.yaml b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-stop-ins-prov.yaml similarity index 57% rename from deployability/modules/workflow_engine/examples/dtt1-agents-2.yaml rename to deployability/modules/workflow_engine/examples/test/vagrant/test-agent-stop-ins-prov.yaml index f86e78078b..e61393c256 100755 --- a/deployability/modules/workflow_engine/examples/dtt1-agents-2.yaml +++ b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-stop-ins-prov.yaml @@ -1,40 +1,47 @@ -# Copyright (C) 2015, Wazuh Inc. -# Created by Wazuh, Inc. . -# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 version: 0.1 description: This workflow is used to test agents deployment por DDT1 PoC variables: - agents-os: + agent-os: + - linux-ubuntu-18.04-amd64 + - linux-ubuntu-20.04-amd64 - linux-ubuntu-22.04-amd64 - linux-debian-10-amd64 - - linux-oracle-8-amd64 - - linux-redhat-8-amd64 - manager-os: linux-centos-8-amd64 - infra-provider: aws + - linux-debian-11-amd64 + - linux-debian-12-amd64 + - linux-oracle-9-amd64 + manager-os: linux-ubuntu-22.04-amd64 + infra-provider: vagrant working-dir: /tmp/dtt1-poc tasks: - # Unique manager provision task - - task: "provision-manager" - description: "Provision the manager." + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." do: this: process with: path: python3 args: - - modules/provision/main.py - - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" - - install: - - component: wazuh-manager - type: assistant - version: 4.7.3 - live: True - depends-on: - - "allocate-manager" + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + on-error: "abort-all" + cleanup: + this: process + with: + path: python3 + args: + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" - # Unique manager allocate task - - task: "allocate-manager" - description: "Allocate resources for the manager." + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." do: this: process with: @@ -43,12 +50,13 @@ tasks: - modules/allocation/main.py - action: create - provider: "{infra-provider}" - - size: large - - composite-name: "{manager-os}" - - inventory-output: "{working-dir}/manager-{manager-os}" - - track-output: "{working-dir}/manager-{manager-os}" - - label-termination-date: "1d" - - label-team: "QA" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + foreach: + - variable: agent-os + as: agent cleanup: this: process with: @@ -56,7 +64,26 @@ tasks: args: - modules/allocation/main.py - action: delete - - track-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + on-error: "abort-all" # Generic agent provision task - task: "provision-install-{agent}" @@ -70,44 +97,37 @@ tasks: - inventory: "{working-dir}/agent-{agent}/inventory.yaml" - dependencies: - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" - - agent: "{working-dir}/agent-{agent}/inventory.yaml" - install: - component: wazuh-agent type: package version: 4.7.3 live: True depends-on: - - "allocate-{agent}" - - "provision-manager" + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" foreach: - - variable: agents-os + - variable: agent-os as: agent - # Generic agent allocate task - - task: "allocate-{agent}" - description: "Allocate resources for the {agent} agent." + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." do: this: process with: path: python3 args: - - modules/allocation/main.py - - action: create - - provider: "{infra-provider}" - - size: small - - composite-name: "{agent}" - - inventory-output: "{working-dir}/agent-{agent}" - - track-output: "{working-dir}/agent-{agent}" - - label-termination-date: "1d" - - label-team: "QA" - cleanup: - this: process - with: - path: python3 - args: - - modules/allocation/main.py - - action: delete - - track-output: "{working-dir}/agent-{agent}/inventory.yaml" + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "stop" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" foreach: - - variable: agents-os - as: agent \ No newline at end of file + - variable: agent-os + as: agent + depends-on: + - "provision-install-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/examples/dtt1-agents-poc.yaml b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-uninstall-ins-prov.yaml similarity index 65% rename from deployability/modules/workflow_engine/examples/dtt1-agents-poc.yaml rename to deployability/modules/workflow_engine/examples/test/vagrant/test-agent-uninstall-ins-prov.yaml index 39b1aeac06..5568493d71 100755 --- a/deployability/modules/workflow_engine/examples/dtt1-agents-poc.yaml +++ b/deployability/modules/workflow_engine/examples/test/vagrant/test-agent-uninstall-ins-prov.yaml @@ -1,71 +1,55 @@ -# Copyright (C) 2015, Wazuh Inc. -# Created by Wazuh, Inc. . -# This program is a free software; you can redistribute it and/or modify it under the terms of GPLv2 version: 0.1 description: This workflow is used to test agents deployment por DDT1 PoC variables: - agents-os: + agent-os: - linux-ubuntu-18.04-amd64 - linux-ubuntu-20.04-amd64 + - linux-ubuntu-22.04-amd64 - linux-debian-10-amd64 - linux-debian-11-amd64 - linux-debian-12-amd64 - linux-oracle-9-amd64 - - linux-opensuse-tumbleweed-amd64 - linux-centos-7-amd64 - linux-centos-8-amd64 - linux-redhat-7-amd64 - linux-redhat-8-amd64 + - linux-redhat-9-amd64 - linux-amazon-2-amd64 - manager-os: linux-centos-8-amd64 + manager-os: linux-ubuntu-22.04-amd64 infra-provider: vagrant working-dir: /tmp/dtt1-poc tasks: - # Generic agent test task - - task: "run-agent-tests-uninstall-{agent}" - description: "Run tests uninstall for the {agent} agent." + # Unique manager allocate task + - task: "allocate-manager-{manager-os}" + description: "Allocate resources for the manager." do: this: process with: path: python3 args: - - modules/testing/main.py - - inventory: "{working-dir}/agent-{agent}/inventory.yaml" - - dependencies: - - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" - - tests: "uninstall" - - component: "agent" - - wazuh-version: "4.7.1" - - wazuh-revision: "40709" - depends-on: - - "run-agent-tests-{agent}" - - "provision-uninstall-{agent}" - foreach: - - variable: agents-os - as: agent - - # Unique manager provision task - - task: "provision-manager" - description: "Provision the manager." - do: + - modules/allocation/main.py + - action: create + - provider: "{infra-provider}" + - size: large + - composite-name: "{manager-os}" + - inventory-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" + - label-termination-date: "1d" + - label-team: "qa" + on-error: "abort-all" + cleanup: this: process with: path: python3 args: - - modules/provision/main.py - - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" - - install: - - component: wazuh-manager - type: assistant - version: 4.7.3 - live: False - depends-on: - - "allocate-manager" + - modules/allocation/main.py + - action: delete + - track-output: "{working-dir}/manager-{manager-os}/track.yaml" - # Unique manager allocate task - - task: "allocate-manager" - description: "Allocate resources for the manager." + # Unique agent allocate task + - task: "allocate-agent-{agent}" + description: "Allocate resources for the agent." do: this: process with: @@ -74,12 +58,15 @@ tasks: - modules/allocation/main.py - action: create - provider: "{infra-provider}" - - size: large - - composite-name: "{manager-os}" - - inventory-output: "{working-dir}/manager-{manager-os}" - - track-output: "{working-dir}/manager-{manager-os}" + - size: small + - composite-name: "{agent}" + - inventory-output: "{working-dir}/agent-{agent}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" - label-termination-date: "1d" - - label-team: "QA" + - label-team: "qa" + foreach: + - variable: agent-os + as: agent cleanup: this: process with: @@ -87,7 +74,26 @@ tasks: args: - modules/allocation/main.py - action: delete - - track-output: "{working-dir}/manager-{manager-os}/inventory.yaml" + - track-output: "{working-dir}/agent-{agent}/track.yaml" + + # Unique manager provision task + - task: "provision-manager-{manager-os}" + description: "Provision the manager." + do: + this: process + with: + path: python3 + args: + - modules/provision/main.py + - inventory: "{working-dir}/manager-{manager-os}/inventory.yaml" + - install: + - component: wazuh-manager + type: assistant + version: 4.7.3 + live: True + depends-on: + - "allocate-manager-{manager-os}" + on-error: "abort-all" # Generic agent provision task - task: "provision-install-{agent}" @@ -101,44 +107,37 @@ tasks: - inventory: "{working-dir}/agent-{agent}/inventory.yaml" - dependencies: - manager: "{working-dir}/manager-{manager-os}/inventory.yaml" - - agent: "{working-dir}/agent-{agent}/inventory.yaml" - install: - component: wazuh-agent - type: assistant + type: package version: 4.7.3 live: True depends-on: - - "allocate-{agent}" - - "provision-manager" + - "allocate-agent-{agent}" + - "provision-manager-{manager-os}" foreach: - - variable: agents-os + - variable: agent-os as: agent - # Generic agent allocate task - - task: "allocate-{agent}" - description: "Allocate resources for the {agent} agent." + # Generic agent test task + - task: "run-agent-{agent}-tests" + description: "Run tests install for the agent {agent}." do: this: process with: path: python3 args: - - modules/allocation/main.py - - action: create - - provider: "{infra-provider}" - - size: small - - composite-name: "{agent}" - - inventory-output: "{working-dir}/agent-{agent}" - - track-output: "{working-dir}/agent-{agent}" - - label-termination-date: "1d" - - label-team: "QA" - cleanup: - this: process - with: - path: python3 - args: - - modules/allocation/main.py - - action: delete - - track-output: "{working-dir}/agent-{agent}/inventory.yaml" + - modules/testing/main.py + - targets: + - wazuh-1: "{working-dir}/manager-{manager-os}/inventory.yaml" + - agent: "{working-dir}/agent-{agent}/inventory.yaml" + - tests: "uninstall" + - component: "agent" + - wazuh-version: "4.7.3" + - wazuh-revision: "40714" + - live: "True" foreach: - - variable: agents-os + - variable: agent-os as: agent + depends-on: + - "provision-install-{agent}" \ No newline at end of file diff --git a/deployability/modules/workflow_engine/workflow_processor.py b/deployability/modules/workflow_engine/workflow_processor.py index 85d531c53d..dfbf4610c9 100755 --- a/deployability/modules/workflow_engine/workflow_processor.py +++ b/deployability/modules/workflow_engine/workflow_processor.py @@ -364,6 +364,7 @@ def run(self) -> None: dag = DAG(self.task_collection) logger.info("Execution plan: %s", json.dumps(dag.get_execution_plan(), indent=2)) + except Exception as e: logger.error("Error in Workflow: %s", e)