Home > Enterprise >  Why does ansible throws error while encrypting the string?
Why does ansible throws error while encrypting the string?

Time:07-25

When I run commands on my ansible 2.9 version on red hat 7 distro -

$ ansible-vault encrypt_string 'l3@TH!hFymu4b91!x[W!u[EL' 
New Vault password:  [ERROR]: User interrupted execution

$ ansible-vault encrypt_string '-w2kBT>ur=X{U`!43o&m'
usage: ansible-vault [-h] [--version] [-v]
                     {create,decrypt,edit,view,encrypt,encrypt_string,rekey}
                     ...
ansible-vault: error: unrecognized arguments: -w2kBT>ur=X{U`!43o&m

The first command succeeds while second one fails. Is it related to special characters. My program automatically generates passwords, so just one time escape won't help!

NB: The BaSh shell also would throw some errors, if you try to pass that string with a tilde using double quotes. But for single quotes, it won't complain.

CodePudding user response:

The second command fails because the argument to encrypt_string looks like a command line option (because it starts with hyphen -). As with many command line tools, you can tell ansible-vault to stop looking for option arguments using the -- marker, like this:

ansible-vault encrypt_string -- '-w2kBT>ur=X{U`!43o&m'
  • Related