Preventing a deploy of tomcat from running again.

54 views
Skip to first unread message

Chris Brooks

unread,
Apr 14, 2015, 7:16:03 AM4/14/15
to ansible...@googlegroups.com
Hiya,

I've had a google for this but I can't find anything which answer my question...

I have a playbook which deploys tomcat via a zip file, this is the standard tomcat file from their website.

it then takes a template of server.xml and places it in the /opt/tomcat/conf directory.

This action changes the contents so the next time my playbook runs it re-runs the play which I don't want, is there an easy way around this?

This is the relevant section:-

########################################################################################


  - name: Add tomcat group
    group: name=tomcat state=present

  - name: Add tomcat user
    user: name=tomcat group=tomcat state=present

  - name: copy the jdk to the local machine
    copy: src=files/jdk-8u40-linux-x64.rpm dest=/tmp/jdk-8u40-linux-x64.rpm

  - name: install the JDK from a local file
    yum: name=/tmp/jdk-8u40-linux-x64.rpm state=present

  - name: unpack tomcat
    unarchive: src=files/apache-tomcat-8.0.20.tar.gz dest=/opt/

  - name: symlink /opt/tomcat to apache tomcat
    file: src=/opt/apache-tomcat-8.0.20 path=/opt/tomcat state=link force=yes

  - name: generate the server.xml from the template
    template: src=tomcat/templates/server.xml.j2 dest=/opt/tomcat/conf/server.xml mode=755

  - name: install the init.d script for tomcat
    template: src=tomcat/templates/tomcat.initd.j2 dest=/etc/init.d/tomcat mode=755

  - name: make sure it is all owned by tomcat
    file: path=/opt/apache-tomcat-8.0.20 owner=tomcat group=tomcat state=directory recurse=yes

########################################################################################

Edgars

unread,
Apr 14, 2015, 8:23:06 AM4/14/15
to ansible...@googlegroups.com
unarchive module supports creates parameter:

creates
    a filename, when it already exists, this step will not be run. (added in Ansible 1.6)

    Edgars
    Reply all
    Reply to author
    Forward
    0 new messages