0

I am trying to upgrade some Jboss servers for my application running on remote nodes using Ansible. Through Ansible I can invoke a jboss server start script which has to upgrade and start my server on remote node. Problem is that the script internally takes a configuration property file as an argument which resides on the remote server (there are many such servers and every server has different configuration property file which resides within the remote node server so I cannot keep these files locally on ansible controller machine) on which actually upgrade is running. However Ansible expects that the resource file should be available on ansible controller (locally) and fails to do the upgrade.

Is there any way I can instruct Ansible to find the particular resource or file directly on the remote node rather then finding it locally and then copying every resource on remote node for execution?

Ansible Playbook file contents

---

- name: Upgrade Server
  hosts: remote_host
  connection: ssh
  vars:
    server_version: 188
    server_name: UpgradeTest
  tasks:
    - name: Start server
      shell: "{{ jboss_home }}/bin/startJBossServer.sh {{ server_name }} >/dev/null 2>&1 &"

    - name: Wait for port {{ server_http_port }} to come up
      wait_for: host="localhost" port="{{ server_http_port }}" delay=15 timeout=300 state=started

    - name: Test server is up and running
      action: uri url="http://localhost:{{ server_http_port }}/{{ server_name }}" return_content=yes timeout=90
      register: webpage
      until: webpage.status == 200
      retries: 25
      delay: 5

The file startJBossServer.sh contains the following command:

nohup "${JBOSS_HOME}/bin/standalone.sh" -Djboss.server.base.dir=${JBOSS_HOME}/${i_server_name} -b=0.0.0.0 -c=@fm.config.xml@ -P=${start_server_properties_file} </dev/null > "/dev/null" 2>&1 &

If you can see we need ${start_server_properties_file} in -P argument which actually is available on remote node server, however Ansible expects the same resource to be available on local machine and hence fails to run the command.

Thomas Hirsch
  • 2,102
  • 3
  • 19
  • 39
Mayank
  • 13
  • 4

0 Answers0