mrlesmithjr / ansible-guacamole

Ansible role to install/configure Guacamole
MIT License
19 stars 15 forks source link

Old extension are never cleaned #30

Closed roumano closed 8 months ago

roumano commented 1 year ago

Describe the bug If we upgrade the guacamole version via this role old guacamole extension are never remove

as consequence tomcat failed to deploy the guacamole.war

To Reproduce Steps to reproduce the behavior: Set guacamole_version to 1.5.2 Deploy the guacamole with one or several extension ( so need guacamole_mysql_auth: true and/or guacamole_totp: true and/or guacamole_ldap is defined)

Update guacamole_version variable to 1.5.3 Deploy with ansible in guacamole server, previous and actual extension are installed :

root@guacamole02:/etc/guacamole/extensions# ls -la
total 55684
drwxr-xr-x 2 tomcat tomcat     4096 Sep  5 10:00 .
drwxr-xr-x 4 tomcat tomcat     4096 Sep  5 10:00 ..
-rw-r--r-- 1 tomcat tomcat 10814736 May 20 07:59 guacamole-auth-jdbc-mysql-1.5.2.jar
-rw-r--r-- 1 tomcat tomcat 10998186 Jul 26 08:01 guacamole-auth-jdbc-mysql-1.5.3.jar
-rw-r--r-- 1 tomcat tomcat 12260887 May 20 07:59 guacamole-auth-ldap-1.5.2.jar
-rw-r--r-- 1 tomcat tomcat 13096260 Jul 26 08:01 guacamole-auth-ldap-1.5.3.jar
-rw-r--r-- 1 tomcat tomcat  4819527 May 20 07:59 guacamole-auth-totp-1.5.2.jar
-rw-r--r-- 1 tomcat tomcat  4910381 Jul 26 08:02 guacamole-auth-totp-1.5.3.jar

As it's trying to enable previous and actual extension, tomcat failed to deploy guacamole.war :

==> catalina.out <==
[2023-09-05 10:13:14] [info] At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
[2023-09-05 10:13:14] [info] 10:13:14.652 [main] INFO  o.a.g.environment.LocalEnvironment - GUACAMOLE_HOME is "/etc/guacamole".
[2023-09-05 10:13:14] [info] 10:13:14.787 [main] INFO  o.a.g.GuacamoleServletContextListener - Read configuration parameters from "/etc/guacamole/guacamole.properties".
[2023-09-05 10:13:14] [info] 10:13:14.791 [main] INFO  o.a.g.rest.auth.HashTokenSessionMap - Sessions will expire after 60 minutes of inactivity.
[2023-09-05 10:13:15] [info] 10:13:15.553 [main] INFO  o.a.g.extension.ExtensionModule - Multiple extensions are installed and will be loaded in order of decreasing priority:
[2023-09-05 10:13:15] [info] 10:13:15.553 [main] INFO  o.a.g.extension.ExtensionModule -  - [mysql] "MySQL Authentication" (/etc/guacamole/extensions/guacamole-auth-jdbc-mysql-1.5.2.jar)
[2023-09-05 10:13:15] [info] 10:13:15.554 [main] INFO  o.a.g.extension.ExtensionModule -  - [mysql] "MySQL Authentication" (/etc/guacamole/extensions/guacamole-auth-jdbc-mysql-1.5.3.jar)
[2023-09-05 10:13:15] [info] 10:13:15.554 [main] INFO  o.a.g.extension.ExtensionModule -  - [ldap] "LDAP Authentication" (/etc/guacamole/extensions/guacamole-auth-ldap-1.5.2.jar)
[2023-09-05 10:13:15] [info] 10:13:15.554 [main] INFO  o.a.g.extension.ExtensionModule -  - [ldap] "LDAP Authentication" (/etc/guacamole/extensions/guacamole-auth-ldap-1.5.3.jar)
[2023-09-05 10:13:15] [info] 10:13:15.554 [main] INFO  o.a.g.extension.ExtensionModule -  - [totp] "TOTP TFA Authentication Backend" (/etc/guacamole/extensions/guacamole-auth-totp-1.5.2.jar)
[2023-09-05 10:13:15] [info] 10:13:15.554 [main] INFO  o.a.g.extension.ExtensionModule -  - [totp] "TOTP TFA Authentication Backend" (/etc/guacamole/extensions/guacamole-auth-totp-1.5.3.jar)
[2023-09-05 10:13:15] [info] 10:13:15.554 [main] INFO  o.a.g.extension.ExtensionModule - To change this order, set the "extension-priority" property or rename the extension files. The default priority of extensions is dictated by the sort order of their filenames.
[2023-09-05 10:13:15] [info] 10:13:15.567 [main] INFO  o.a.g.a.mysql.conf.MySQLEnvironment - Installed JDBC driver for MySQL/MariaDB detected as "MySQL Connector/J".
[2023-09-05 10:13:16] [info] 10:13:16.527 [main] INFO  o.a.g.extension.ExtensionModule - Extension "MySQL Authentication" (mysql) loaded.
[2023-09-05 10:13:16] [info] 10:13:16.559 [main] INFO  o.a.g.a.mysql.conf.MySQLEnvironment - Installed JDBC driver for MySQL/MariaDB detected as "MySQL Connector/J".
[2023-09-05 10:13:17] [info] 10:13:17.416 [main] INFO  o.a.g.extension.ExtensionModule - Extension "MySQL Authentication" (mysql) loaded.
[2023-09-05 10:13:17] [info] 10:13:17.597 [main] WARN  o.a.g.e.LanguageResourceService - Overlay language resource "de" does not exist.
[2023-09-05 10:13:17] [info] 10:13:17.601 [main] INFO  o.a.g.extension.ExtensionModule - Extension "LDAP Authentication" (ldap) loaded.
[2023-09-05 10:13:17] [info] 10:13:17.758 [main] WARN  o.a.g.e.LanguageResourceService - Overlay language resource "de" does not exist.
[2023-09-05 10:13:17] [info] 10:13:17.762 [main] INFO  o.a.g.extension.ExtensionModule - Extension "LDAP Authentication" (ldap) loaded.
[2023-09-05 10:13:17] [info] 10:13:17.942 [main] INFO  o.a.g.extension.ExtensionModule - Extension "TOTP TFA Authentication Backend" (totp) loaded.
[2023-09-05 10:13:18] [info] 10:13:18.121 [main] INFO  o.a.g.extension.ExtensionModule - Extension "TOTP TFA Authentication Backend" (totp) loaded.
[2023-09-05 10:13:18] [info] 10:13:18.250 [main] INFO  o.a.g.t.w.WebSocketTunnelModule - Loading JSR-356 WebSocket support...
[2023-09-05 10:13:18] [crit] One or more listeners failed to start. Full details will be found in the appropriate container log file

==> localhost.2023-09-05.log <==
05-Sep-2023 10:13:18.379 SEVERE [main] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class [org.apache.guacamole.GuacamoleServletContextListener]
    com.google.inject.CreationException: Unable to create injector, see the following errors:

1) More than one servlet was mapped to the same URI pattern: /app/ext/totp/templates/authenticationCodeField.html
  at ExtensionModule.serveStaticResources(ExtensionModule.java:387)

1 error

======================
Full classname legend:
======================
ExtensionModule: "org.apache.guacamole.extension.ExtensionModule"
========================
End of classname legend:
========================

        at com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:576)
        at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:163)
        at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:110)
        at com.google.inject.Guice.createInjector(Guice.java:87)
        at com.google.inject.Guice.createInjector(Guice.java:78)
        at org.apache.guacamole.GuacamoleServletContextListener.lambda$getInjector$0(GuacamoleServletContextListener.java:193)
        at java.base/java.util.concurrent.atomic.AtomicReference.updateAndGet(AtomicReference.java:209)
        at org.apache.guacamole.GuacamoleServletContextListener.getInjector(GuacamoleServletContextListener.java:186)
        at com.google.inject.servlet.GuiceServletContextListener.contextInitialized(GuiceServletContextListener.java:45)
        at org.apache.guacamole.GuacamoleServletContextListener.contextInitialized(GuacamoleServletContextListener.java:173)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4716)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5177)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:717)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:706)
        at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:946)
        at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1792)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
        at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:757)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:426)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1520)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:309)
        at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
        at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
        at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:843)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1384)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1374)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
        at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:140)
        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:909)
        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:434)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:772)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:477)

==> catalina.2023-09-05.log <==
05-Sep-2023 10:13:18.380 SEVERE [main] org.apache.catalina.core.StandardContext.startInternal One or more listeners failed to start. Full details will be found in the appropriate container log file

Expected behavior a new ansible tasks need to be created to remove previous extension

i was able to fix the issue via creating this 2 simple tasks :

- name: config | list previous exensions version
  ansible.builtin.find:
    paths: "/etc/guacamole/extensions/"
    excludes: '*{{ guacamole_version }}*'
    file_type: file
  register: guacamole_previous_extensions

- name: config | Delete previous exensions version
  ansible.builtin.file:
    path: "{{ guacamole_extension.path }}"
    state: absent
  loop: "{{ guacamole_previous_extensions.files }}"
  loop_control:
    loop_var: guacamole_extensions
stale[bot] commented 10 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

roumano commented 10 months ago

I proposed a fix on my previous information, it's sufficient or do you need/want a PR ?

mrlesmithjr commented 10 months ago

@roumano feel free to submit a PR and I’ll be glad to review and merge in.

mrlesmithjr commented 10 months ago

@roumano - Merged and thanks for the contribution