Hi, all
We have an application stop/start script that starts/stops application without root privilege and with 'sudo'.
If I am on the host, I login as the application user and then run the script to stop/start application as 'sudo application_stop_start.sh stop/start'.
On the ansible server (v2.7), I created a simple test file. The application user ID is the same on ansible host and remote node (ssh authentication has no problem)
tasks:
- name: run script to stop/start application
command: sudo /usr/local/bin/application_stop_start.sh stop
It ran successfully on the remote host with a warning message.
PLAY [Stop application] *********************************************************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************************************************************
ok: [host1]
TASK [run application_stop_start.sh script to stop application] **********************************************************************************************************************************************************************************************
[WARNING]: Consider using 'become', 'become_method', and 'become_user' rather than running sudo
changed: [host1]
PLAY RECAP **********************************************************************************************************************************************************************************************************************************
host1 : ok=2 changed=1 unreachable=0 failed=0
I don't need 'become' and 'become_user' at least since the UID is the same. Tried to use 'become_method = sudo' and remove 'sudo' from 'command: /usr/local/bin/application_stop_start.sh stop' and it did not work. Does anyone have any suggestions?
Thanks.