diff --git a/partition/roles/sonic-boot-to-onie/README.md b/partition/roles/sonic-boot-to-onie/README.md new file mode 100644 index 00000000..f632ab5b --- /dev/null +++ b/partition/roles/sonic-boot-to-onie/README.md @@ -0,0 +1,11 @@ +# sonic-boot-to-onie + +Boots a SONiC switch into ONIE so it can be reinstalled from scratch. + +It depends on the `switch_facts` module from `ansible-common`, so make sure modules from `ansible-common` are included before executing this role. + +## Variables + +| Name | Mandatory | Description | +| ----------------------------- | --------- | -------------------------------------------------------------------------------- | +| sonic_boot_to_onie_bootentry | yes | The efi boot entry number for the ONIE boot entry as seen with `efibootmgr`. | diff --git a/partition/roles/sonic-boot-to-onie/defaults/main.yaml b/partition/roles/sonic-boot-to-onie/defaults/main.yaml new file mode 100644 index 00000000..e6a975c8 --- /dev/null +++ b/partition/roles/sonic-boot-to-onie/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +sonic_boot_to_onie_bootentry: "0001" diff --git a/partition/roles/sonic-boot-to-onie/tasks/main.yaml b/partition/roles/sonic-boot-to-onie/tasks/main.yaml new file mode 100644 index 00000000..29d6e07f --- /dev/null +++ b/partition/roles/sonic-boot-to-onie/tasks/main.yaml @@ -0,0 +1,24 @@ +--- +- name: Gather switch facts + switch_facts: + +- name: Check mandatory variables for this role are set + assert: + fail_msg: "not all mandatory variables given, check role documentation" + quiet: yes + that: + - sonic_boot_to_onie_bootentry is defined + - metal_stack_switch_os_is_sonic + +- name: Set next boot entry to ONIE + command: efibootmgr -n {{ sonic_boot_to_onie_bootentry }} + +- name: Boot into ONIE + reboot: + +- name: Wait until ZTP has completed + command: "show ztp status" + register: result + until: "'SUCCESS' in result.stdout" + retries: 30 + delay: 20