We don’t use root directly in ansible in most cases. Instead, we prefer a common
user to execute some tasks in sudo mode. By doing so, we can keep the security.
Let’s make an example, we try to manage tomcat init script by using ansible become
first create a common user and switch to it
yaml file content
but we met an error when run it directly(run below command by classmate user)
we try it one more time in debug mode to check detail
configure sudoer on test-host to solve it