1、 使用$需要\转义符

ansible was -m shell -a "ps -ef | grep java | grep was2 | grep -v grep | awk '{print \$NF}'"