onie-nos-install from ansible

Wanted a way to re-install from ONIE without modifying DHCP options or manually runnning onie-nos-install. Played around with busybox’s ash shell until coming upon the -ilc invocation to get the path set for
Delegates the task to localhost so that the command can be performed with root, bypassing a non-root ansible_ssh_user in the inventory, which would otherwise take precedence.
Example playbook below.
---    - hosts: sw35    become: yes      vars:      initial_install: "http://webserver/CumulusLinux-2.5.1-"      arch_map:        ppc: "powerpc"        x86: "amd64"      tasks:    - name: boot into onie rescue mode      command: "cl-img-select -fr"      notify:      - restart machine      - wait for switch to come back up      tags: onie_rescue      - name: reboot immediately      meta: flush_handlers      - name: onie-nos-install base version      shell: ssh root@{{ inventory_hostname }} '/bin/ash -ilc "onie-nos-install {{initial_install}}{{ arch_map[ansible_architecture] }}.bin"'      delegate_to:      become: no      tags: onie_nos_install      notify:      - wait for switch to come back up      - name: wait for switch to come back up      meta: flush_handlers      handlers:    - name: restart machine      command: shutdown -r now "Ansible updates triggered"      async: 0      poll: 0      ignore_errors: true      - name: wait for switch to come back up      become: no      local_action: wait_for host={{ inventory_hostname }} port=22 delay=20                    state=started      become: false

0 replies

Be the first to reply!