diff --git a/.github/workflows/packages_builder_ami.yaml b/.github/workflows/packages_builder_ami.yaml index 54a36e2..3d23ef6 100644 --- a/.github/workflows/packages_builder_ami.yaml +++ b/.github/workflows/packages_builder_ami.yaml @@ -1,13 +1,13 @@ -run-name: Build AMI - Wazuh virtual machines branch ${{ inputs.WAZUH_VIRTUAL_MACHINES_REFERENCE }} - Launched by @${{ github.actor }} +run-name: Build AMI - Wazuh virtual machines ${{ inputs.id }} - Branch ${{ github.ref_name }} - Launched by @${{ github.actor }} name: Build AMI on: workflow_dispatch: inputs: - WAZUH_VIRTUAL_MACHINES_REFERENCE: - description: 'Branch or tag of the wazuh-virtual-machines repository where the workflow will be triggered' - required: true - default: '4.10.0' + id: + description: "ID used to identify the workflow uniquely." + type: string + required: false WAZUH_AUTOMATION_REFERENCE: description: 'Branch or tag of the wazuh-automation repository' required: true @@ -26,8 +26,10 @@ on: - -vv - -vvv - -vvvv - SUFFIX_AMI: - description: 'Suffix to add to the AMI name, must begin with "_" without quotes. For pre-relase, use -1' + AMI_REVISION: + description: | + 'For AMI candidates must be a number, e,g: -1.' + 'To build a development AMI, use another revision format, e.g: -dev' required: false default: '-1' DESTROY: @@ -35,10 +37,16 @@ on: description: 'Destroy the base instance after the AMI is created' required: false default: true + workflow_call: + inputs: + id: + type: string + required: false env: COMPOSITE_NAME: "linux-amazon-2-ami-amd64" ALLOCATOR_PATH: "/tmp/allocatorvm_ami" + PLAYBOOKS_PATH: "${{ github.workspace }}/ami/playbooks/" permissions: id-token: write @@ -53,8 +61,6 @@ jobs: - name: Checkout wazuh/wazuh-virtual-machines repository uses: actions/checkout@v4 - with: - ref: ${{ inputs.WAZUH_VIRTUAL_MACHINES_REFERENCE }} - name: Configure aws credentials uses: aws-actions/configure-aws-credentials@v3 @@ -110,7 +116,7 @@ jobs: - name: Run Ansible playbook to install Wazuh components run: | - ansible-playbook -i ${{ env.ALLOCATOR_PATH }}/inventory_ansible.ini ami/playbooks/build_ami_packages.yaml --extra-vars "installation_assistant_reference=${{ inputs.WAZUH_INSTALLATION_ASSISTANT_REFERENCE }}" ${{ inputs.VERBOSITY }} + ansible-playbook -i ${{ env.ALLOCATOR_PATH }}/inventory_ansible.ini ${{ env.PLAYBOOKS_PATH }}/build_ami_packages.yaml --extra-vars "installation_assistant_reference=${{ inputs.WAZUH_INSTALLATION_ASSISTANT_REFERENCE }}" ${{ inputs.VERBOSITY }} - name: Stop instance run: | @@ -145,7 +151,7 @@ jobs: - name: Build AMI from instance if: success() run: | - AMI_NAME="Wazuh_v${{ env.WAZUH_VERSION }}${{ inputs.SUFFIX_AMI }}" + AMI_NAME="Wazuh_v${{ env.WAZUH_VERSION }}${{ inputs.AMI_REVISION }}" aws ec2 create-image --instance-id ${{ env.identifier }} --name "$AMI_NAME" --no-reboot AMI_ID=$(aws ec2 describe-images --filters "Name=name,Values=$AMI_NAME" --query 'Images[*].ImageId' --output text) echo "AMI_ID=$AMI_ID" >> $GITHUB_ENV @@ -180,7 +186,7 @@ jobs: - name: Tag AMI if: success() run: | - aws ec2 create-tags --resources ${{ env.AMI_ID }} --tags Key=Name,Value="Wazuh_v${{ env.WAZUH_VERSION }}${{ inputs.SUFFIX_AMI }}" + aws ec2 create-tags --resources ${{ env.AMI_ID }} --tags Key=Name,Value="Wazuh_v${{ env.WAZUH_VERSION }}${{ inputs.AMI_REVISION }}" - name: Delete allocated VM if: always() && steps.alloc_vm_ami.outcome == 'success' && inputs.DESTROY == true diff --git a/CHANGELOG.md b/CHANGELOG.md index d850c48..af99f06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,17 +6,18 @@ All notable changes to this project will be documented in this file. ### Added - Added builder_OVA workflow ([#32](https://github.com/wazuh/wazuh-virtual-machines/pull/32)) - - Added packages_builder_ami workflow header ([#31](https://github.com/wazuh/wazuh-virtual-machines/pull/31)) - - Added the OVA to the wazuh-virtual-machines repository without changes ([#30](https://github.com/wazuh/wazuh-virtual-machines/pull/30)) - (OVA) ### Changed + - Adapted repository selection in OVA generation ([#58](https://github.com/wazuh/wazuh-virtual-machines/pull/58)) +- Modify the AMI GHA workflow with the new Installation Assistant logic ([#55](https://github.com/wazuh/wazuh-virtual-machines/pull/55)) - Migrated the OVA construction files to the wazuh-virtual-machines repository ([#29](https://github.com/wazuh/wazuh-virtual-machines/pull/29)) - (OVA) ### Fixed +- Deleted dashboard logs cleanup in OVA local build([#57](https://github.com/wazuh/wazuh-virtual-machines/pull/57)) - Fix typos and add news inputs in the AMI workflow header ([#35](https://github.com/wazuh/wazuh-virtual-machines/pull/35)) ### Deleted diff --git a/ami/playbooks/build_ami_packages.yaml b/ami/playbooks/build_ami_packages.yaml index 6be7848..dd210e0 100644 --- a/ami/playbooks/build_ami_packages.yaml +++ b/ami/playbooks/build_ami_packages.yaml @@ -109,7 +109,7 @@ until: clone_result is success - name: Build install script - shell: "bash {{ installation_assistant_directory }}/{{ builder_script_name }} -i -d" + shell: "bash {{ installation_assistant_directory }}/{{ builder_script_name }} -i" - name: Build password change script shell: "bash {{ installation_assistant_directory }}/{{ builder_script_name }} -p" @@ -166,7 +166,7 @@ ############################### - name: Run {{ installer_script_name }} script - command: "bash {{ installation_assistant_directory }}/{{ installer_script_name }} -a -v -o" + command: "bash {{ installation_assistant_directory }}/{{ installer_script_name }} -a -v -o -d" ############################### # Post-install stage diff --git a/ova/assets/postProvision.sh b/ova/assets/postProvision.sh index 1340a19..295c09b 100644 --- a/ova/assets/postProvision.sh +++ b/ova/assets/postProvision.sh @@ -25,7 +25,6 @@ find /var/log/ -type f -exec bash -c 'cat /dev/null > {}' \; find /var/ossec/logs -type f -execdir sh -c 'cat /dev/null > "$1"' _ {} \; find /var/log/wazuh-indexer -type f -execdir sh -c 'cat /dev/null > "$1"' _ {} \; find /var/log/filebeat -type f -execdir sh -c 'cat /dev/null > "$1"' _ {} \; -find /usr/share/wazuh-dashboard/data/wazuh/logs -type f -execdir sh -c 'cat /dev/null > "$1"' _ {} \; history -c shutdown -r now > /dev/null 2>&1