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

Provision module Improvements and support actions #4883

Conversation

fcaffieri
Copy link
Member

@fcaffieri fcaffieri commented Jan 25, 2024

Related issue
#4853

Description

The following improvements were made:

  • The new parameter will be added
  • Added Jinja2 templates.
  • The new uninstall action was implemented
  • New classes were created:
  • Action class
    • Install class
    • Uninstall call
  • ComponentType class
    • Package class
    • AIO class
    • Generic class
    • Dependency class
  • Custom credentials were removed

Test

Full log
$ python3 workflow_engine.py ../modules/workflow_engine/examples/dtt1-agents-poc.yaml ../modules/workflow_engine/schema.json
[2024-01-26 10:40:26] [INFO] Executing tasks in parallel.
[2024-01-26 10:40:26] [INFO] [allocate-manager] Starting task.
task_args ['/home/fcaffieri/repos/wazuh-qa/deployability/launchers/allocation.py', '--action=create', '--provider=vagrant', '--size=large', '--composite-name=linux-ubuntu-20.04-amd64', '--inventory-output=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', '--track-output=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/track.yaml']
[2024-01-26 10:41:19] [INFO] Creating instance at /tmp/wazuh-qa
Instance VAGRANT-3EA53D2C-9DE6-4AE9-AEB4-98A81C1885A4 created.
Instance VAGRANT-3EA53D2C-9DE6-4AE9-AEB4-98A81C1885A4 started.

Inventory file generated at /tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml

Track file generated at /tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/track.yaml

[2024-01-26 10:41:19] [INFO] Finish task: : allocate-manager
[2024-01-26 10:41:19] [INFO] [allocate-manager] Finished task in 53.13 seconds.
[2024-01-26 10:41:19] [INFO] [allocate-linux-ubuntu-20.04-amd64] Starting task.
task_args ['allocation.py', '--action=create', '--provider=vagrant', '--size=small', '--composite-name=linux-ubuntu-20.04-amd64', '--inventory-output=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml', '--track-output=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/track.yaml']
[2024-01-26 10:42:16] [INFO] Creating instance at /tmp/wazuh-qa
Instance VAGRANT-699DDC06-074A-4E34-A6C4-BFFEC1CD596D created.
Instance VAGRANT-699DDC06-074A-4E34-A6C4-BFFEC1CD596D started.

Inventory file generated at /tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml

Track file generated at /tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/track.yaml

[2024-01-26 10:42:16] [INFO] Finish task: : allocate-linux-ubuntu-20.04-amd64
[2024-01-26 10:42:16] [INFO] [allocate-linux-ubuntu-20.04-amd64] Finished task in 56.96 seconds.
[2024-01-26 10:42:16] [INFO] [provision-manager] Starting task.
argvalue {'component': 'wazuh-manager', 'type': 'package'}
task_args ['provision.py', '--inventory-manager=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', "--install={'component': 'wazuh-manager', 'type': 'package'}"]
[2024-01-26 10:43:51] [INFO] {'component': 'wazuh-manager', 'version': 'package', 'manager_ip': None, 'templates_path': 'provision/wazuh/package/install', 'templates_order': ['set_repo.j2', 'install.j2', 'register.j2', 'service.j2']}
Using /etc/ansible/ansible.cfg as config file

PLAY [127.0.0.1] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Install packages] ********************************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - -y
  - install
  - gnupg
  - apt-transport-https
  delta: '0:00:06.259655'
  end: '2024-01-26 13:42:24.046808'
  msg: ''
  rc: 0
  start: '2024-01-26 13:42:17.787153'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Reading package lists...
    Building dependency tree...
    Reading state information...
    gnupg is already the newest version (2.2.19-3ubuntu2.2).
    The following NEW packages will be installed:
      apt-transport-https
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,704 B of archives.
    After this operation, 162 kB of additional disk space will be used.
    Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.10 [1,704 B]
    Fetched 1,704 B in 4s (464 B/s)
    Selecting previously unselected package apt-transport-https.
    (Reading database ... (Reading database ... 5%(Reading database ... 10%(Reading database ... 15%(Reading database ... 20%(Reading database ... 25%(Reading database ... 30%(Reading database ... 35%(Reading database ... 40%(Reading database ... 45%(Reading database ... 50%(Reading database ... 55%(Reading database ... 60%(Reading database ... 65%(Reading database ... 70%(Reading database ... 75%(Reading database ... 80%(Reading database ... 85%(Reading database ... 90%(Reading database ... 95%(Reading database ... 100%(Reading database ... 111968 files and directories currently installed.)
    Preparing to unpack .../apt-transport-https_2.0.10_all.deb ...
    Unpacking apt-transport-https (2.0.10) ...
    Setting up apt-transport-https (2.0.10) ...
  stdout_lines: <omitted>

TASK [Install GPG key] *********************************************************
changed: [127.0.0.1] => changed=true 
  cmd: curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg
  delta: '0:00:01.287887'
  end: '2024-01-26 13:42:25.583556'
  msg: ''
  rc: 0
  start: '2024-01-26 13:42:24.295669'
  stderr: |-
    gpg: keyring '/usr/share/keyrings/wazuh.gpg' created
    gpg: directory '/root/.gnupg' created
    gpg: /root/.gnupg/trustdb.gpg: trustdb created
    gpg: key 96B3EE5F29111145: public key "Wazuh.com (Wazuh Signing Key) <[email protected]>" imported
    gpg: Total number processed: 1
    gpg:               imported: 1
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

TASK [Add Wazuh repository] ****************************************************
changed: [127.0.0.1] => changed=true 
  cmd: echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
  delta: '0:00:00.015320'
  end: '2024-01-26 13:42:25.830798'
  msg: ''
  rc: 0
  start: '2024-01-26 13:42:25.815478'
  stderr: ''
  stderr_lines: <omitted>
  stdout: deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main
  stdout_lines: <omitted>

TASK [Update package information] **********************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - update
  delta: '0:00:07.554530'
  end: '2024-01-26 13:42:33.619115'
  msg: ''
  rc: 0
  start: '2024-01-26 13:42:26.064585'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
    Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    Get:3 https://packages.wazuh.com/4.x/apt stable InRelease [17.3 kB]
    Hit:4 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
    Get:5 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3,059 kB]
    Get:6 https://packages.wazuh.com/4.x/apt stable/main amd64 Packages [39.0 kB]
    Get:7 https://packages.wazuh.com/4.x/apt stable/main i386 Packages [11.1 kB]
    Get:8 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
    Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [926 kB]
    Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [493 kB]
    Get:11 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted i386 Packages [36.8 kB]
    Get:12 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [2,619 kB]
    Get:13 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [365 kB]
    Get:14 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,158 kB]
    Get:15 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2,678 kB]
    Get:16 http://us.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [769 kB]
    Get:17 http://us.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [278 kB]
    Get:18 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [700 kB]
    Get:19 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [410 kB]
    Get:20 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [2,508 kB]
    Get:21 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [26.1 kB]
    Get:22 http://security.ubuntu.com/ubuntu focal-security/restricted i386 Packages [35.5 kB]
    Get:23 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [349 kB]
    Get:24 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse i386 Packages [8,436 B]
    Get:25 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [7,768 B]
    Get:26 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [641 kB]
    Get:27 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [933 kB]
    Get:28 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [197 kB]
    Get:29 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [23.9 kB]
    Get:30 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5,796 B]
    Fetched 18.5 MB in 6s (3,083 kB/s)
    Reading package lists...
  stdout_lines: <omitted>

TASK [Import the GPG key] ******************************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

TASK [Add Wazuh repository] ****************************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

TASK [Install the wazuh-manager] ***********************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - -y
  - install
  - wazuh-manager
  delta: '0:01:01.189407'
  end: '2024-01-26 13:43:35.073377'
  msg: ''
  rc: 0
  start: '2024-01-26 13:42:33.883970'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Reading package lists...
    Building dependency tree...
    Reading state information...
    Suggested packages:
      expect
    The following NEW packages will be installed:
      wazuh-manager
    0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded.
    Need to get 172 MB of archives.
    After this operation, 631 MB of additional disk space will be used.
    Get:1 https://packages.wazuh.com/4.x/apt stable/main amd64 wazuh-manager amd64 4.7.2-1 [172 MB]
    Fetched 172 MB in 16s (10.9 MB/s)
    Selecting previously unselected package wazuh-manager.
    (Reading database ... (Reading database ... 5%(Reading database ... 10%(Reading database ... 15%(Reading database ... 20%(Reading database ... 25%(Reading database ... 30%(Reading database ... 35%(Reading database ... 40%(Reading database ... 45%(Reading database ... 50%(Reading database ... 55%(Reading database ... 60%(Reading database ... 65%(Reading database ... 70%(Reading database ... 75%(Reading database ... 80%(Reading database ... 85%(Reading database ... 90%(Reading database ... 95%(Reading database ... 100%(Reading database ... 111972 files and directories currently installed.)
    Preparing to unpack .../wazuh-manager_4.7.2-1_amd64.deb ...
    Unpacking wazuh-manager (4.7.2-1) ...
    Setting up wazuh-manager (4.7.2-1) ...
    Processing triggers for systemd (245.4-4ubuntu3.22) ...
  stdout_lines: <omitted>

TASK [Install the wazuh-manager] ***********************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

TASK [Enable wazuh-manager service] ********************************************
changed: [127.0.0.1] => changed=true 
  cmd: systemctl daemon-reload && systemctl enable wazuh-manager
  delta: '0:00:00.373452'
  end: '2024-01-26 13:43:35.685695'
  msg: ''
  rc: 0
  start: '2024-01-26 13:43:35.312243'
  stderr: Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-manager.service → /lib/systemd/system/wazuh-manager.service.
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

TASK [Start wazuh-manager service] *********************************************
changed: [127.0.0.1] => changed=true 
  cmd: systemctl start wazuh-manager
  delta: '0:00:13.161149'
  end: '2024-01-26 13:43:49.074556'
  msg: ''
  rc: 0
  start: '2024-01-26 13:43:35.913407'
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=8    changed=7    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0   
summary
{'skipped': {'127.0.0.1': 3}, 'ok': {'127.0.0.1': 8}, 'dark': {}, 'failures': {}, 'ignored': {}, 'rescued': {}, 'processed': {'127.0.0.1': 1}, 'changed': {'127.0.0.1': 7}}

[2024-01-26 10:43:51] [INFO] Finish task: : provision-manager
[2024-01-26 10:43:51] [INFO] [provision-manager] Finished task in 95.12 seconds.
[2024-01-26 10:43:51] [INFO] [provision-install-linux-ubuntu-20.04-amd64] Starting task.
argvalue {'component': 'wazuh-agent', 'type': 'package'}
argvalue {'component': 'curl'}
task_args ['provision.py', '--inventory-agent=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml', '--inventory-manager=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', "--install={'component': 'wazuh-agent', 'type': 'package'}", "--install={'component': 'curl'}"]
[2024-01-26 10:44:34] [INFO] {'component': 'wazuh-agent', 'version': 'package', 'manager_ip': '127.0.0.1', 'templates_path': 'provision/wazuh/package/install', 'templates_order': ['set_repo.j2', 'install.j2', 'register.j2', 'service.j2']}
Using /etc/ansible/ansible.cfg as config file

PLAY [127.0.0.1] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Install packages] ********************************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - -y
  - install
  - gnupg
  - apt-transport-https
  delta: '0:00:05.268895'
  end: '2024-01-26 13:43:59.392312'
  msg: ''
  rc: 0
  start: '2024-01-26 13:43:54.123417'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Reading package lists...
    Building dependency tree...
    Reading state information...
    gnupg is already the newest version (2.2.19-3ubuntu2.2).
    The following NEW packages will be installed:
      apt-transport-https
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 1,704 B of archives.
    After this operation, 162 kB of additional disk space will be used.
    Get:1 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 apt-transport-https all 2.0.10 [1,704 B]
    Fetched 1,704 B in 3s (597 B/s)
    Selecting previously unselected package apt-transport-https.
    (Reading database ... (Reading database ... 5%(Reading database ... 10%(Reading database ... 15%(Reading database ... 20%(Reading database ... 25%(Reading database ... 30%(Reading database ... 35%(Reading database ... 40%(Reading database ... 45%(Reading database ... 50%(Reading database ... 55%(Reading database ... 60%(Reading database ... 65%(Reading database ... 70%(Reading database ... 75%(Reading database ... 80%(Reading database ... 85%(Reading database ... 90%(Reading database ... 95%(Reading database ... 100%(Reading database ... 111968 files and directories currently installed.)
    Preparing to unpack .../apt-transport-https_2.0.10_all.deb ...
    Unpacking apt-transport-https (2.0.10) ...
    Setting up apt-transport-https (2.0.10) ...
  stdout_lines: <omitted>

TASK [Install GPG key] *********************************************************
changed: [127.0.0.1] => changed=true 
  cmd: curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg
  delta: '0:00:01.200931'
  end: '2024-01-26 13:44:00.840528'
  msg: ''
  rc: 0
  start: '2024-01-26 13:43:59.639597'
  stderr: |-
    gpg: keyring '/usr/share/keyrings/wazuh.gpg' created
    gpg: directory '/root/.gnupg' created
    gpg: /root/.gnupg/trustdb.gpg: trustdb created
    gpg: key 96B3EE5F29111145: public key "Wazuh.com (Wazuh Signing Key) <[email protected]>" imported
    gpg: Total number processed: 1
    gpg:               imported: 1
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

TASK [Add Wazuh repository] ****************************************************
changed: [127.0.0.1] => changed=true 
  cmd: echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
  delta: '0:00:00.015116'
  end: '2024-01-26 13:44:01.095475'
  msg: ''
  rc: 0
  start: '2024-01-26 13:44:01.080359'
  stderr: ''
  stderr_lines: <omitted>
  stdout: deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main
  stdout_lines: <omitted>

TASK [Update package information] **********************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - update
  delta: '0:00:11.541898'
  end: '2024-01-26 13:44:12.878435'
  msg: ''
  rc: 0
  start: '2024-01-26 13:44:01.336537'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
    Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
    Hit:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
    Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3,059 kB]
    Get:5 https://packages.wazuh.com/4.x/apt stable InRelease [17.3 kB]
    Get:6 https://packages.wazuh.com/4.x/apt stable/main i386 Packages [11.1 kB]
    Get:7 https://packages.wazuh.com/4.x/apt stable/main amd64 Packages [39.0 kB]
    Get:8 http://us.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages [926 kB]
    Get:9 http://us.archive.ubuntu.com/ubuntu focal-updates/main Translation-en [493 kB]
    Get:10 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted i386 Packages [36.8 kB]
    Get:11 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [2,619 kB]
    Get:12 http://us.archive.ubuntu.com/ubuntu focal-updates/restricted Translation-en [365 kB]
    Get:13 http://us.archive.ubuntu.com/ubuntu focal-updates/universe i386 Packages [769 kB]
    Get:14 http://us.archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1,158 kB]
    Get:15 http://us.archive.ubuntu.com/ubuntu focal-updates/universe Translation-en [278 kB]
    Get:16 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse i386 Packages [8,436 B]
    Get:17 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [26.1 kB]
    Get:18 http://us.archive.ubuntu.com/ubuntu focal-updates/multiverse Translation-en [7,768 B]
    Get:19 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
    Get:20 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [2,678 kB]
    Get:21 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [700 kB]
    Get:22 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [410 kB]
    Get:23 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [2,508 kB]
    Get:24 http://security.ubuntu.com/ubuntu focal-security/restricted i386 Packages [35.5 kB]
    Get:25 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [349 kB]
    Get:26 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [641 kB]
    Get:27 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [933 kB]
    Get:28 http://security.ubuntu.com/ubuntu focal-security/universe Translation-en [197 kB]
    Get:29 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [23.9 kB]
    Get:30 http://security.ubuntu.com/ubuntu focal-security/multiverse Translation-en [5,796 B]
    Fetched 18.5 MB in 10s (1,839 kB/s)
    Reading package lists...
  stdout_lines: <omitted>

TASK [Import the GPG key] ******************************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

TASK [Add Wazuh repository] ****************************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

TASK [Install the wazuh-agent] *************************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - -y
  - install
  - wazuh-agent
  delta: '0:00:08.133592'
  end: '2024-01-26 13:44:21.286779'
  msg: ''
  rc: 0
  start: '2024-01-26 13:44:13.153187'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following NEW packages will be installed:
      wazuh-agent
    0 upgraded, 1 newly installed, 0 to remove and 52 not upgraded.
    Need to get 9,379 kB of archives.
    After this operation, 31.5 MB of additional disk space will be used.
    Get:1 https://packages.wazuh.com/4.x/apt stable/main amd64 wazuh-agent amd64 4.7.2-1 [9,379 kB]
    Preconfiguring packages ...
    Fetched 9,379 kB in 4s (2,463 kB/s)
    Selecting previously unselected package wazuh-agent.
    (Reading database ... (Reading database ... 5%(Reading database ... 10%(Reading database ... 15%(Reading database ... 20%(Reading database ... 25%(Reading database ... 30%(Reading database ... 35%(Reading database ... 40%(Reading database ... 45%(Reading database ... 50%(Reading database ... 55%(Reading database ... 60%(Reading database ... 65%(Reading database ... 70%(Reading database ... 75%(Reading database ... 80%(Reading database ... 85%(Reading database ... 90%(Reading database ... 95%(Reading database ... 100%(Reading database ... 111972 files and directories currently installed.)
    Preparing to unpack .../wazuh-agent_4.7.2-1_amd64.deb ...
    Unpacking wazuh-agent (4.7.2-1) ...
    Setting up wazuh-agent (4.7.2-1) ...
    Processing triggers for systemd (245.4-4ubuntu3.22) ...
  stdout_lines: <omitted>

TASK [Install the wazuh-agent] *************************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

TASK [Modify Wazuh manager IP in Wazuh agent] **********************************
changed: [127.0.0.1] => changed=true 
  msg: 1 replacements made
  rc: 0

TASK [Enable wazuh-agent service] **********************************************
changed: [127.0.0.1] => changed=true 
  cmd: systemctl daemon-reload && systemctl enable wazuh-agent
  delta: '0:00:00.511803'
  end: '2024-01-26 13:44:22.340109'
  msg: ''
  rc: 0
  start: '2024-01-26 13:44:21.828306'
  stderr: Created symlink /etc/systemd/system/multi-user.target.wants/wazuh-agent.service → /lib/systemd/system/wazuh-agent.service.
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

TASK [Start wazuh-agent service] ***********************************************
changed: [127.0.0.1] => changed=true 
  cmd: systemctl start wazuh-agent
  delta: '0:00:07.169565'
  end: '2024-01-26 13:44:29.725985'
  msg: ''
  rc: 0
  start: '2024-01-26 13:44:22.556420'
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=9    changed=8    unreachable=0    failed=0    skipped=3    rescued=0    ignored=0   
{'component': 'curl', 'version': 'generic', 'manager_ip': None, 'templates_path': 'provision/generic/install', 'templates_order': None}
Using /etc/ansible/ansible.cfg as config file

PLAY [127.0.0.1] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Install curl] ************************************************************
ok: [127.0.0.1] => changed=false 
  cache_update_time: 1706276651
  cache_updated: false

TASK [Install curl] ************************************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=2    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
summary
{'skipped': {'127.0.0.1': 1}, 'ok': {'127.0.0.1': 2}, 'dark': {}, 'failures': {}, 'ignored': {}, 'rescued': {}, 'processed': {'127.0.0.1': 1}, 'changed': {}}

[2024-01-26 10:44:34] [INFO] Finish task: : provision-install-linux-ubuntu-20.04-amd64
[2024-01-26 10:44:34] [INFO] [provision-install-linux-ubuntu-20.04-amd64] Finished task in 42.44 seconds.
[2024-01-26 10:44:34] [INFO] [run-agent-tests-linux-ubuntu-20.04-amd64] Starting task.
task_args ['test.py', '--inventory=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml', '--dependency=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', '--tests=install', '--component=agent', '--wazuh-version=4.7.1', '--wazuh-revision=40709']
[2024-01-26 10:44:48] [INFO] Using /etc/ansible/ansible.cfg as config file

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Create test directory] ***************************************************
changed: [127.0.0.1] => changed=true 
  gid: 0
  group: root
  mode: '0755'
  owner: root
  path: /tmp/tests
  size: 4096
  state: directory
  uid: 0

TASK [Copy files to endpoints] *************************************************
changed: [127.0.0.1] => changed=true 
  dest: /tmp/tests/
  src: /home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/testing/tests/

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
Using /etc/ansible/ansible.cfg as config file

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Test install for agent] **************************************************
fatal: [127.0.0.1]: FAILED! => changed=false 
  cmd: pytest test_agent/test_install.py -v --wazuh_version=4.7.1 --component=agent
  msg: '[Errno 2] No such file or directory: b''pytest'''
  rc: 2
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
Using /etc/ansible/ansible.cfg as config file

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Clean test directory] ****************************************************
changed: [127.0.0.1] => changed=true 
  path: /tmp/tests
  state: absent

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[2024-01-26 10:44:48] [INFO] Finish task: : run-agent-tests-linux-ubuntu-20.04-amd64
[2024-01-26 10:44:48] [INFO] [run-agent-tests-linux-ubuntu-20.04-amd64] Finished task in 14.05 seconds.
[2024-01-26 10:44:48] [INFO] [provision-uninstall-linux-ubuntu-20.04-amd64] Starting task.
argvalue {'component': 'wazuh-agent', 'type': 'package'}
task_args ['provision.py', '--inventory-agent=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml', '--inventory-manager=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', "--uninstall={'component': 'wazuh-agent', 'type': 'package'}"]
[2024-01-26 10:44:56] [INFO] {'component': 'wazuh-agent', 'version': 'package', 'manager_ip': '127.0.0.1', 'templates_path': 'provision/wazuh/package/uninstall', 'templates_order': None}
Using /etc/ansible/ansible.cfg as config file

PLAY [127.0.0.1] ***************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Uninstall the wazuh-agent] ***********************************************
changed: [127.0.0.1] => changed=true 
  cmd:
  - apt-get
  - remove
  - --purge
  - wazuh-agent
  - -y
  delta: '0:00:05.322515'
  end: '2024-01-26 13:44:54.589724'
  msg: ''
  rc: 0
  start: '2024-01-26 13:44:49.267209'
  stderr: ''
  stderr_lines: <omitted>
  stdout: |-
    Reading package lists...
    Building dependency tree...
    Reading state information...
    The following packages will be REMOVED:
      wazuh-agent*
    0 upgraded, 0 newly installed, 1 to remove and 52 not upgraded.
    After this operation, 31.5 MB disk space will be freed.
    (Reading database ... (Reading database ... 5%(Reading database ... 10%(Reading database ... 15%(Reading database ... 20%(Reading database ... 25%(Reading database ... 30%(Reading database ... 35%(Reading database ... 40%(Reading database ... 45%(Reading database ... 50%(Reading database ... 55%(Reading database ... 60%(Reading database ... 65%(Reading database ... 70%(Reading database ... 75%(Reading database ... 80%(Reading database ... 85%(Reading database ... 90%(Reading database ... 95%(Reading database ... 100%(Reading database ... 112352 files and directories currently installed.)
    Removing wazuh-agent (4.7.2-1) ...
    (Reading database ... (Reading database ... 5%(Reading database ... 10%(Reading database ... 15%(Reading database ... 20%(Reading database ... 25%(Reading database ... 30%(Reading database ... 35%(Reading database ... 40%(Reading database ... 45%(Reading database ... 50%(Reading database ... 55%(Reading database ... 60%(Reading database ... 65%(Reading database ... 70%(Reading database ... 75%(Reading database ... 80%(Reading database ... 85%(Reading database ... 90%(Reading database ... 95%(Reading database ... 100%(Reading database ... 111988 files and directories currently installed.)
    Purging configuration files for wazuh-agent (4.7.2-1) ...
    dpkg: warning: while removing wazuh-agent, directory '/usr/lib/systemd/system' not empty so not removed
    Processing triggers for systemd (245.4-4ubuntu3.22) ...
  stdout_lines: <omitted>

TASK [Uninstall the wazuh-agent] ***********************************************
skipping: [127.0.0.1] => changed=false 
  false_condition: ansible_os_family == "RedHat"
  skip_reason: Conditional result was False

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=2    changed=1    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
summary
{'skipped': {'127.0.0.1': 1}, 'ok': {'127.0.0.1': 2}, 'dark': {}, 'failures': {}, 'ignored': {}, 'rescued': {}, 'processed': {'127.0.0.1': 1}, 'changed': {'127.0.0.1': 1}}

[2024-01-26 10:44:56] [INFO] Finish task: : provision-uninstall-linux-ubuntu-20.04-amd64
[2024-01-26 10:44:56] [INFO] [provision-uninstall-linux-ubuntu-20.04-amd64] Finished task in 7.99 seconds.
[2024-01-26 10:44:56] [INFO] [run-agent-tests-uninstall-linux-ubuntu-20.04-amd64] Starting task.
task_args ['test.py', '--inventory=/tmp/dtt1-poc/agent-linux-ubuntu-20.04-amd64/inventory.yaml', '--dependency=/tmp/dtt1-poc/manager-linux-ubuntu-20.04-amd64/inventory.yaml', '--tests=uninstall', '--component=agent', '--wazuh-version=4.7.1', '--wazuh-revision=40709']
[2024-01-26 10:45:10] [INFO] Using /etc/ansible/ansible.cfg as config file

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Create test directory] ***************************************************
changed: [127.0.0.1] => changed=true 
  gid: 0
  group: root
  mode: '0755'
  owner: root
  path: /tmp/tests
  size: 4096
  state: directory
  uid: 0

TASK [Copy files to endpoints] *************************************************
changed: [127.0.0.1] => changed=true 
  dest: /tmp/tests/
  src: /home/fcaffieri/wazuh-env/wazuh-qa/deployability/modules/testing/tests/

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=3    changed=2    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   
Using /etc/ansible/ansible.cfg as config file

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Test uninstall for agent] ************************************************
fatal: [127.0.0.1]: FAILED! => changed=false 
  cmd: pytest test_agent/test_uninstall.py -v --wazuh_version=4.7.1 --component=agent
  msg: '[Errno 2] No such file or directory: b''pytest'''
  rc: 2
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
Using /etc/ansible/ansible.cfg as config file

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
ok: [127.0.0.1]

TASK [Clean test directory] ****************************************************
changed: [127.0.0.1] => changed=true 
  path: /tmp/tests
  state: absent

PLAY RECAP *********************************************************************
127.0.0.1                  : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

[2024-01-26 10:45:10] [INFO] Finish task: : run-agent-tests-uninstall-linux-ubuntu-20.04-amd64
[2024-01-26 10:45:10] [INFO] [run-agent-tests-uninstall-linux-ubuntu-20.04-amd64] Finished task in 14.29 seconds.
[2024-01-26 10:45:10] [INFO] Executing cleanup tasks.

@fcaffieri fcaffieri self-assigned this Jan 25, 2024
@fcaffieri fcaffieri linked an issue Jan 25, 2024 that may be closed by this pull request
6 tasks
@fcaffieri fcaffieri changed the base branch from 4857-dtt1-iteration-3-provision to 4852-dtt1-iteration-3-provision-module-improvements-and-fixes January 25, 2024 23:31
@fcaffieri fcaffieri requested a review from QU3B1M January 25, 2024 23:31
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

LGTM

status = install.install_component()

return status
def validateManagerIp(self, components, ip):
Copy link
Member

Choose a reason for hiding this comment

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

There is no documentation for the function


@classmethod
def validate_action(cls, values):
Copy link
Member

Choose a reason for hiding this comment

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

There is no documentation for the function


@classmethod
def validate_inventory(cls, values):
Copy link
Member

Choose a reason for hiding this comment

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

There is no documentation for the function


@validator('install', pre=True)
def validate_install(cls, install) -> Union[None, List[str]]:
Copy link
Member

Choose a reason for hiding this comment

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

There is no documentation for the function


@validator('uninstall', pre=True)
def validate_uninstall(cls, uninstall) -> Union[None, List[str]]:
Copy link
Member

Choose a reason for hiding this comment

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

There is no documentation for the function


@classmethod
def validate_install_uninstall(cls, components) -> Union[None, List[str]]:
Copy link
Member

Choose a reason for hiding this comment

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

There is no documentation for the function

deployability/modules/provision/actions.py Show resolved Hide resolved
deployability/modules/provision/provision.py Show resolved Hide resolved
Copy link
Member

@QU3B1M QU3B1M left a comment

Choose a reason for hiding this comment

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

LGTM

@QU3B1M QU3B1M merged commit 9a82f46 into 4852-dtt1-iteration-3-provision-module-improvements-and-fixes Jan 30, 2024
@QU3B1M QU3B1M deleted the 4853-dtt1-iteration-3-provision-module-uninstall-option branch January 30, 2024 17:38
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 module - Improvement support actions
3 participants