0

This is my playbok. I'm trying to add a new logging server to my switches.

---
- name: "Add new logging server"
  hosts: all
  gather_facts: no

  tasks:
    - name: Add logging server
      cisco.ios.ios_logging_global:
        config:
          hosts:
            - hostname: 10.255.0.2
          logging_on: enable
          trap: informational

The play book is working (it does add the server) but its not idempotent. Does anyone else have that problem? I have checked the LF and encoding. The version for Galaxy collection "cisco.ios" is 2.5.

My ansible version is:

$ansible --version

ansible 2.10.9
  config file = /home/fredr/ansible/ansible.cfg
  configured module search path = ['/home/fredr/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/fredr/.local/lib/python3.8/site-packages/ansible
  executable location = /home/fredr/.local/bin/ansible
  python version = 3.8.10 (default, Jun  2 2021, 10:49:15) [GCC 9.4.0]

How can I make it idempotent?

Fredrik Karlsson
  • 113
  • 1
  • 1
  • 9

2 Answers2

0

If I only do it does become idempotent

    - name: Add logging server
      cisco.ios.ios_logging_global:
        config:
          hosts:
            - hostname: 10.255.0.2

The reason is it uses the running config and since its default value is "logging enable" and "logging informational", they don't show in the running config.

The lines you want to set need to show in the configuration.

Fredrik Karlsson
  • 113
  • 1
  • 1
  • 9
0

An old question but I'm sharing my findings in case it helps anyone. As Fredrik said, the issue is that the module commands are not always exactly as the device shows them when using show run | include logging.

In my case the issue was the severity level on the buffered log config. Not idempotent:

config:
  buffered:
    severity: debugging
    size: 65000
  console:
    severity: errors

idempotent:

config:
  buffered:
    size: 65000
  console:
    severity: errors

The reason being that 'debugging' is the default severity for the buffered log and doesn't show in the running config:

sh run | i logging
logging buffered 65000
logging console errors

If a different severity is configured, such as 'informational', then that will be handled correctly if the same severity is pushed down from ansible.

delboy
  • 1