首页 文章

在Ansible中使用保险库给出:无法连接'str'和'AnsibleVaultEncryptedUnicode'

提问于
浏览
0

我正在尝试在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]:失败了! => {“failed”:true,“msg”:“[{u'dest':u'/ etc / nullmailer / remotes',u'content':u \”{{lookup('template','lookup / nullmailer__remotes.j2')| from_yaml |加入('\ n')}} \“,u'group':u'mail',u'mode':u'0600',u'owner':u'mail'}]:运行时发生未处理的异常查找插件'模板' . 错误是原始消息:发生了意外的模板类型错误({%set nullmailer__tpl_remotes = []%} \ n {%for entry in(nullmailer__default_remotes nullmailer__remotes)%} \ n {%set nullmailer__tpl_entry = []%} \ n {%if if entry is string%} \ n {%set _ = nullmailer__tpl_remotes.append(entry)%} \ n {%elif条目映射%} \ n {%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 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 entry.x509certfile | d( )%} \ n {%set _ = nullmailer__tpl_entry.append(' - x509certfile ='entry.x509certfile)%} \ n {%endif%} \ n {%if if entry.x509crlfile | d()%} \ n { %set _ = nullmailer__tpl_entry.append(' - x509crlfile ='entry.x509crlfile)%} \ n {%endif%} \ n {%if if entry.port | d()%} \ n {%set _ = nullmailer__tpl_entry . append(' - port ='entry.port)%} \ n {%endif%} \ n {%if((entry.auth | d()和entry.auth | bool)或(entry.auth_login | d( )和entry.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 if entry.options is string 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表示nullmailer__tpl_remotes%}} \ n-'{}'\ n {%endfor%} \ n {%else%} \ n-''\ n {%endif%} \ n):无法连接'str'和'AnsibleVaultEncryptedUnicode'对象“}

取出 pass 变量会使其成功运行,但显然不需要 /etc/nullmailer/remotes 中的 --pass= 参数 .

我'm pretty new to ansible - what'在这里?为什么要尝试连接 strAnsibleVaultEncryptedUnicode ?解密不起作用吗?

1 回答

  • 1

    解密不起作用吗?

    在Jinja2(Python) append 方法中使用Ansible Vault加密变量时甚至没有尝试过 .

    那就是说,你很可能应该:

    • 使用Ansible Vault文件而不是变量,或

    • 在GitHub / fix ansible-nullmailer项目上自行提出问题来处理这种情况 .

相关问题