I am trying to copy a secret Python settings file from a settings server to the production environment. Since the settings contains passwords I am using Ansible Vault.
My playbook looks like this:
---
- 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 }}"
And my settings.yml looks like this:
config: |
ASD='DEF'
PROGRAM='PROG'
PASSWORD='MAGNUS123'
TEMP='TEST'
However when I run the playbook I get the file:
ASD='DEF'
PROGRAM='PROG'
PASSWORD='MAGNUS123'
Even though Ansible claims the last line is also copied:
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=)
What am I doing wrong to cause this?
Ansible version:
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)]