Ritorno al metodo di scrittura del file, stavolta temporaneo.

This commit is contained in:
Emiliano Vavassori 2015-07-14 22:01:41 +02:00
parent 7f7e93c935
commit 0d77b24de9
2 changed files with 12 additions and 3 deletions

View File

@ -10,4 +10,7 @@ logfile=/var/lib/ansible-pull.log
branch=master
playbook=local.yml
ansible-pull --accept-host-key -d "${repo}" -U "${url}" -C "${branch}" "${playbook}" --vault-password "$(/var/lib/{{ domainfull }}/bin/getvaultpass.py)"
vaultpassfile=$(/var/lib/{{ domainfull }}/bin/getvaultpass.py)
ansible-pull --accept-host-key -d "${repo}" -U "${url}" -C "${branch}" "${playbook}" --vault-password-file "${vaultpassfile}"
rm -f "${vaultpassfile}"

View File

@ -6,7 +6,8 @@ from Crypto.Cipher import AES
from base64 import b64decode
from requests import get
from socket import gethostname
from os import makedirs, path
from tempfile import mkstemp
import os
key = MD5.new(gethostname()).digest()
cipher = AES.new(key, AES.MODE_ECB)
@ -14,4 +15,9 @@ base64enc = get("http://{{ serverfqdn }}:3000/vaultpass")
encrypted = b64decode(base64enc.content)
longpass = cipher.decrypt(encrypted)
print(longpass.strip('x'))
fd, filename = mkstemp()
with open(filename, 'w+') as f:
f.write(longpass.strip('x'))
os.close(fd)
print(filename)