Skip to content

Commit

Permalink
Debug workspace content
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcr01 committed Aug 28, 2024
1 parent 81033b9 commit f70c612
Show file tree
Hide file tree
Showing 2 changed files with 202 additions and 11 deletions.
24 changes: 13 additions & 11 deletions .github/workflows/Test_installation_assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ jobs:
repository: wazuh/wazuh-automation
ref: ${{ inputs.AUTOMATION_REFERENCE }}
token: ${{ secrets.GH_CLONE_TOKEN }}

- name: Debug workspace
run: ls $GITHUB_WORKSPACE

- name: Checkout code
uses: actions/checkout@v4

- name: Debug workspace
run: ls $GITHUB_WORKSPACE

- name: Install and set allocator requirements
run: pip3 install -r deployability/deps/requirements.txt
Expand All @@ -136,19 +145,12 @@ jobs:
--label-team devops --label-termination-date 1d
sed 's/: */=/g' /tmp/allocator_instance/inventory.yml > /tmp/allocator_instance/inventory_mod.yml
sed -i 's/-o StrictHostKeyChecking=no/\"-o StrictHostKeyChecking=no\"/g' /tmp/allocator_instance/inventory_mod.yml
source /tmp/allocator_instance/inventory_mod.yml
echo "[gha_instance]" > /tmp/allocator_instance/inventory_ansible.ini
echo "$ansible_host ansible_port=$ansible_port ansible_user=$ansible_user ansible_ssh_private_key_file=$ansible_ssh_private_key_file ansible_ssh_common_args='$ansible_ssh_common_args'" >> /tmp/allocator_instance/inventory_ansible.ini
echo "::add-mask::$ansible_host"
echo "::add-mask::$ansible_port"
echo "::add-mask::$ansible_user"
echo "::add-mask::$ansible_ssh_private_key_file"
echo "::add-mask::$ansible_ssh_common_args"
cat "/tmp/allocator_instance/inventory_mod.yml" >> $GITHUB_ENV;
cat /tmp/allocator_instance/inventory_ansible.ini
echo "[gha_instance]" > /tmp/allocator_instance/inventory
echo "$ansible_host ansible_port=$ansible_port ansible_user=$ansible_user ansible_ssh_private_key_file=$ansible_ssh_private_key_file ansible_ssh_common_args='$ansible_ssh_common_args'" >> /tmp/allocator_instance/inventory
- name: Delete allocated VM
if: always() && steps.allocator_instance.outcome == 'success'
run: python3 deployability/modules/allocation/main.py --action delete --track-output /tmp/allocator_instance/track.yml
189 changes: 189 additions & 0 deletions .github/workflows/ansible-playbooks/provision.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
---
- hosts: all
become: true
vars:
script_path: "{{ tmp_path }}/unattended_installer"
script_name: "wazuh-install.sh"
rpm_deps:
- git
- python3
- python3-pip
- openssl
- tar
apt_deps:
- git
- software-properties-common
- gnupg2
pip_deps:
- attrs==21.1.0
- importlib-metadata==4.8.2
- iniconfig==1.1.1
- packaging==21.3
- pluggy==1.0.0
- py==1.11.0
- pyparsing==3.0.6
- toml==0.10.2
- typing-extensions==4.0.0
- pytest==6.2.5
- pyyaml
- requests
- setuptools
- beautifulsoup4
- urllib3==1.26.6

tasks:
- name: Make tmp folder directory
file:
path: "{{ tmp_path }}"
state: directory

- name: Install main deps block
block:

- name: Install required dependencies DNF
dnf:
name: "{{ rpm_deps }}"
state: present
when: ansible_pkg_mgr == "dnf"

# ---------------------------------------------------------------------

- name: Install required dependencies YUM
yum:
name: "{{ rpm_deps }}"
state: present
when: ansible_pkg_mgr == "yum"

# ---------------------------------------------------------------------

- name: Install required dependencies APT
apt:
name: "{{ apt_deps }}"
state: present
update_cache: yes
when: ansible_pkg_mgr == "apt"
when:
- install_deps is defined
- install_deps == true

- name: Install Python and pip
block:

# ---------------------------------------------------------------------
# Ubuntu --------------------------------------------------------------

- name: Set up Python 3.9 repository
apt_repository:
repo: 'ppa:deadsnakes/ppa'
when:
- ansible_pkg_mgr == "apt"
- ansible_distribution == "Ubuntu"

- name: Install Python3.9 on Ubuntu Jammy
apt:
name:
- python3.9
- python3.9-distutils
state: present
update_cache: yes
when:
- ansible_pkg_mgr == "apt"
- ansible_distribution == "Ubuntu"
- ansible_distribution_release == "jammy"

- name: Change Python link Ubuntu Jammy
command: ln -sf /usr/bin/python3.9 /usr/bin/python3
when:
- ansible_pkg_mgr == "apt"
- ansible_distribution == "Ubuntu"
- ansible_distribution_release == "jammy"

- name: Change Python link Ubuntu Xenial
command: ln -sf /usr/local/bin/python3.8 /usr/bin/python3
when:
- ansible_pkg_mgr == "apt"
- ansible_distribution == "Ubuntu"
- ansible_distribution_release == "xenial"

# ---------------------------------------------------------------------
# Pip installation ----------------------------------------------------

- stat:
path: /usr/bin/pip3
register: stat_pip3
when:
- ansible_pkg_mgr == "apt"

- name: Install pip Ubuntu\Debian
shell: curl https://bootstrap.pypa.io/get-pip.py | python3 -
when:
- ansible_pkg_mgr == "apt"
- stat_pip3.stat.exists == False
- ansible_distribution_release != "xenial"
- ansible_distribution_release != "focal"
- ansible_distribution_release != "bionic"

- name: Install pip Ubuntu Xenial
shell: curl https://bootstrap.pypa.io/get-pip.py | python3 -
when:
- ansible_pkg_mgr == "apt"
- stat_pip3.stat.exists == False
- ansible_distribution_release == "xenial"

when:
- install_python is defined
- install_python == true

# No version specified in pyyaml due to Xenial error.
- name: Install pytest
command: pip3 install {{ item }}
with_items: "{{ pip_deps }}"
when:
- install_pip_deps is defined
- install_pip_deps == true

- name: Clone installation assistant git repository
git:
repo: "{{ repository }}"
dest: "{{ tmp_path }}"
version: "{{ packages_reference }}"
depth: 1
force: true

- name: Generate unattended
command: "bash {{ tmp_path }}/unattended_installer/builder.sh -i -d"

- name: Change pre-release repository to selected one
command: "sed -i 's|pre-release|{{ pkg_repository }}|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

- name: Change wazuh rpm revision to generic one
command: "sed -i 's|wazuh_revision_rpm=.*|wazuh_revision_rpm=\"*\"|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

- name: Change wazuh deb revision to generic one
command: "sed -i 's|wazuh_revision_deb=.*|wazuh_revision_deb=\"*\"|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

- name: Change indexer rpm revision to generic one
command: "sed -i 's|indexer_revision_rpm=.*|indexer_revision_rpm=\"*\"|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

- name: Change indexer deb revision to generic one
command: "sed -i 's|indexer_revision_deb=.*|indexer_revision_deb=\"*\"|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

- name: Change dashboard rpm revision to generic one
command: "sed -i 's|dashboard_revision_rpm=.*|dashboard_revision_rpm=\"*\"|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

- name: Change dashboard deb revision to generic one
command: "sed -i 's|dashboard_revision_deb=.*|dashboard_revision_deb=\"*\"|g' {{ script_name }}"
args:
chdir: "{{ script_path }}"

0 comments on commit f70c612

Please sign in to comment.