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

Added venv to AMI and OVA workflows #112

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/ansible_playbooks/ova_generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@

tasks:
- name: Install git
yum:
name: git
state: present
shell: sudo yum install -y git

- name: Make build directory
file:
Expand Down
25 changes: 23 additions & 2 deletions .github/workflows/builder_OVA.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,23 @@ permissions:

jobs:
build_and_run:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Install Python and create virtual environment
run: |
sudo apt-get update
sudo apt install -y python3 python3-venv
python3 -m venv ova_venv
source ova_venv/bin/activate
python3 -m pip install --upgrade pip
echo PATH=$PATH >> $GITHUB_ENV

- name: Install Ansible
run: sudo apt-get update && sudo apt install -y python3 jq sshpass && python3 -m pip install --user ansible-core==2.16 && pip install pyyaml && ansible-galaxy collection install community.general
run: |
sudo apt install -y jq sshpass
python3 -m pip install ansible-core==2.16
pip install pyyaml
ansible-galaxy collection install community.general

- name: Checkout wazuh/wazuh-virtual-machines repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -187,6 +200,10 @@ jobs:
fi
done

- name: Install Python3 in the instance
run: |
sshpass -p ${{ env.OVA_USER_PASSWORD }} ssh -o 'StrictHostKeyChecking no' ${{ env.OVA_USER }}@${{ env.ANSIBLE_HOST }} "sudo yum install -y python3"

- name: Run Ansible playbook to generate the OVA
run: |
builder_args="-i"
Expand All @@ -200,6 +217,10 @@ jobs:
builder_args='$builder_args' \
debug=yes" ${{ inputs.DEBUG }}

- name: Uninstall Python3 from the instance
run: |
sshpass -p ${{ env.OVA_USER_PASSWORD }} ssh -o 'StrictHostKeyChecking no' ${{ env.OVA_USER }}@${{ env.ANSIBLE_HOST }} "sudo yum remove -y python3"

- name: Export Instance to create OVA
run: |
EXPORT=$(aws ec2 create-instance-export-task --instance-id "${{ env.INSTANCE_ID }}" --target-environment vmware \
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/packages_builder_ami.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ permissions:

jobs:
Build_AMI:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: View parameters
run: echo "${{ toJson(inputs) }}"
Expand All @@ -79,8 +79,18 @@ jobs:
WAZUH_VERSION=$(cat VERSION)
echo WAZUH_VERSION=$WAZUH_VERSION >> $GITHUB_ENV

- name: Install Python and create virtual environment
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip
python3 -m venv ami_env
source ami_env/bin/activate
python3 -m pip install --upgrade pip
echo PATH=$PATH >> $GITHUB_ENV

- name: Install Ansible
run: sudo apt-get update && sudo apt install -y python3 && python3 -m pip install --user ansible-core==2.16
run: |
python3 -m pip install ansible-core==2.16

- name: Ansible version
run: ansible --version
Expand All @@ -95,7 +105,7 @@ jobs:

- name: Install and set allocator requirements
run: |
pip3 install -r wazuh-automation/deployability/deps/requirements.txt
python3 -m pip install -r wazuh-automation/deployability/deps/requirements.txt

- name: Execute allocator module that will create the base instance
id: alloc_vm_ami
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.

### Changed

- Added venv to AMI and OVA workflows. ([#112](https://github.com/wazuh/wazuh-virtual-machines/pull/112))
- Improvements to AMI customization script. ([#98](https://github.com/wazuh/wazuh-virtual-machines/pull/98))

### Fixed
Expand Down
Loading