首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >可选的nxos_interface模块:

可选的nxos_interface模块:
EN

Stack Overflow用户
提问于 2020-04-19 15:51:45
回答 1查看 167关注 0票数 1

我是一名网络工程师,刚接触Ansible自动化,我正在尝试按照实战手册中提到的方式配置Nexus交换机接口,我没有遇到从ios_command模块获取结果的问题,但ios_config模块出现了问题,我不知道问题是什么,请帮助我,我已经粘贴了实战手册和错误日志:

代码语言:javascript
复制
---
---
- name: configure ethernet interface
  hosts: nx-os

  tasks:
    - name: filter hostname
      ios_command:
        commands: "show run | inc hostname"

      register: output

    - name: configure interfaces
      nxos_interface:
          - name: "{{ item.name }}"
            admin_state: up
            duplex: full
            speed: auto

      with_items:
         - name: Ethernet1/41
         - name: Ethernet1/42
      when: "'nx-os' in output.stdout[0]"

错误:

代码语言:javascript
复制
[DEPRECATION WARNING]: The TRANSFORM_INVALID_GROUP_CHARS settings is set to allow bad characters in group names by default, this will change, but
still be user configurable on deprecation. This feature will be removed in version 2.10. Deprecation warnings can be disabled by setting
deprecation_warnings=False in ansible.cfg.
[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

ERROR! unexpected parameter type in action: <class 'ansible.parsing.yaml.objects.AnsibleSequence'>

The error appears to be in '/root/ansible/bkrishna/configure_interface.yml': line 12, column 7, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


    - name: Admin down an interface
      ^ here
EN

回答 1

Stack Overflow用户

发布于 2020-04-20 23:50:51

错误消息非常明确:

错误!操作中的意外参数类型:<class 'ansible.parsing.yaml.objects.AnsibleSequence'>

不存在接受列表作为其主要配置形式的ansible模块,尽管有些模块接受单个键的列表

您需要的是以下内容:

代码语言:javascript
复制
- name: configure interfaces
  nxos_interface:
    name: "{{ item.name }}"
    admin_state: up
    speed: auto
  with_items:
  - # as you had before ...
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61301173

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档