Ansible,列表对象没有属性
我正在使用Ansible 2.3.0.0,并在Ansible 2.4.0.0中进行了测试,获得了相同的结果。我的问题很简单,但我看不出问题所在 我在Ansible中定义了一个对象列表,如下所示:Ansible,列表对象没有属性,ansible,ansible-2.x,Ansible,Ansible 2.x,我正在使用Ansible 2.3.0.0,并在Ansible 2.4.0.0中进行了测试,获得了相同的结果。我的问题很简单,但我看不出问题所在 我在Ansible中定义了一个对象列表,如下所示: vars: password_text_to_encrypt: - { line: "{{truststore_pass }}" , regexp: '\${TRUSTSTORE_PASS}*'} - { line: "{{ keystore_pas
vars:
password_text_to_encrypt:
- { line: "{{truststore_pass }}" , regexp: '\${TRUSTSTORE_PASS}*'}
- { line: "{{ keystore_pass }}" , regexp: '\${KEYSTORE_PASS}*'}
- { line: "{{ gp_pass }}" , regexp: '\${GP_PASS}*'}
- { line: "{{ datasource_password }}" , regexp: '\${DATASOURCE_PASS}*'}
- { line: "{{ server_password }}" , regexp: '\${SERVER_PASSWORD}*'}
- { line: "{{ sftp_password }}" , regexp: '\${SFTP_PASSWORD}*'}
- { line: "{{ db_userpassword }}" , regexp: '\${DB_PASSWORD}*'}
roles:
- basic_role
我的基本_角色只是打印项目,我想获得每行的内容:
---
- name: "print password"
debug:
msg: "The content of the line is: {{ item.line}}"
with_nested:
- "{{password_text_to_encrypt}}"
但我得到的结果是:
FAILED! => {"failed": true, "msg": "the field 'args' has an invalid value, which appears to include a variable that is undefined. The error was: 'list object' has no attribute 'line'\n\nThe error appears to have been in.....
如果我将item.line
更改为仅item
,它会工作,但会打印:
ok: [localhost] => (item=[u'regexp', u'line']) => {
"item": [
"regexp",
"line"
],
"msg": "The content of the line is: [u'regexp', u'line']"
}
.
.
.
综上所述,ANTILE不考虑直线O-ReXEP的内容。我一直在做测试,用于初始化line和regexp的变量不是空的。使用
和_items
而不是和_nested
我想你需要,因为你得到了一个预期的扁平列表(根据文档)。这是我问题的总结版本。我真正想做的是调用一个端点来加密我的密码,但我认为这不一定需要更多的代码。是的,这是复制粘贴我的代码的另一部分,实际上是工作。