Search code examples
ansibleansible-vault

Ansible vault : encrypt password that begins with '-'


I am trying to encrypt password "-abc" using ansible-vault. It errors out saying "no such option".

Error is given below,

$ansible-vault encrypt_string '-abc' 
Usage: ansible-vault encrypt_string [--prompt] [options] string_to_encrypt

ansible-vault: error: no such option: -a

Version: ansible 2.7.7; Ubuntu 18

It is a legitimate password used in our system, that begins with '-'.

Kindly advise.


Solution

  • Because it takes -a as an option. You should use double dash (--) which means end of command options.

    $ansible-vault encrypt_string -- '-abc'