distcloud/distributedcloud/scripts
Salman Rana ba5f718276 Update enroll-init logic to allow retry
This update enables enroll-init to re-run even after a prior success,
providing support for oam/passowrd reconfiguration following failures
in later enrollment stages. Changes include:

- Cloud-init cleanup is now deferred until the end of enrollment,
  enabling flexibility in the enroll-init step.
- A new RVMC mode, 'eject_image_only', has been added to strictly eject
  an inserted image. This is invoked as part of the enroll-init playbook
  to eject the seed ISO, preventing cloud-config from being reapplied
  during reboots. This is necessary since cloud-init remains enabled
  until the enrollment concludes.

Additionally, these changes have been made:
- Replace incorrect admin_password with 'sysadmin_password' from the
  payload to reconfigure the sysadmin password.
- Utilize the enroll-init playbook, separated from the install playbook
  (see dependent changes).

Background:
Cloud-init services were originally cleaned up immediately after a
successful enroll-init (OAM and password reconfiguration) to:
- Align with default cloud-init behavior: configuration applied once
  per instance.
- Prevent unintended conflicts during the enrollment process with
  'run-always' modules, such as an inserted seed ISO retriggering
  reconfiguration during later reboots.

However, this caused a limitation where, if enrollment failed after a
successful enroll-init, retries would skip enroll-init, necessitating
manual intervention for oam/password if needed.

Test Plan:
1. PASS: Verify enrollment without the admin field in the bootstrap
         values. Ensure semantic checks, and confirm
         'sysadmin_password' is used for password reconfiguration.

2. PASS: Mount and validate the contents of the generated seed ISO.
         The cloud-config should no longer specify a cleanup script.

3. PASS: Run a remote install:
         Validate RVMC script output. The script should execute as
         before, the new code path should not be reached.

4. PASS: Validate enroll-init retries:
         - Induce failure in the enroll-init step.
         - Simulate a later stage enrollment failure after
           a successful enroll-init.

         Ensure OAM and password can be reconfigured during retries
         in all scenarios.

5. PASS: Verify that cloud-init remains enabled until the end of
         enrollment.

Story: 2011100
Task: 51363

Depends-On: https://review.opendev.org/c/starlingx/ansible-playbooks/+/935519

Change-Id: I65bf2a28638c75930ba3f71f33267e42fb449b6c
Signed-off-by: Salman Rana <salman.rana@windriver.com>
2024-11-22 14:46:54 -05:00
..
rvmc_install.py Update enroll-init logic to allow retry 2024-11-22 14:46:54 -05:00