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

Added a role to boot a SONiC switch to onie #327

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions partition/roles/sonic-boot-to-onie/README.md
Original file line number Diff line number Diff line change
@@ -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`. |
2 changes: 2 additions & 0 deletions partition/roles/sonic-boot-to-onie/defaults/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
sonic_boot_to_onie_bootentry: "0001"
24 changes: 24 additions & 0 deletions partition/roles/sonic-boot-to-onie/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -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
shell: "show ztp status"
Gerrit91 marked this conversation as resolved.
Show resolved Hide resolved
register: result
until: "'SUCCESS' in result.stdout"
retries: 30
delay: 20
Loading