# ansible-playbook ./firmware_upgrade.yml
- name: Upgrade WTI Device
  hosts: "{{ansible_hosts}}"  # pass as -e ansible_hosts=wti_demo on the commandline
  collections:
     - wti.remote
  connection: local
  gather_facts: False

  tasks:
  - set_fact: use_https=False
    when: use_https is undefined
  - set_fact: validate_certs=False
    when: validate_certs is undefined

  - name: upgrade WTI device checking online for new version
    cpm_firmware_update:
      cpm_url: "{{ansible_host}}"
      cpm_username: "{{ansible_user}}"
      cpm_password: "{{ansible_pw}}"
      use_https: "{{use_https}}"
      validate_certs: "{{validate_certs}}"
      cpm_path: "/tmp/"
      # when cpm_file is missing, the playbook will look online for the latest version
      # cpm_file: "uimage_3352_tsm_arm.md5"
      # cpm_file: "uimage_3352_128512_vmr_v2.15.md5"
    register: testout
  - name: dump test output
    debug:
      msg: "{{ testout['data'] }}"
