0

I'm in the middle of automating some processes in a VM, we are currently using java 17 and have updated out jettys to jetty-11. Since in jetty-11 both home and base are separate it's important to initialize the jetty-base folder. I need to do it from ansible I worked out a solution in local shell but trying that in ansible it's not working

- name: "Run initialization command" 
  shell: "nohup java -jar '{{ jetty_home }}'/start.jar jetty.base='{{ jetty_install_dir }}' --add-module=server,http,deploy,annotations,logging-jetty,jsp &"

There are no obvious errors when I run the playbook, just

TASK [jetty-distribution : initialize jetty-base] **************************************************************************************************************************
changed: [****************************] (cutting the vm name off)

Is there any solutions to this issue ? Thanks in advance

Rahim T.S
  • 13
  • 5
  • 2
    What does not work? The playbook execution states that it has run (changed ...). – pringi Mar 02 '22 at 14:46
  • 1
    Using `nohup` in ansible `shell` looks like a very bad idea. Are you simply trying to run that command async ? Or is it supposed to run forever ? For first case see https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html, for second make it a real service. – Zeitounator Mar 02 '22 at 17:01
  • Yeah I just want the jetty-base to be initialized, it doesn't have to run forever. – Rahim T.S Mar 03 '22 at 04:38

1 Answers1

0

You most definately should be using 2 separate directories.

(repeated here for others that see this question in the future)

  1. The jetty.home directory.
    This is for the jetty distribution (or the more modern jetty-home tarball/zip).
    The jetty.home directory is sacred, don't edit/change/remove/add/modify ANYTHING in this directory. You don't need to, for any possible configuration you can come up with (trust me).

  2. The jetty.base directory.
    This is the directory for your configuration, or instance of Jetty.
    Make sure this directory does not nest inside/outside of the jetty.home directory, you'll just make your life needless complicated when it's time to upgrade (or even downgrade) your Jetty version.

Next, when it comes to initialization, turn off nuhup, that just hides any errors you might have during initialization. The --add-module command is terminal anyway and will do what it needs and then exit, it's not a daemon and keeps running. If you don't want to see the output, at least redirect it to an output file you can interrogate if there's issues.

Don't put it in the background either (the & at the end), the exit code will be useful to you if an error occurs.

aka

java -jar /path/to/jetty-home/start.jar \
  jetty.home=/path/to/jetty-home \
  jetty.base=/path/to/my-jetty-base \
  --add-module=http,deploy,annotations,logging-jetty,jsp \
  2>&1 > /path/to/my-jetty-base/jetty-init.log

Keep in mind that some modules, when added, require user interaction (to accept licenses). This can be handled in scripts by using the --approve-all-licenses option on start.jar.

Lastly, are you sure ansible supports the "Jakarta Big Bang" namespace changes that Jetty 11 implements?

See past answer on this: https://stackoverflow.com/a/66368511/775715

If ansible has updated to Jakarta EE 9, then go ahead and use Jetty 11, if they haven't, then stick with Jetty 10 (which is on Jakarta EE 8) until such time that ansible catches up with the rest of the world.

Joakim Erdfelt
  • 46,896
  • 7
  • 86
  • 136