I'm writing a Ansible module to configure software The supplier requires that the configuration commands must be executed under a specific user. If you do it under 'root' you will get an error.
So mu current solution is:
module = AnsibleModule(....)
command='su - <user> -c "<command>"'
result = module.run_command(command)
It works but I'm not really happy with this. I could also let Ansible do it and use become
and become_user
. But then you must document this properly and you will get a higher change of errors because people do not always read the documentation.
So I'm curious what could be the best way to go or is there another way to solve this.