Hi!

I wrote a simple playbook that downloads, extracts and starts Tomcat. Here 
are the relevant parts of it:

- name: Download Tomcat 7.0.42
  get_url: 
url=http://archive.apache.org/dist/tomcat/tomcat-7/v7.0.42/bin/apache-tomcat-7.0.42.tar.gz
 
dest=/home/tomcat/apache-tomcat-7.0.42.tar.gz

- name: Extract Tomcat
  command: chdir=/home/tomcat tar -xvzf apache-tomcat-7.0.42.tar.gz 
creates=/home/tomcat/apache-tomcat-7.0.42

- name: Change ownership of Tomcat installation
  file: path=/home/tomcat/apache-tomcat-7.0.42 owner=tomcat group=tomcat 
state=directory recurse=yes

- name: Configure Tomcat server
  template: src=tomcat-users.xml 
dest=/home/tomcat/apache-tomcat-7.0.42/conf/
  notify: restart tomcat
  
- name: Set JAVA_HOME for tomcat
  lineinfile: dest=/home/tomcat/apache-tomcat-7.0.42/bin/setenv.sh 
line='export JAVA_HOME=/opt/java/jdk1.7.0_51' create=yes state=present 
mode=0555

- name: Start Tomcat
  command: /home/tomcat/apache-tomcat-7.0.42/bin/startup.sh
  sudo: true
  sudo_user: tomcat
    
- name: wait for tomcat to start
  wait_for: port=8080

The wait step always times out because Tomcat doesn't start. The strange 
thing is that when I execute the startup.sh script on the vm's shell it 
works. And Ansible doesn't complain it says that the step was executed 
successfully. Here's the output with 'vvvv':

TASK: [tomcat | Start Tomcat] 
************************************************* 

<127.0.0.1> ESTABLISH CONNECTION FOR USER: vagrant

<127.0.0.1> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 
'ControlPersist=60s', '-o', 
'ControlPath=/Users/asahli/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 
'Port=2222', '-o', 
'IdentityFile=/Users/asahli/.vagrant.d/insecure_private_key', '-o', 
'KbdInteractiveAuthentication=no', '-o', 
'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', 
'-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 
'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'mkdir -p 
/tmp/ansible-1391975068.22-50068957235035 && chmod a+rx 
/tmp/ansible-1391975068.22-50068957235035 && echo 
/tmp/ansible-1391975068.22-50068957235035'"]

<127.0.0.1> REMOTE_MODULE command 
/home/tomcat/apache-tomcat-7.0.42/bin/startup.sh

<127.0.0.1> PUT /var/folders/vj/fw7zgzj93j371115rb1mtvv00000gn/T/tmpcOMgD0 
TO /tmp/ansible-1391975068.22-50068957235035/command

<127.0.0.1> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 
'ControlPersist=60s', '-o', 
'ControlPath=/Users/asahli/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 
'Port=2222', '-o', 
'IdentityFile=/Users/asahli/.vagrant.d/insecure_private_key', '-o', 
'KbdInteractiveAuthentication=no', '-o', 
'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', 
'-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 
'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'chmod a+r 
/tmp/ansible-1391975068.22-50068957235035/command'"]

<127.0.0.1> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 
'ControlPersist=60s', '-o', 
'ControlPath=/Users/asahli/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 
'Port=2222', '-o', 
'IdentityFile=/Users/asahli/.vagrant.d/insecure_private_key', '-o', 
'KbdInteractiveAuthentication=no', '-o', 
'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', 
'-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 
'ConnectTimeout=10', '127.0.0.1', '/bin/sh -c \'sudo -k && sudo -H -S -p 
"[sudo via ansible, key=pqvlljvxxezlskhjkospaalznznwlzdy] password: " -u 
tomcat /bin/sh -c \'"\'"\'echo 
SUDO-SUCCESS-pqvlljvxxezlskhjkospaalznznwlzdy; /usr/bin/python 
/tmp/ansible-1391975068.22-50068957235035/command\'"\'"\'\'']

<127.0.0.1> EXEC ['ssh', '-tt', '-vvv', '-o', 'ControlMaster=auto', '-o', 
'ControlPersist=60s', '-o', 
'ControlPath=/Users/asahli/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 
'Port=2222', '-o', 
'IdentityFile=/Users/asahli/.vagrant.d/insecure_private_key', '-o', 
'KbdInteractiveAuthentication=no', '-o', 
'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', 
'-o', 'PasswordAuthentication=no', '-o', 'User=vagrant', '-o', 
'ConnectTimeout=10', '127.0.0.1', "/bin/sh -c 'rm -rf 
/tmp/ansible-1391975068.22-50068957235035/ >/dev/null 2>&1'"]

changed: [tp-web-proxy] => {"changed": true, "cmd": 
["/home/tomcat/apache-tomcat-7.0.42/bin/startup.sh"], "delta": 
"0:00:00.006908", "end": "2014-02-09 19:44:28.235406", "item": "", "rc": 0, 
"start": "2014-02-09 19:44:28.228498", "stderr": "", "stdout": "Using 
CATALINA_BASE:   /home/tomcat/apache-tomcat-7.0.42\nUsing CATALINA_HOME:   
/home/tomcat/apache-tomcat-7.0.42\nUsing CATALINA_TMPDIR: 
/home/tomcat/apache-tomcat-7.0.42/temp\nUsing JRE_HOME:        
/opt/java/jdk1.7.0_51\nUsing CLASSPATH:       
/home/tomcat/apache-tomcat-7.0.42/bin/bootstrap.jar:/home/tomcat/apache-tomcat-7.0.42/bin/tomcat-juli.jar"}

On IRC somebody gave me that hint: "something that tomcat wants (from your 
shell env) seems like it's missing from running the command without a 
terminal started". But I can't find out what's missing.

Does somebody know this problem?

Thanks for your help!

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to