diff --git a/playbook_sysupgrade.yml b/playbook_sysupgrade.yml index 9e4e79f..a43b0f3 100644 --- a/playbook_sysupgrade.yml +++ b/playbook_sysupgrade.yml @@ -1,19 +1,30 @@ --- - name: upgrade firmware on openwrt device(s) - gather_facts: no hosts: accesspoints + vars: + running_garet_profile: "{{ ansible_local['garet']['profile'] | default() }}" + running_garet_release: "{{ ansible_local['garet']['release'] | default() }}" + firmware_file: "firmware/garet_{{ garet_profile }}-{{ garet_release }}.bin" + gather_facts: no tasks: - - name: upload new firmware - copy: - src: "{{ firmware_file }}" - dest: "/tmp/{{ firmware_file | basename }}" + - name: gather firmware version + setup: + filter: ansible_local - - name: issue sysupgrade command - command: - cmd: "sysupgrade /tmp/{{ firmware_file | basename }}" - ignore_errors: yes + - name: handle update + block: + - name: upload new firmware + copy: + src: "{{ firmware_file }}" + dest: "/tmp/{{ firmware_file | basename }}" - - name: wait till device is back online - wait_for_connection: - delay: 10 - timeout: 600 + - name: issue sysupgrade command + shell: + cmd: "sysupgrade /tmp/{{ firmware_file | basename }} && exit 0" + ignore_unreachable: yes + + - name: wait till device is back online + wait_for_connection: + delay: 10 + timeout: 600 + when: garet_profile != running_garet_profile or garet_release != running_garet_release