LoginSignup
2
0

More than 5 years have passed since last update.

【凡ミス】Ansible Vaultで作成したパスワードに改行コード(\n)が含まれてしまう。

Posted at

【事象】

Ansible Vaultで作成したパスワードに改行(\n)が含まれてしまい、ユーザー作成の際などにパスワードがおかしくなる。

【解決】

パスワード作成時、echoコマンドに オプション-n を忘れていた。

■改行コードが含まれてしまう
# echo test | ansible-vault encrypt
■改行コードが含まれない
# echo -n test | ansible-vault encrypt

Pythonの仕業なのか!?!?と思いめっちゃ焦りました...。
単発のパスフレーズで気づけて良かった。

【参考】

公式でもecho -nしてた。。。
Use encrypt_string to create encrypted variables to embed in yaml
https://docs.ansible.com/ansible/latest/user_guide/vault.html?highlight=vault

echo -n 'letmein' | ansible-vault encrypt_string --vault-id dev@password --stdin-name 'db_password'

echoのMAN
https://linuxjm.osdn.jp/html/GNU_sh-utils/man1/echo.1.html

sivelさんも言ってた。。。
You will need to use echo -n to prevent echo from adding the newline to your data. Vault should not be responsible for stripping newlines, as the newlines could be desired.
https://github.com/ansible/ansible/issues/34795

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0