我是一名网络工程师,刚接触Ansible自动化,我正在尝试按照实战手册中提到的方式配置Nexus交换机接口,我没有遇到从ios_command模块获取结果的问题,但ios_config模块出现了问题,我不知道问题是什么,请帮助我,我已经粘贴了实战手册和错误日志:
---
---
- 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]"错误:
[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发布于 2020-04-20 23:50:51
错误消息非常明确:
错误!操作中的意外参数类型:
<class 'ansible.parsing.yaml.objects.AnsibleSequence'>
不存在接受列表作为其主要配置形式的ansible模块,尽管有些模块接受单个键的列表
您需要的是以下内容:
- name: configure interfaces
nxos_interface:
name: "{{ item.name }}"
admin_state: up
speed: auto
with_items:
- # as you had before ...https://stackoverflow.com/questions/61301173
复制相似问题