Playbook only works with -vvv

I’ve got a playbook using the ios_command module to grab command output from a Cisco switch. The playbook works if I run it with -vvv but without -vvv the output file contains only the word “None”. There are no error messages either way.

I can change the command to “show version” and it works fine for all switches. I can log in and do “show run” manually with no problems. Output is longer on the three that are failing but not outrageously so. I have 2960 stacks that have much longer config output and the same playbook works fine on those. Note that the “show version” command that succeeds is also considerably shorter output than “show run”

I have five of these switches and only have this issue on three of them. The other two give the expected output. They all have the same software version and hardware model but the three that are failing have an extra power supply a 10G module.

Any clues as to what’s different with -vvv? Apparently it’s doing more than just turning on some print statements.

Thank you,

Hullo Dave.

I know nothing about Cisco switches, but I can’t see how anyone can help you without seeing the code you are trying to run… maybe post the playbook?

If you can reduce the playbook to a minimal demonstration of the problem, that would help (and in doin it, you migt find the problem yourself).

Regards, K.

Here’s the relevant bits of the playbook. The debug prints the text, “None”, for the ones that fail and the output of “show run” for the ones that work.

It works with -vvv, so what’s the difference and how do I make it work without -vvv?

tasks:

  - name: IOS-ish Show Run
    block:
    - ios_command:
        commands: show run
      register: cmd_output

    - set_fact:
        config: "{{ cmd_output.stdout[0] }}"

    - debug:
        msg: "{{ config }}"
      when: config is defined

    when:
      - ansible_network_os is defined
      - "ansible_network_os in ['ios', 'iosxe', 'iosxr', 'nxos']"

Thanks,
Dave