From 851c3cdad6b7280d4a1e97d0a5492bf0c8759733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Fri, 10 May 2024 12:30:55 +0200 Subject: [PATCH 1/3] Added `--instance-name` as compulsory in Vagrant deploy --- deployability/modules/allocation/README.MD | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/deployability/modules/allocation/README.MD b/deployability/modules/allocation/README.MD index 8444c1b602..cf308536cf 100644 --- a/deployability/modules/allocation/README.MD +++ b/deployability/modules/allocation/README.MD @@ -182,13 +182,13 @@ If one wishes to execute the allocaation module without installing the Workflow - Local deployment (Vagrant) ```bash - python3 modules/allocation/main.py --action create --provider '{{ vagrant }}' --size '{{ large }}' --composite-name '{{ composite-name }}' --inventory-output '{{ inventory }}' --track-output '{{ track }}' + python3 modules/allocation/main.py --action create --provider '{{ vagrant }}' --size '{{ large }}' --composite-name '{{ composite-name }}' --instance-name '{{ name }}' --inventory-output '{{ inventory }}' --track-output '{{ track }}' ``` Example: ```bash - python3 modules/allocation/main.py --action create --provider vagrant --size large --composite-name linux-ubuntu-22.04-amd64 --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" + python3 modules/allocation/main.py --action create --provider vagrant --size large --composite-name linux-ubuntu-22.04-amd64 --instance-name "ubuntu_2204_amd_large" --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" ``` - AWS deployment @@ -209,6 +209,16 @@ If one wishes to execute the allocaation module without installing the Workflow python3 modules/allocation/main.py --action create --provider aws --size large --composite-name linux-ubuntu-22.04-amd64 --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" --label-termination-date "2024-03-20 21:00:00" --label-team devops ``` + Example 2: + ```bash + python3 modules/allocation/main.py --action create --provider aws --size small --composite-name linux-ubuntu-22.04-amd64 --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" --label-termination-date "3d" --label-team devops --label-issue "https://github.com/wazuh/internal-devel-requests/issues/1115" + ``` + + Example 3: + ```bash + python3 modules/allocation/main.py --action create --provider aws --size small --composite-name linux-ubuntu-22.04-amd64 --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" --label-termination-date "1d" --label-team devops --instance-name "ubuntu_2204_amd_large" + ``` + 2. Delete While in wazuh-qa/deployability @@ -282,7 +292,7 @@ If one wishes to execute the allocaation module without installing the Workflow This argument it is mandatory for AWS deploy, allows you to define the date on which the machine can be deleted. The allowed values are **1d** (where the **1** refers to the number of days the machine is needed) or with the following format **"2024-03-20 21:00:00"** - --instance-name - This argument allows us to define a custom name for the instance, if this argument is not used, the instance name is defined by other parameters entered, such as --label-issue or --composite-name. + This argument allows us to define a custom name for the instance. It is compulsory for the Vagrant deploy. For the AWS deploy, if this argument is not used, the instance name is defined by other parameters entered, such as --label-issue or --composite-name. --- ### Technical documentation From 6fe1ba024d5747b3826af14a6411e7e3f943a905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Fri, 10 May 2024 15:19:12 +0200 Subject: [PATCH 2/3] Improved `--instance-name` and `label-issue` documentation --- deployability/modules/allocation/README.MD | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/deployability/modules/allocation/README.MD b/deployability/modules/allocation/README.MD index cf308536cf..3eb014aade 100644 --- a/deployability/modules/allocation/README.MD +++ b/deployability/modules/allocation/README.MD @@ -182,15 +182,22 @@ If one wishes to execute the allocaation module without installing the Workflow - Local deployment (Vagrant) ```bash - python3 modules/allocation/main.py --action create --provider '{{ vagrant }}' --size '{{ large }}' --composite-name '{{ composite-name }}' --instance-name '{{ name }}' --inventory-output '{{ inventory }}' --track-output '{{ track }}' + python3 modules/allocation/main.py --action create --provider '{{ vagrant }}' --size '{{ large }}' --composite-name '{{ composite-name }}' --instance-name '{{ name }}' --inventory-output '{{ inventory }}' --track-output '{{ track }}' ``` + >Note: In the case of Vagrant it is mandatory to specify either --instance-name or --label-issue parameters. + Example: ```bash python3 modules/allocation/main.py --action create --provider vagrant --size large --composite-name linux-ubuntu-22.04-amd64 --instance-name "ubuntu_2204_amd_large" --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" ``` + Example 2: + ```bash + python3 modules/allocation/main.py --action create --provider vagrant --size micro --composite-name linux-ubuntu-22.04-amd64 --label-issue "https://github.com/wazuh/internal-devel-requests/issues/1115" --inventory-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/inventory.yaml" --track-output "/tmp/dtt1-poc/agent-linux-ubuntu-22.04-amd64/track.yaml" + ``` + - AWS deployment ```bash @@ -283,7 +290,7 @@ If one wishes to execute the allocaation module without installing the Workflow This argument allows us to define in which directory the files referring to the VM will be generated. By default, **/tmp/wazuh-qa** - --label-issue - This argument is only used in the case of AWS and is not mandatory, it allows us to create a label to reference the created instance to an issue on GitHub. It has to be a GitHub URL of a Wazuh repository, for example: **https://github.com/wazuh/internal-devel-requests/issues/1008** + This argument is mandatory for the Vagrant deploy if the **--instance-name** is not specified. For AWS deploy, it is not mandatory. It allows to create a label to reference the created instance to an issue on GitHub. It has to be a GitHub URL of a Wazuh repository, for example: **https://github.com/wazuh/internal-devel-requests/issues/1008** - --label-team This argument it is mandatory for AWS deploy, allows you to set the team that owns the VM to be able to track it. The valid options are: **qa**, **core**, **framework**, **devops**, **frontend**, **operations**, **cloud**, **threat-intel**, **marketing**, **documentation** @@ -292,7 +299,7 @@ If one wishes to execute the allocaation module without installing the Workflow This argument it is mandatory for AWS deploy, allows you to define the date on which the machine can be deleted. The allowed values are **1d** (where the **1** refers to the number of days the machine is needed) or with the following format **"2024-03-20 21:00:00"** - --instance-name - This argument allows us to define a custom name for the instance. It is compulsory for the Vagrant deploy. For the AWS deploy, if this argument is not used, the instance name is defined by other parameters entered, such as --label-issue or --composite-name. + This argument is mandatory for the Vagrant if the **--label-issue** is not specified. It allows us to define a custom name for the instance. In AWS deploy, if this argument is not used, the instance name is defined by other parameters entered, such as --label-issue or --composite-name. --- ### Technical documentation From 7df50d15c914e3e1b75cf0023015e99937bf4657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Correa=20Rodr=C3=ADguez?= Date: Fri, 10 May 2024 15:24:23 +0200 Subject: [PATCH 3/3] Improved parameter error message --- deployability/modules/allocation/vagrant/provider.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployability/modules/allocation/vagrant/provider.py b/deployability/modules/allocation/vagrant/provider.py index 5c86f29327..59bd155921 100644 --- a/deployability/modules/allocation/vagrant/provider.py +++ b/deployability/modules/allocation/vagrant/provider.py @@ -58,7 +58,7 @@ def _create_instance(cls, base_dir: Path, params: CreationPayload, config: Vagra repository = cls.generate_repository_name(str(issue_name.group(1))) name = repository + "-" + str(re.search(r'(\d+)$', issue).group(1)) + "-" + str(params.composite_name.split("-")[1]) + "-" + str(params.composite_name.split("-")[2]) else: - raise ValueError("Instance name or issue label is required.") + raise ValueError("Either --instance-name or --label-issue parameter is required.") instance_id = name + "-" + str(random.randint(0000, 9999)) # Create the instance directory.