.. Reminder for header structure:
  Parts (H1)          : #################### with overline
  Chapters (H2)       : ******************** with overline
  Sections (H3)       : ====================
  Subsections (H4)    : --------------------
  Subsubsections (H5) : ^^^^^^^^^^^^^^^^^^^^
  Paragraphs (H6)     : """""""""""""""""""""

.. |date| date::

.. meta::
  :description: Updating the WAPT Agent
  :keywords: waptconsole, waptagent, wapt_deploy, WAPT, preferences, documentation, WAPT Console, Windows, Linux, macOS

#######################
Updating the WAPT Agent
#######################

.. _WAPT_Windows_Agent:

*******************
Updating on Windows
*******************

.. warning::

  **Recommendations regarding the test environment**

  The recommended method to correctly test your Wapt Agent packages is to use representative sample of hosts in your inventory.
  So the more heterogeneous your installed base of hosts, the larger your sample should be.

  This method consists of testing the installation of the Wapt Agent on as many platforms and configurations as possible,
  so to improve its reliability, before the Wapt Agent is transferred to production repositories.

  .. figure:: wapt-resources/wapt-select-maturity-on-wapt-agent.png
    :scale: 50%
    :align: center
    :alt: Select maturity on Wapt Agent

  To explain how package maturities work, you can refer to this `video for a detailed overview <https://www.youtube.com/watch?v=V-XFWzDkIUE>`_.


For each WAPT Server's :ref:`upgrade <upgrade-wapt>`, you will have to upgrade the WAPT Agents.

To do so, you have to :ref:`generate the WAPT Agent <create_WAPT_agent>` and deploy it.

After an update, when you launch WAPT Console, you must rebuild the new agent for your new version of WAPT.

Go to the url of your waptserver and download the :file:`WAPTSetup`.

Or download https://srvwapt.domain.lan/wapt/waptagent/waptsetup.exe, the only way in CSPN mode.

.. figure:: wapt-resources/srvwapt_url.png
  :scale: 60%
  :align: center
  :alt: Url of your waptserver

  Url of your waptserver

Then, install the WAPTSetup of your workstation.

When is done, launch the console. You will see the new version of WAPT in the bottom of the authentification window.

.. figure:: wapt-resources/Wapt_console_authentification.png
  :scale: 75%
  :align: center
  :alt: Wapt console authentification

  Wapt console authentification

After the console has been opened, you will see a window for create the new agent. Press :kbd:`Yes`.

.. figure:: wapt-resources/WaptAgent_version_check.png
  :align: center
  :alt: Wapt Agent version check

  Wapt Agent version check

The next window must be carefully reviewed, as it defines the baseline configuration for all your WAPT agents on Windows. 
Ensure that the embedded certificates and desired parameters for your entire infrastructure are correctly configured before proceeding.

.. figure:: wapt-resources/wapt-console_renew_waptagent.png
  :scale: 75%
  :align: center
  :alt: wapt console renew waptagent

  wapt console renew waptagent

.. note::

  It is recommended to start with a basic configuration for the agent and use configuration packages to define specific behaviors for different machines (distinguishing between workstation and server updates, etc.).

You have now updated your WAPT agent for Windows.

Ensure that the waptupgrade package is available on the machines or assigned to an Organizational Unit (OU) that includes them.

Manually
========

You can do that manually :ref:`by following this documentation on installing the WAPT Agent <install_agent>`.

Via waptupgrade
===============

While you :ref:`generate <create_WAPT_Agent>` the WAPT Agent, package named :file:`waptupgrade` is created.

This package is a standard WAPT package designed to upgrade the WAPT Agents on remote hosts.

.. hint::

  For now, :file:`waptupgrade` only works for Windows.
  Waptupgrade does not upgrade the WAPT Agent if the WAPT Server version and the WAPT Agent version are the same.

Upgrading the WAPT Agents using the :file:`waptupgrade` package is a two step process:

* First the package copies the :file:`waptsetup.exe` file on the client computer and creates a scheduled task that will run :program:`waptsetup.exe` with predefined installation flags two minutes after the creation of the scheduled task.
  At that point the package itself is installed and the inventory on the WAPT Server shows the package installation as *OK*, with the correct version installed, but the inventory will still show the old version as the WAPT Agent is not yet updated.

* After two minutes, the scheduled task starts and runs :program:`waptsetup.exe` with a predefined configuration created in the WAPT Console. 
  This new method keeps the :program:`waptsetup.exe` signed by Tranquil IT, but the WAPT Agent configuration will come from the WAPT Server.
  :program:`waptsetup.exe` shutdowns the local WAPT service, upgrades WAPT locally, and then restarts the WAPT service.
  The scheduled task is then automatically removed and the WAPT Agent starts sending back its inventory to the WAPT Server.
  From then on, the inventory on the WAPT Server will show the new version of the WAPT Agent.

.. _WAPT_Linux_MacOS_Agent:

***************************
Updating on Linux and macOS
***************************

.. warning::

  **Recommendations regarding the test environment**

  The recommended method to correctly test your Wapt Agent packages is to use representative sample of hosts in your inventory.
  So the more heterogeneous your installed base of hosts, the larger your sample should be.

  This method consists of testing the installation of the Wapt Agent on as many platforms and configurations as possible,
  so to improve its reliability, before the Wapt Agent is transferred to production repositories.

  .. figure:: wapt-resources/wapt-select-maturity-on-wapt-agent.png
    :scale: 50%
    :align: center
    :alt: Select maturity on Wapt Agent

  To explain how package maturities work, you can refer to this `video for a detailed overview <https://www.youtube.com/watch?v=V-XFWzDkIUE>`_.


For each WAPT Server's :ref:`upgrade <upgrade-wapt>`, you will have to upgrade the WAPT Agents.

To do so, you have to :ref:`generate the WAPT Agent <create_WAPT_agent>` and deploy it.

After an update, when you launch WAPT Console, you must rebuild the new agent for your new version of WAPT.

Go to the url of your waptserver and download the :file:`WAPTSetup`.

.. figure:: wapt-resources/srvwapt_url.png
  :scale: 60%
  :align: center
  :alt: Url of your waptserver

  Url of your waptserver

Then, install the WAPTSetup of your workstation.

When is done, launch the console. You will see the new version of WAPT in the bottom of the authentification window.

.. figure:: wapt-resources/Wapt_console_authentification.png
  :scale: 75%
  :align: center
  :alt: Wapt console authentification

  Wapt console authentification

Manually on the workstation
===========================

You can install manually the Linux / macOS Agent :ref:`by following this documentation on installing the WAPT Agent <install_agent>`.

Automatically with the WAPT Console
===================================

Before proceeding, ensure that the WAPT Console has an active internet connection to perform this action.

You need to click on :guilabel:`Tools`, then :guilabel:`Get and upload Agents installers to server`.

In this window, you will see various OS types and architectures. Select the one that meets your requirements.

.. figure:: wapt-resources/Update_Linux_and_Mac_Agent.png
  :scale: 75%
  :align: center
  :alt: Update Linux and Mac Agent

  Update Linux and Mac Agent

Finally click on :kbd:`Build_upload_waptupgrade`


Ensure that the waptupgrade package is available on the machines or assigned to an Organizational Unit (OU) that includes them.