2017-11-25 7 views
0

Ich versuche debops.nullmailer auf Ansible (2.4) verwenden, um Nullmailer auf meinen Hosts zu konfigurieren. Ich möchte das Passwort in der Variable verschlüsselt behalten, also suche ich nach der Tresor-Funktionalität, um das Geheimnis zu verschlüsseln. Mein Textbuch sieht wie folgt aus:Verwendung von Vault in Ansible gibt: 'str' und 'AnsibleVaultEncryptedUnicode' kann nicht verkettet werden

--- 
- 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 

jedoch die Anwendung dieser mit --ask-vault-pass gibt einen langatmigen Fehler:

TASK [debops.nullmailer : Generate private configuration files] *******************************************************************************************************************************************************************************
fatal: [talkbot]: FAILED! => {"failed": true, "msg": "[{u'dest': u'/etc/nullmailer/remotes', u'content': u\"{{ lookup('template', 'lookup/nullmailer__remotes.j2') | from_yaml | join('\n') }}\", u'group': u'mail', u'mode': u'0600', u'owner': u'mail'}]: An unhandled exception occurred while running the lookup plugin 'template'. Error was a , original message: Unexpected templating type error occurred on ({% 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 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() and entry.starttls|bool) or nullmailer__starttls|bool) and (entry.ssl is undefined or not entry.ssl|bool) and (entry.options is undefined or not entry.options)) %}\n{% set _ = nullmailer__tpl_entry.append('--starttls') %}\n{% endif %}\n{% if entry.ssl|d() and entry.ssl|bool %}\n{% set _ = nullmailer__tpl_entry.append('--ssl') %}\n{% endif %}\n{% if entry.insecure|d() and entry.insecure|bool %}\n{% set _ = nullmailer__tpl_entry.append('--insecure') %}\n{% endif %}\n{% if entry.x509fmtder|d() and 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 entry.x509crlfile|d() %}\n{% set _ = nullmailer__tpl_entry.append('--x509crlfile=' + entry.x509crlfile) %}\n{% endif %}\n{% if entry.port|d() %}\n{% set _ = nullmailer__tpl_entry.append('--port=' + entry.port) %}\n{% endif %}\n{% if ((entry.auth|d() and entry.auth|bool) or (entry.auth_login|d() and 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() or 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{% for entry in nullmailer__tpl_remotes %}\n- '{{ entry }}'\n{% endfor %}\n{% else %}\n- ''\n{% endif %}\n): cannot concatenate 'str' and 'AnsibleVaultEncryptedUnicode' objects"}

herausnehmen pass Variable bewirkt, dass es erfolgreich arbeiten, aber offensichtlich ohne --pass= Parameter in /etc/nullmailer/remotes benötigt.

Ich bin ziemlich neu zu ansible - was ist hier los? Warum versucht es eine str und eine AnsibleVaultEncryptedUnicode zu verketten? Funktioniert die Entschlüsselung nicht?

Antwort

1

Is the decryption not working?

Es versucht nicht einmal, wenn ein ansible Vault-verschlüsselte Variable innerhalb Jinja2 (Python) append Methode verwendet wird.

Das heißt, höchstwahrscheinlich Sie sollten:

  • ein ansible Vault statt einer variablen Datei verwenden oder

  • Datei ein Problem auf GitHub/fix ansible-nullmailer Projekt selbst mit der Situation umgehen.

+0

Ah, interessant. Ich werde stattdessen versuchen, eine Vault-Datei zu verwenden. – growse

Verwandte Themen