Upgrading 2960x

149 views
Skip to first unread message

kanor

unread,
Apr 24, 2020, 2:15:47 PM4/24/20
to Ansible Project
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
---
- hosts: all
connection: network_cli
gather_facts: no
vars:
ansible_network_os: ios
ansible_command_timeout: 720
tasks:
- name: Copy
ios_command:
commands: "copy tftp://xxx.xxx.xxx.xxx/c2960x-universalk9-mz.152-7.E0a.bin flash:"
prompt: "c2960x-universalk9-mz.152-7.E0a.bin"
answer: "\r"
- name: Show results
debug: msg= {{ results.stdout_lines }} My error.
fatal: [10.xxx.xxx.xxx]: FAILED! => {
63
"ansible_facts": {
64
"discovered_interpreter_python": "/usr/bin/python"
65
},
66
"changed": false,
67
"invocation": {
68
"module_args": {
69
"answer": "\r",
70
"commands": "copy tftp://xxx.xxx.xxx.xxx/c2960x-universalk9-mz.152-7.E0a.bin flash:",
71
"prompt": "c2960x-universalk9-mz.152-7.E0a.bin"
72
}
73
},
74
"msg": "Unsupported parameters for (ios_command) module: answer, prompt Supported parameters include: auth_pass, authorize, commands, host, interval, match, password, port, provider, retries, ssh_keyfile, timeout, username, wait_for"
75
}
76

Dick Visser

unread,
Apr 24, 2020, 8:01:27 PM4/24/20
to ansible...@googlegroups.com
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.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b94107fc-acad-40f3-9414-b7f02d2a2c41%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

Heinz Meier

unread,
Apr 25, 2020, 5:01:31 PM4/25/20
to ansible...@googlegroups.com
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:

all:
hosts:
    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

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/{{ 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]'
 

Dick Visser

unread,
Apr 26, 2020, 12:56:17 AM4/26/20
to ansible...@googlegroups.com
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)?


Claudia de Luna

unread,
Apr 26, 2020, 8:50:23 AM4/26/20
to Ansible Project
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


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

To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.

Kevin Northcutt

unread,
Apr 26, 2020, 10:33:52 AM4/26/20
to ansible...@googlegroups.com
I really appreciate everyone's input to my question. 
Thanks

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/22bb1171-c5f7-4b65-892b-d47782f5a571%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages