Now, the best solution will be to stick to using keystore content especially for passwords.
For something like cat /file/containing/setting/value | filebeat keystore add ES_PWD --stdin --force
and then use it in the yml file: output.elasticsearch.password: "${ES_PWD}"
How to use that in ansible, I don't want to reinvent the wheel.
Here you should find a working example, you just need to translate it from kibana to filebeat command style:
The similar should be possible with a remote exec provisioner:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.