# Upgrading 2960x

**URL:** <https://forum.ansible.com/t/upgrading-2960x/32776>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [April 24, 2020, 6:15pm UTC](https://forum.ansible.com/t/upgrading-2960x/32776 "2020-04-24T18:15:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Northcutt](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin\_Northcutt](https://forum.ansible.com/u/Kevin_Northcutt)\
**Post date:** [April 24, 2020, 6:15pm UTC](https://forum.ansible.com/t/upgrading-2960x/32776/1 "2020-04-24T18:15:47Z")

</div>

I’m sure I’m missing something very simple but have been working on this for a few days. I’m really new to Ansible and would really appreciate any help.

I have AWX  
Ansible

My Playbook

| |

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 25, 2020, 12:00am UTC](https://forum.ansible.com/t/upgrading-2960x/32776/2 "2020-04-25T00:00:52Z")

</div>

Hi

Although this list isn’t for AWX, it’s easy to spot the error because it literally says at the end what is wrong.  
The commands parameter expects a list.  
See the last example on  
[https://docs.ansible.com/ansible/latest/modules/ios\_command\_module.html#examples](https://docs.ansible.com/ansible/latest/modules/ios_command_module.html#examples)

---

<div class="post-metadata">

**Author:** ![Heinz\_Meier](https://avatars.discourse-cdn.com/v4/letter/h/7ba0ec/32.png) [@Heinz\_Meier](https://forum.ansible.com/u/Heinz_Meier)\
**Post date:** [April 25, 2020, 9:00pm UTC](https://forum.ansible.com/t/upgrading-2960x/32776/3 "2020-04-25T21:00:57Z")

</div>

hi,

i started to write a universal ios upgrade playbook. The meta playbook includes the playbooks for the specific model upgrades. Sorry for the lengthy post. But when I find some time I will write a better blog article.

Please feel free to ask me again if you have a question regarding this playbooks.

First we have an inventory like:

```auto
all:
  hosts: 

```

```auto
    switch01: 
      ansible_host: 192.168.100.149 # DHCP address in staging net

  children: # grouping in ansible is called „children“
    c9200l: # grouping according to hardware 
      hosts: 
        switch01: 
      vars: 
        compliant_ios_version: 16.12.01 
        ios_hash: 727cfc785bc304b985656dee660b0382 
        ios_file: cat9k_lite_iosxe.16.12.01.SPA.bin

```

```auto
The meta playbook is like:
---
- hosts: cisco
  vars:
    model: "{{ ansible_net_model | regex_replace('^WS-C(\d+.).*$', '\1') }}"
  tasks:
    - name: Output
      debug:
        msg: "Found model: {{ model }}. Will try to upgrade."
    - name: Include model series specific upgrade
      block:
        - name: do include
          include: "ios-upgrade-{{ model }}.yaml"
      when: (ansible_net_version != compliant_ios_version)

The playbook for a c2960L is:
  - name: Copy IOS to device
    ios_command:
      commands:
        - command: 'copy tftp://[192.168.100.16/{{](http://192.168.100.16/{{) ios_file }} flash:'
          prompt: 'Destination filename \[{{ ios_file }}\]?'
          answer: "\r"
    vars:
      ansible_command_timeout: 600

  - name: Check md5sum of IOS on device
    ios_command:
      commands:
        - command: 'verify /md5 flash:{{ ios_file }} {{ ios_hash }}'
    register: md5_output

  - name: Continue if hash matches
    block:

      - name: Set new boot variable
        ios_config:
          lines: boot system flash:{{ ios_file }}
          save_when: always

      - name: Reboot device
        ios_command:
          commands:
            - command: reload
              prompt: '\[confirm\]'
              answer: "\r"

      - name: Wait for switch to reboot
        wait_for:
          host: "{{ ansible_host }}"
          port: 22
          delay: 60
          timeout: 600
        delegate_to: localhost

      - name: Gather facts of the switch again
        ios_facts:

      - name: Assert that the running IOS version is correct
        assert:
          that:
            - compliant_ios_version == ansible_net_version
          msg: "IOS version does not match compliant version. Upgrade unsuccessful."

    when: '"Verified" in md5_output.stdout[0]'

	

```

```auto
 

```

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [April 26, 2020, 4:55am UTC](https://forum.ansible.com/t/upgrading-2960x/32776/4 "2020-04-26T04:55:47Z")

</div>

Hi

What is the purpose of this message? It seems to bear no question, and does not have any relation to the original message(s)?

---

<div class="post-metadata">

**Author:** ![Claudia\_de\_Luna](https://avatars.discourse-cdn.com/v4/letter/c/ecccb3/32.png) [@Claudia\_de\_Luna](https://forum.ansible.com/u/Claudia_de_Luna)\
**Post date:** [April 26, 2020, 12:50pm UTC](https://forum.ansible.com/t/upgrading-2960x/32776/5 "2020-04-26T12:50:23Z")

</div>

I believe Mr. Meier was just sharing an example of a working version of a playbook that does what kanor is trying to do.

It also illustrates your point about the ios\_commands module wanting a list.

 ![ios-command-2020-04-26_05-45-14.png](https://us1.discourse-cdn.com/ansible/original/2X/a/a2429b4e53072b56ab993716c34f882a95ffa977.png)

I found it pretty relevant and am glad he took the time to share that.

---

<div class="post-metadata">

**Author:** ![Kevin\_Northcutt](https://avatars.discourse-cdn.com/v4/letter/k/47e85d/32.png) [@Kevin\_Northcutt](https://forum.ansible.com/u/Kevin_Northcutt)\
**Post date:** [April 26, 2020, 2:33pm UTC](https://forum.ansible.com/t/upgrading-2960x/32776/6 "2020-04-26T14:33:14Z")

</div>

I really appreciate everyone’s input to my question.  
Thanks

> **(attachments)**
>
> ![ios-command-2020-04-26_05-45-14.png](https://us1.discourse-cdn.com/ansible/original/2X/a/a2429b4e53072b56ab993716c34f882a95ffa977.png)
