简体   繁体   English

ansible shell /命令模块未在远程计算机上执行脚本

[英]ansible shell/command module not executing script at remote machine

While trying to run startup.sh script for Tomcat-8, I am getting below error. 尝试为Tomcat-8运行startup.sh脚本时,出现以下错误。 Playbook is executing successfully with STDOUT- "Tomcat started" but it is not reflecting in the remote machine. Playbook使用STDOUT成功执行-“ Tomcat已启动”,但未反映在远程计算机中。 The error is there for both modules - command and shell 两个模块都存在错误-命令和外壳

- name: Download Tomcat version 8
  get_url: 
  url: http://mirrors.wuchna.com/apachemirror/tomcat/tomcat-8/v8.5.35/bin/apache-tomcat-8.5.35.tar.gz 
  dest: /tmp/apache-tomcat-8.5.35.tar.gz

- name: Untar Tomcat to /opt
  shell: tar -zxvf apache-tomcat-8.5.35.tar.gz -C /opt
  args:
    chdir: /tmp/
    warn: False

- name: Change permissions of Tomcat folder
  file:
    path: /opt/apache-tomcat-8.5.35
    mode: 0777
    recurse: yes

- name: Set Catalina Home
  lineinfile:
    path: /etc/profile.d/maven.sh
    regexp: '^#?\s*export CATALINA_HOME=(.*)$'
    line: 'export CATALINA_HOME=/opt/apache-tomcat-8.5.35'
    state: present

- name: execute source
  shell: source maven.sh
  args:
    chdir: /etc/profile.d/
    executable: /bin/sh

- name: start catalina
  become: true
  command: /opt/apache-tomcat-8.5.35/bin/startup.sh &>> /var/log/log.txt

Tried running your tasks in a playbook on Centos7 and it executes successfully with Tomcat up and healthy. 尝试在Centos7上的剧本中运行任务,并且在Tomcat正常运行的情况下成功执行。 (Had to install maven first) I might need more info to debug this. (必须先安装Maven)我可能需要更多信息来调试它。

  • Q: Are you planning to run tomcat as root user? 问:您打算以root用户身份运行tomcat吗? (if you are.. you shouldn't) (如果您是..您不应该)
  • Q: What is the OS on remote? 问:远程操作系统是什么?
  • Q: Have you installed JRE or JDK properly ? 问:您是否正确安装了JRE或JDK?

Have a look at this example: https://github.com/ansible/ansible-examples/tree/master/tomcat-standalone 看一下这个例子: https : //github.com/ansible/ansible-examples/tree/master/tomcat-standalone

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM