Python 2.7 Ansible错误-实现错误:名称请求的类型字符串未知
执行ansible playbook时,出现未知类型字符串错误 实现错误:名称请求的类型字符串未知 我试图用ansible剧本来展示我的名字。bg代码是pythonPython 2.7 Ansible错误-实现错误:名称请求的类型字符串未知,python-2.7,ansible,Python 2.7,Ansible,执行ansible playbook时,出现未知类型字符串错误 实现错误:名称请求的类型字符串未知 我试图用ansible剧本来展示我的名字。bg代码是python --- - name: Test hello module hosts: localhost tasks: - name: run the hello module hello: name: 'Test' register: helloout
---
- name: Test hello module
hosts: localhost
tasks:
- name: run the hello module
hello:
name: 'Test'
register: helloout
- name: dump test output
debug:
msg: '{{ helloout }}'
[警告]:提供的主机列表为空,只有本地主机可用。请注意,隐式localhost与“all”不匹配
播放[测试hello模块]****************************************************************************************************************************
任务[收集事实]******************************************************************************************************************************
确定:[本地主机]
任务[运行hello模块]*************************************************************************************************************************
致命:[localhost]:失败!=>{“changed”:false,“msg”:“实现错误:为名称“}请求的类型字符串未知”
重演******************************************************************************************************************************************
localhost:ok=1已更改=0不可访问=0失败=1已跳过=0已获救=0已忽略=0
在AnsibleModule()
方法参数argument\u spec
中,您要查找的类型实际上是str
,而不是string
:
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True, type='str')
),
supports_check_mode=False
)
您可以在中看到参数的可接受类型规范列表
module = AnsibleModule(
argument_spec=dict(
name=dict(required=True, type='str')
),
supports_check_mode=False
)