tomcat - ansible jar check if already installed -


i'm having jar file installs tomcat website. have following tasks download jar file, install jar file , delete jar file. want ansible tell installed instead of downloading , trying install again. how can achieve such?

- name: downloading installer   get_url:   url: http://[url]/installfile.jar   dest: "/opt"  - name: installing jar file   shell: java -jar "/opt/installfile.jar"  - name: removing installer   file:   state: absent   path: "/opt/installfile.jar" 

you can use creates arg on install task @ least, java program run when file not yet exist. ansible create such file first time task runs.

something like:

- name: installing jar file   shell: java -jar "/opt/installfile.jar"   args:     creates: /opt/installfile-check 

or if want condition 3 tasks run when tomcat not installed, need first run program checks whether installed , register result in variable other tasks can use determine if need run using when.

- name: check see if tomcat installed   shell: "command --that --checks" # example,   register: tomcat_is_installed 

you can include tomcat playbook when not installed:

- name: playbook included when tomcat not installed   include: tomcat-playbook.yml   when: tomcat_is_installed.rc != 0 

Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -