The only solution I found so far was:
playbook1:
Set the facts, and save to a file
On playbook2:
Vars:
ansible_user: "{{lookup(file',('userfactsfile')}}"
ansible_ssh_pass: "{{lookup(file',('passfactsfile')}}"
Tasks:
- import_playbook: playbook1.yml
...
my actions here
...
delete userfactsfile
delete passfactsfile
There is still a problem: the password is saved in clear text for the duration of the playbook run. If there is an unexpected interruption in the process, the password file might be left stored in the server (which is the primary concern being addressed in this very same work).
An acceptable solution would be:
Encrypt the password before saving it to file in paybook1, However, I faced some technical challenges (I am pretty noob in Ansible), but still a viable solution if I could achieve.
The encryption in playbook1 would use the actual password as passphrase.The passphrase is persistent across both playbooks, in a fact.
In playbook2, this password would be used to decrypt the password file in the Vars lookup.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…