我尝试在Ansible(2.4)上使用debops.nullmailer
在我的主机上配置nullmailer。我想在变量中加密密码,所以我希望使用保险库功能来加密密码。我的剧本看起来像这样:
---
- name: My baseline
hosts: all
become: true
vars:
nullmailer__default_remotes:
- port: "587"
host: smtp.mailgun.org
user: myusername
pass: !vault |
$ANSIBLE_VAULT;1.1;AES256
6430...63433
roles:
- role: debops.nullmailer
然而,将此应用于--ask-vault-pass
会产生一个冗长的错误:
任务[debops.nullmailer:生成私有配置文件] ************************************ ************************************************** ************************************************** ***************************************
致命:[talkbot]:失败了! => {"失败":是的," msg":" [{u' dest':u' / etc / nullmailer / remotes',你的内容':你需要{{查询('模板',' lookup / nullmailer__remotes.j2')| from_yaml |加入(' \ n')}} \",u' group&#39 ;: u' mail',u' mode':u&#39 ; 0600',您'所有者':您邮件'}]:运行查找插件'模板时发生了未处理的异常。错误是原始消息:发生了意外的模板类型错误({%set nullmailer__tpl_remotes = []%} \ n {%for entry in(nullmailer__default_remotes + nullmailer__remotes)%} \ n {%set nullmailer__tpl_entry = []%} \ n {%if entry is string%} \ n {%set _ = nullmailer__tpl_remotes.append(entry)%} \ n {%elif entry is mapping%} \ n {%if if entry.host | d()%} \ n { %set _ = nullmailer__tpl_entry.append(entry.host)%} \ n {%set _ = nullmailer__tpl_entry.append(entry.protocol | d(' smtp'))%} \ n {%if(( (entry.starttls | d()和entry.starttls | bool)或nullmailer__starttls | bool)和(entry.ssl未定义或不是entry.ssl | bool)和(entry.options未定义或不是entry.options))% } \ n {%set _ = nullmailer__tpl_entry.append(' - starttls')%} \ n {%endif%} \ n {%if entry.ssl | d()和entry.ssl | bool %} \ n {%set _ = nullmailer__tpl_entry.append(' - ssl')%} \ n {%endif%} \ n {%if entry.insecure | d()和entry.insecure | bool%} \ n {%set _ = nullmailer__tpl_entry.append(' - insecure')%} \ n {%endif%} \ n {%if if entry.x509fmtder | d()和entry.x509fmtder | bool%} \ n {%set _ = nullmailer__tpl_entry.append(' - x509fmtder')%} \ n {%endif%} \ n {%if entry.x509cafile | d()%} \ n {%set _ = nullmailer__tpl_entry.append(' - x509cafile =' + entry.x509cafile)%} \ n {%endif%} \ n {%if if entry.x509certfile | d()%} \ n {%set _ = nullmailer__tpl_entry.append(' - x509certfile =&#39 ; + entry.x509certfile)%} \ n {%endif%} \ n {%if if entry.x509crlfile | d()%} \ n {%set _ = nullmailer__tpl_entry.append(' - x509crlfile =&# 39; + entry.x509crlfile)%} \ n {%endif%} \ n {%if if entry.port | d()%} \ n {%set _ = nullmailer__tpl_entry.append(' - port =& #39; + entry.port)%} \ n {%endif%} \ n {%if((entry.auth | d()和entry.auth | bool)或(entry.auth_login | d()和条目。 auth_login | bool))%} \ n {%set _ = nullmailer__tpl_entry.append(' - auth-login')%} \ n {%endif%} \ n {%if entry.user | d ()%} \ n {%set _ = nullmailer__tpl_entry.append(' - user =' + entry.user)%} \ n {%endif%} \ n {%if entry.password | d()或entry.pass | d()%} \ n {%set _ = nullmailer__tpl_entry.append(' - pass =' +(entry.password | d(entry.pass))) %} \ n {%endif %} \ n {%if entry.options | d()%} \ n {%set _ = nullmailer__tpl_entry.append(entry.options如果entry.options是字符串else entry.options | join(' '))%} \ n {%endif%} \ n {%set _ = nullmailer__tpl_remotes.append(nullmailer__tpl_entry | join(''))%} \ n {%endif%} \ n {%endif%} \ n {%endfor%} \ n {%if nullmailer__tpl_remotes%} \ n {%{null for nullmailer__tpl_remotes%} \ n-' {{entry}}' \ n { %endfor%} \ n {%else%} \ n-'' \ n {%endif%} \ n):无法连接' str'和' AnsibleVaultEncryptedUnicode'对象"}
取出pass
变量会使其成功运行,但显然不需要--pass=
中的/etc/nullmailer/remotes
参数。
我对ansible很新 - 这里发生了什么?为什么要尝试连接str
和AnsibleVaultEncryptedUnicode
?解密不起作用吗?
答案 0 :(得分:1)
解密不起作用吗?
在Jinja2(Python)append
方法中使用Ansible Vault加密变量时,甚至没有尝试过。
那就是说,你很可能应该:
使用Ansible Vault文件而不是变量,或
自行提交GitHub / fix ansible-nullmailer
项目的问题以处理这种情况。