[WARNING]: To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device?

Hello, All

I’ve setup ansible playbook to change password for Cisco nxos devices.
However, I keep getting the following warning message. Does anyone have any clue? or any experience to see the same issue?

##[section]Starting: Update NPA on NXOS devices for Specific Devices
`==============================================================================`
Generating script.
Script contents:
ansible-playbook /etc/ansible/playbooks/nxos/plb-nxos-secrets-admin.yml -i /etc/ansible/inventories/inv-test-for_nxos_with_password.yml
========================== Starting Command Output ===========================
PLAY [NXOS - Set password for local admin account] *****************************

TASK [Set password for local admin account] ************************************
[WARNING]: To ensure idempotency and correct diff the input configuration lines
should be similar to how they appear if present in the running configuration on
device
changed: [xxxxx-ooo-asw02]

PLAY RECAP *********************************************************************
xxxxx-ooo-asw02 : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   

##[error]Bash wrote one or more lines to the standard error stream.
##[error][WARNING]: To ensure idempotency and correct diff the input configuration lines
should be similar to how they appear if present in the running configuration on
device

##[section]Finishing: Update NPA on NXOS devices for Specific Devices
[root@ansible001 ~]# ansible --version
ansible [core 2.15.6]

NAME="Red Hat Enterprise Linux"
VERSION="9.3 (Plow)"
- my playbook code!
- name: NXOS - Set password for local admin account
  hosts: nxos
  gather_facts: false
  tasks:

  - name: Set password for local admin account
    nxos_config:
      lines:
        - username admin password xxxxxxxxxx role network-admin

Thank you in advance for looking at this issue.

Regards

Hello @bacchus21

The nxos_config module displays a warning when changes occur.

If it is for user management, the nxos_user module may be more suitable.
https://docs.ansible.com/ansible/latest/collections/cisco/nxos/nxos_user_module.html

Hello, @akira6592

Thank you very much for looking at my question. However, looks like nxos_user is a bit different from my case.

By the way, do you have any clue why below error appears?
##[error]Bash wrote one or more lines to the standard error stream.

Regards

@bacchus21 Sorry, I do not know the cause of that error.

Hi,

This WARNING message was sent to stderr instead of stdout, since Ansible sends any warning message to stderr.

TASK [Set password for local admin account] ************************************
[WARNING]: To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device
changed: [xxxxx-ooo-asw02]

So following error simply indicates that there were some output to stderr and dumps the contents of the stderr.
I assume you are using Azure Pipelines, but if the “Fail On Standard Error” option is false (default), I think you can ignore this error message.

##[error]Bash wrote one or more lines to the standard error stream.
##[error][WARNING]: To ensure idempotency and correct diff the input configuration lines should be similar to how they appear if present in the running configuration on device

If you want to hide any WARNINGs from tasks, you can set ANSIBLE_ACTION_WARNINGS=false environment variable or add action_warnings = false to ansible.cfg: Ansible Configuration Settings — Ansible Documentation

1 Like

@kurokobo Thank you very much for your advice. Indeed, action_warnings = false to ansible.cfg works perfectly fine.

I need one more advice. Can we set the same in playbook so that this change only affect on specific playbooks?

Thank you.
Regards

@akira6592 Noted. Thank you very much!

1 Like

AFAIK we can’t change this configuration in a playbook. As workarounds, we should consider changing this configuration via environment variable by some way.

We can use env for task (or bash, idk which is used on your side) for Azure pipelines:

steps:
  - bash: ...
    env:
      ANSIBLE_ACTION_WARNINGS: "false"
  - task: ...
    env:
      ANSIBLE_ACTION_WARNINGS: "false"

Or to respect bash way, append ANSIBLE_ACTION_WARNINGS=false just before ansible-playbook in your script:

ANSIBLE_ACTION_WARNINGS=false ansible-playbook /etc/ansible/playbooks/nxos/plb-nxos-secrets-admin.yml -i /etc/ansible/inventories/inv-test-for_nxos_with_password.yml
3 Likes

@kurokobo Thank you very much for your advice.

I tried both “env” and “apend” options.

Regarding the below method, it causes some unexpected pipeline error, so I wasn’t able to proceed further.

steps:
  - bash: ...
    env:
      ANSIBLE_ACTION_WARNINGS: "false"
  - task: ...
    env:
      ANSIBLE_ACTION_WARNINGS: "false"

However, regarding the second option, it worked perfectly!!!
ANSIBLE_ACTION_WARNINGS=false ansible-playbook /etc/ansible/playbooks/nxos/plb-nxos-secrets-admin.yml -i /etc/ansible/inventories/inv-test-for_nxos_with_password.yml

For now, I’ll be using the second option, appending ANSIBLE_ACTION_WARNINGS=false in my script.

Thank you again for helping me on this issue.

Regards

1 Like