CRYPTO_UPGRADE="ansible-vault requires a newer version of pycrypto than the one installed on your platform. You may fix this with OS-specific commands such as: yum install python-devel; rpm -e --nodeps python-crypto; pip install pycrypto"
CRYPTO_UPGRADE="ansible-vault requires a newer version of pycrypto than the one installed on your platform. You may fix this with OS-specific commands such as: yum install python-devel; rpm -e --nodeps python-crypto; pip install pycrypto"
HEADER='$ANSIBLE_VAULT'
HEADER=u'$ANSIBLE_VAULT'
CIPHER_WHITELIST=['AES','AES256']
CIPHER_WHITELIST=['AES','AES256']
classVaultLib(object):
classVaultLib(object):
def__init__(self,password):
def__init__(self,password):
...
@@ -76,26 +81,28 @@ class VaultLib(object):
...
@@ -76,26 +81,28 @@ class VaultLib(object):
self.cipher_name=None
self.cipher_name=None
self.version='1.1'
self.version='1.1'
defis_encrypted(self,data):
defis_encrypted(self,data):
data=to_unicode(data)
ifdata.startswith(HEADER):
ifdata.startswith(HEADER):
returnTrue
returnTrue
else:
else:
returnFalse
returnFalse
defencrypt(self,data):
defencrypt(self,data):
data=to_unicode(data)
ifself.is_encrypted(data):
ifself.is_encrypted(data):
raiseerrors.AnsibleError("data is already encrypted")
raiseerrors.AnsibleError("data is already encrypted")
ifnotself.cipher_name:
ifnotself.cipher_name:
self.cipher_name="AES256"
self.cipher_name="AES256"
#raise errors.AnsibleError("the cipher must be set before encrypting data")
#raise errors.AnsibleError("the cipher must be set before encrypting data")