我正在尝试将秘密 Python 设置文件从设置服务器复制到生产环境。由于设置包含密码,我正在使用 Ansible Vault。
我的剧本如下所示:
---
- hosts: production
tasks:
- include_vars: settings.yml
- name: Set properties
lineinfile:
dest: ~/temp/deploy
regexp: "{{ item.split('=')[0] }}\\s*="
line: "{{ item }}"
with_lines: echo "{{ config }}"
我的 settings.yml 看起来像这样:
config: |
ASD='DEF'
PROGRAM='PROG'
PASSWORD='MAGNUS123'
TEMP='TEST'
但是,当我运行剧本时,我得到了文件:
ASD='DEF'
PROGRAM='PROG'
PASSWORD='MAGNUS123'
即使 Ansible 声称最后一行也被复制:
changed: [ssh.pythonanywhere.com] => (item=ASD='DEF' )
changed: [ssh.pythonanywhere.com] => (item=PROGRAM='PROG')
changed: [ssh.pythonanywhere.com] => (item=PASSWORD='MAGNUS123')
changed: [ssh.pythonanywhere.com] => (item=TEMP='TEST')
changed: [ssh.pythonanywhere.com] => (item=)
我做错了什么导致这个?
Ansible 版本:
ansible --version
ansible 2.4.1.0
config file = None
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.2 (default, Jul 17 2017, 16:44:45) [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]