0

我第一次在 IOS-XE 设备(Cat 9k,16.8.1r)上使用 Netconf-Yang,我正在发送以下 XML 块来更改接口描述。

我正在使用带有这些参数的 ansible netconf_config:

- name: netconf playbook
  hosts: switch1
  vars:
    ansible_connection: netconf
    ansible_port: 830
    outfile: yang-config.xml

  tasks:
    - name: Changing interfaces description
      netconf_config:
        lock: if-supported
        error_option: rollback-on-error
        default_operation: "merge"
        commit: yes
        content: "{{ lookup('file', outfile) }}"
      register: result

    - debug:
        var: result


Contents of outfile: >>>


<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
    <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
        <interface>
            <name>GigabitEthernet1/1/1</name>
            <description>netconf-test1</description>
            <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
        </interface>
    </interfaces>
</config>

然后我得到以下错误。我已经排除了身份验证问题。这不是用户名或密码,也不是交换机上的 ACL。不知何故,模型一定有问题。我已经用 pyang2dsdl 对其进行了验证,但它只是告诉我“配置”应该是“数据”。

TASK [Changing interfaces description] *********************************************************************************************************************************************************
The full traceback is:
  File "/tmp/ansible_netconf_config_payload_jx0san85/ansible_netconf_config_payload.zip/ansible/modules/network/netconf/netconf_config.py", line 401, in main
  File "/tmp/ansible_netconf_config_payload_jx0san85/ansible_netconf_config_payload.zip/ansible/module_utils/connection.py", line 185, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [switch1]: FAILED! => changed=false 
  invocation:
    module_args:
      backup: false
      backup_options: null
      commit: true
      confirm: 0
      confirm_commit: false
      content: |-
        <config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
            <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
                <interface>
                    <name>GigabitEthernet1/1/1</name>
                    <description>netconf-test1</description>
                    <type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:ethernetCsmacd</type>
                </interface>
            </interfaces>
        </config>
      default_operation: merge
      delete: false
      error_option: rollback-on-error
      format: xml
      host: null
      hostkey_verify: true
      lock: always
      look_for_keys: true
      password: null
      port: 830
      save: false
      source_datastore: null
      src: null
      ssh_keyfile: null
      target: auto
      timeout: 10
      username: null
      validate: false
  msg: |-
    error: /oc-stp:stp/rapid-pvst/vlan: badarg
    error: /oc-sys:system/ntp/config/ntp-source-interface: badarg
    error: /oc-sys:system/aaa/authentication/config/authentication-method: {case_clause,<<"tacgroup">>}

我无法找到有关此错误的任何信息。谢谢你的帮助。

4

0 回答 0