ansible-vault variables are imported with extra empty lines
#8764 opened on Dec 6, 2020
Description
ISSUE TYPE
- Bug Report
SUMMARY
I am importing inventory from git repository. I understand that AWX needs to use __ansible_vault which is fine. However it changes the input data and adds extra empty lines. If the view is changed to JSON the encrypted string has erroneous \n characters embedded.
ENVIRONMENT
- AWX version: 15.0.1
- AWX install method: docker on linux
- Ansible version: 2.9.14
- Operating System: Ubuntu 20.04
- Web Browser: Firefox
STEPS TO REPRODUCE
Create an inventory with host variable file which has ansible vault encrypted data in a git repository.
encrypted_variable: !vault |
$ANSIBLE_VAULT;1.2;AES256;myvaultid
37393937383739363161306133623566396530626562373962616235626636383564626631613832
6534623133626365303931636563346663386335636230350a383832343462313832633464373431
31346430346364636538353863383966343364316336366430616635643034356365653063636630
6561336336613637660a343965343137373032636466383566656430663465646335313632363861
37306136663563376333623031636462323138326639386462363361653234386132303466313439
32626539656562313165663931323265613063653431633064356633373837313861623037333865
66326138353530646439653438303463313037616330333964623265303637306239616532666161
30343539626164366438
Import inventory to AWX
EXPECTED RESULTS
I expected to see in AWX inventory host variables:
encrypted_variable:
__ansible_vault: |
$ANSIBLE_VAULT;1.2;AES256;myvaultid
37393937383739363161306133623566396530626562373962616235626636383564626631613832
6534623133626365303931636563346663386335636230350a383832343462313832633464373431
31346430346364636538353863383966343364316336366430616635643034356365653063636630
6561336336613637660a343965343137373032636466383566656430663465646335313632363861
37306136663563376333623031636462323138326639386462363361653234386132303466313439
32626539656562313165663931323265613063653431633064356633373837313861623037333865
66326138353530646439653438303463313037616330333964623265303637306239616532666161
30343539626164366438
ACTUAL RESULTS
Imported data looks like this:
encrypted_variable:
__ansible_vault: >
$ANSIBLE_VAULT;1.2;AES256;myvaultid
37393937383739363161306133623566396530626562373962616235626636383564626631613832
6534623133626365303931636563346663386335636230350a383832343462313832633464373431
31346430346364636538353863383966343364316336366430616635643034356365653063636630
6561336336613637660a343965343137373032636466383566656430663465646335313632363861
37306136663563376333623031636462323138326639386462363361653234386132303466313439
32626539656562313165663931323265613063653431633064356633373837313861623037333865
66326138353530646439653438303463313037616330333964623265303637306239616532666161
30343539626164366438
ADDITIONAL INFORMATION
I tested by manually modifying the variable to my expected result. It seems to work until I switch between JSON-YAML views in the view. The conversion process adds the extra empty lines and changes the block style.
The JSON view appears as (which seems correct?):
"encrypted_variable": {
"__ansible_vault": "$ANSIBLE_VAULT;1.2;AES256;myvaultid\n37393937383739363161306133623566396530626562373962616235626636383564626631613832\n6534623133626365303931636563346663386335636230350a383832343462313832633464373431\n31346430346364636538353863383966343364316336366430616635643034356365653063636630\n6561336336613637660a343965343137373032636466383566656430663465646335313632363861\n37306136663563376333623031636462323138326639386462363361653234386132303466313439\n32626539656562313165663931323265613063653431633064356633373837313861623037333865\n66326138353530646439653438303463313037616330333964623265303637306239616532666161\n30343539626164366438\n"
}
It seems like wrong block style is used?