Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/4940 dtt1 provision multiple dependencies inventories #4946

Conversation

QU3B1M
Copy link
Member

@QU3B1M QU3B1M commented Feb 8, 2024

Description

This PR implements the multi dependencies option for the provision module. It can be used when we provision a worker of a cluster that requires info from the master or a complete installation where we require the IPs of the dashboard, servers & indexers.

Usage

Now the provision module accepts the optional argument dependencies which is a list of dicts or a dict. Example:

  • list: [{'manager': 'path/to/inventory.yaml'}, {'agent': 'path/to/inventory.yaml'}]
  • dict: {'manager': 'path/to/inventory.yaml', 'agent': 'path/to/inventory.yaml'}

So, implemented in a task of the workflow it looks like this:

  - task: "provision-install-{agent}"
    description: "Provision resources for the {agent} agent."
    do:
      this: process
      with:
        path: python3
        args:
          - provision.py
          - 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
            - component: curl

Note that in this task the dependency agent was declared just for testing purposes, it is not required in the real scenario.


Testing performed

  • Provision without the dependencies

    [2024-02-09 19:14:36] [INFO] WORKFLOW_ENGINE: [provision-manager] Starting task.
    argvalue {'component': 'wazuh-manager', 'type': 'package'}
    task_args ['provision.py', '--inventory=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', "--install={'component': 'wazuh-manager', 'type': 'package'}"]
    [2024-02-09 19:17:41] [INFO] WORKFLOW_ENGINE: [2024-02-09 19:14:36] [DEBUG] ANSIBLE: Rendering template dependencies.j2
    [2024-02-09 19:17:41] [INFO] WORKFLOW_ENGINE: Finish task: : provision-manager
    [2024-02-09 19:17:41] [INFO] WORKFLOW_ENGINE: [provision-manager] Finished task in 184.63 seconds.
  • Provision with dependencies

    task_args ['provision.py', '--inventory=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml', "--dependencies={'manager': '/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml'}", "--dependencies={'agent': '/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml'}", "--install={'component': 'wazuh-agent', 'type': 'package'}", "--install={'component': 'curl'}"]
    [2024-02-09 19:19:37] [INFO] WORKFLOW_ENGINE: [2024-02-09 19:17:41] [DEBUG] ANSIBLE: Rendering template dependencies.j2
    [2024-02-09 19:19:37] [INFO] WORKFLOW_ENGINE: Finish task: : provision-install-linux-ubuntu-20.04-amd64
    [2024-02-09 19:19:37] [INFO] WORKFLOW_ENGINE: [provision-install-linux-ubuntu-20.04-amd64] Finished task in 116.50 seconds.

@QU3B1M QU3B1M self-assigned this Feb 8, 2024
@QU3B1M QU3B1M linked an issue Feb 8, 2024 that may be closed by this pull request
4 tasks
@QU3B1M QU3B1M marked this pull request as ready for review February 9, 2024 22:21
Copy link
Member

@pro-akim pro-akim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Notes

Small changes requested

parser.add_argument("--inventory-agent", default=None, help="Inventory with agent host information")
parser.add_argument("--inventory-manager", default=None, help="Inventory with manager host information")
parser.add_argument("--inventory", default=None, help="Inventory with agent host information")
parser.add_argument("--dependencies", action='append',required=False)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dependencies do not have help information.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated on commit 2962694

@@ -12,7 +12,7 @@ class ComponentType(ABC):
component (str): The component to be provisioned.
type (str): The type of the component.
version (str): The version of the component.
manager_ip (str): The manager IP to be used in the provision.
dependencies (str): The manager IP to be used in the provision.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would change to: Dependencies that will be used as a manager.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated on commit 2962694

@QU3B1M QU3B1M requested a review from pro-akim February 19, 2024 13:14
Base automatically changed from 4852-dtt1-iteration-3-provision-module-improvements-and-fixes to enhancement/4495-DTT1 February 19, 2024 17:45
Copy link
Member

@pro-akim pro-akim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Notes

Some conflicts are present.

…-fixes' into enhancement/4940-dtt1-provision-multiple-dependencies-inventories
@pro-akim
Copy link
Member

Review Notes

LGTM, conflicts were solved.

@fcaffieri fcaffieri merged commit b57e3fc into enhancement/4495-DTT1 Feb 21, 2024
@fcaffieri fcaffieri deleted the enhancement/4940-dtt1-provision-multiple-dependencies-inventories branch February 21, 2024 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DTT1 - Iteration 3 - Provision - Multiple dependencies inventories in InputPayload
3 participants