Closed diLLec closed 7 months ago
As noted in the summary, I've tracked the problem to the following line in lib\ansible\plugins\connection\httpapi.py:241
self.httpapi.login(self.get_option('remote_user'), self.get_option('password'))
The get_options originates in lib/ansible/plugins/__init__.py
. Putting the following there, will show that in the "EXPECTED RESULTS" case the decrypted password is returned (...'password': 'test',...
)and in the "ACTUAL RESULTS" the vault dict is returned ('password': {'__ansible_vault': '$ANSIBLE_VAULT;1....
)
import traceback
if option == 'password':
raise Exception("%s -- %s" % (self._options, traceback.format_stack()))
From the other connection plugins, I've already seen that self._play_context is used. I've replace the line with
self.httpapi.login(self._play_context.remote_user, self._play_context.password)
which worked. As I don't know the side effects of this, please review :-).
I could be wrong, but the issue looks like it is in module_utils/connection.py on line 142:
data = json.dumps(req, cls=AnsibleJSONEncoder)
Should vault_to_text=true
argument be passed in here?
Looks like there's already an issue with ansible.
indeed - should have been fixed by: https://github.com/ansible/ansible/pull/78236
Closing it off, as the issue is already fixed in https://github.com/ansible/ansible/pull/78236 Regards
SUMMARY
While using httpapi with the collection fortinet.fortios (version 1.0.11) the modules will report
quote_from_bytes() expected bytes
if used after include_vars or set_fact, because the "password" option of httapi will contain the vault dict instead of the actual password whenself.httpapi.login(self.get_option('remote_user'), self.get_option('password'))
is called inlib\ansible\plugins\connection\httpapi.py:241
ISSUE TYPE
COMPONENT NAME
connection plugin -> httpapi
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Ubuntu in WSL
STEPS TO REPRODUCE
inventory
playbook
EXPECTED RESULTS
If set_fact is obtained - the result is:
Note: The same behavior can be seen if assert or include_vars is used
ACTUAL RESULTS