wcm-io-devops / ansible-jenkins-pipeline-library

Ansible role for setting up a Jenkins instance for the jenkins-pipeline-library
Apache License 2.0
2 stars 2 forks source link

Jenkins Startup Errors using wcm_io_devops.jenkins_pipeline_library version 2.249.2-1 #29

Closed timblaktu closed 3 years ago

timblaktu commented 3 years ago

After working through the "A later version is already installed" problem and the Java version Check bug in Jenkins Debian Package I'm now running jenkins_pipeline_library version 2.249.2-1, but Jenkins is crashing at first startup, with what looks like a lot of plugin load errors in /var/log/jenkins.log (see below for excerpt).

The only clue that I can see in this so far is that it appears that several of these failed plugins report a version newer than what your release page indicates should be installed for that version. For example, the log indicates Failed to load: Branch API Plugin (2.6.3), however your release page indicates 2.6.0 should be installed by this release. In this example, the Branch API Plugin 2.6.3 fails to load indicating that "Jenkins (2.264) or higher required".

So it appears that something in the plugin version locking is not working properly in this role.

Let me know what I can do to help troubleshoot this.

Running from: /usr/share/jenkins/jenkins.war
2020-12-15 21:53:59.105+0000 [id=1]     INFO    org.eclipse.jetty.util.log.Log#initialized: Logging initialized @317ms to org.eclipse.jetty.util.log.JavaUtilLog
2020-12-15 21:53:59.192+0000 [id=1]     WARNING o.e.j.s.handler.ContextHandler#setContextPath: Empty contextPath
2020-12-15 21:53:59.244+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: jetty-9.4.30.v20200611; built: 2020-06-11T12:34:51.929Z; git: 271836e4c1f4612f12b7bb13ef5a92a927634b0d; jvm 11.0.9.1+1-post-Debian-1deb10u2
2020-12-15 21:53:59.523+0000 [id=1]     INFO    o.e.j.w.StandardDescriptorProcessor#visitServlet: NO JSP Support for /, did not find org.eclipse.jetty.jsp.JettyJspServlet
2020-12-15 21:53:59.557+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: DefaultSessionIdManager workerName=node0
2020-12-15 21:53:59.557+0000 [id=1]     INFO    o.e.j.s.s.DefaultSessionIdManager#doStart: No SessionScavenger set, using defaults
2020-12-15 21:53:59.560+0000 [id=1]     INFO    o.e.j.server.session.HouseKeeper#startScavenging: node0 Scavenging every 660000ms
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.thoughtworks.xstream.core.util.Fields (file:/var/cache/jenkins/war/WEB-INF/lib/xstream-1.4.7-jenkins-1.jar) to field java.util.TreeMap.comparator
WARNING: Please consider reporting this to the maintainers of com.thoughtworks.xstream.core.util.Fields
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-12-15 21:53:59.923+0000 [id=1]     INFO    hudson.WebAppMain#contextInitialized: Jenkins home directory: /home/jenkins/.jenkins found at: EnvVars.masterEnvVars.get("JENKINS_HOME")
2020-12-15 21:54:00.049+0000 [id=1]     INFO    o.e.j.s.handler.ContextHandler#doStart: Started w.@52b56a3e{Jenkins v2.249.2,/,file:///var/cache/jenkins/war/,AVAILABLE}{/var/cache/jenkins/war}
2020-12-15 21:54:00.070+0000 [id=1]     INFO    o.e.j.server.AbstractConnector#doStart: Started ServerConnector@66d1af89{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
2020-12-15 21:54:00.071+0000 [id=1]     INFO    org.eclipse.jetty.server.Server#doStart: Started @1283ms
2020-12-15 21:54:00.072+0000 [id=34]    INFO    winstone.Logger#logInternal: Winstone Servlet Engine running: controlPort=disabled
2020-12-15 21:54:00.356+0000 [id=44]    INFO    jenkins.InitReactorRunner$1#onAttained: Started initialization
2020-12-15 21:54:00.647+0000 [id=63]    INFO    jenkins.InitReactorRunner$1#onAttained: Listed all plugins
2020-12-15 21:54:01.147+0000 [id=64]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Branch API Plugin v2.6.3 (branch-api)
java.io.IOException: Failed to load: Branch API Plugin (2.6.3)
 - Jenkins (2.264) or higher required
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.148+0000 [id=63]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Basic Branch Build Strategies Plugin v1.3.2 (basic-branch-build-strategies)
java.io.IOException: Failed to load: Basic Branch Build Strategies Plugin (1.3.2)
 - Failed to load: Branch API Plugin (2.6.3)
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.152+0000 [id=44]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Pipeline: Basic Steps v2.23 (workflow-basic-steps)
java.io.IOException: Failed to load: Pipeline: Basic Steps (2.23)
 - Jenkins (2.263) or higher required
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.156+0000 [id=43]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Docker Pipeline v1.25 (docker-workflow)
java.io.IOException: Failed to load: Docker Pipeline (1.25)
 - Failed to load: Pipeline: Basic Steps (2.23)
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.157+0000 [id=43]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Pipeline: Multibranch v2.22 (workflow-multibranch)
java.io.IOException: Failed to load: Pipeline: Multibranch (2.22)
 - Failed to load: Branch API Plugin (2.6.3)
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.158+0000 [id=56]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Pipeline SCM API for Blue Ocean v1.24.3 (blueocean-pipeline-scm-api)
java.io.IOException: Failed to load: Pipeline SCM API for Blue Ocean (1.24.3)
 - Failed to load: Pipeline: Multibranch (2.22)
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.160+0000 [id=44]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Pipeline: Declarative v1.7.2 (pipeline-model-definition)
java.io.IOException: Failed to load: Pipeline: Declarative (1.7.2)
 - Failed to load: Pipeline: Basic Steps (2.23)
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
2020-12-15 21:54:01.160+0000 [id=60]    SEVERE  jenkins.InitReactorRunner$1#onTaskFailed: Failed Loading plugin Pipeline implementation for Blue Ocean v1.24.3 (blueocean-pipeline-api-impl)
java.io.IOException: Failed to load: Pipeline implementation for Blue Ocean (1.24.3)
 - Failed to load: Pipeline SCM API for Blue Ocean (1.24.3)
        at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:952)
        at hudson.PluginManager$2$1$1.run(PluginManager.java:549)
        at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
        at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
        at jenkins.model.Jenkins$5.runTask(Jenkins.java:1131)
        at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
        at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
        at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
.
.
.

Here is the play that is invoking this role:

- name: Install/Configure Jenkins                                                                                                                                                                    tags: ["install", "jenkins"]                                                                                                                                                                       become: true                                                                                                                                                                                       hosts: jenkins_masters
  tasks:
    - include_role:
        name: wcm_io_devops.jenkins_pipeline_library
      vars:
        # Role Variables Documented here: https://github.com/wcm-io-devops/ansible-jenkins-pipeline-library#role-variables

        # Says "do geerlingguy.jenkins role to install jenkins"
        # Jenkins version is dictated by/defaults to the version of wcm_io_devops.jenkins_pipeline_library we're using,
        # whose versioning scheme aligns with Jenkins'.
        jenkins_pipeline_library_jenkins_install: true
        # values for geerlingguy.jenkins
        jenkins_prefer_lts: true
        # required until https://github.com/geerlingguy/ansible-role-jenkins/pull/294 is merged
        jenkins_pkg_url: "https://pkg.jenkins.io/debian-stable/binary"

        jenkins_pipeline_library_jenkins_process_user: "{{ jenkins_linux_user_name }}"
        jenkins_pipeline_library_jenkins_process_group: "{{ jenkins_pipeline_library_jenkins_process_user }}"

        jenkins_pipeline_library_admin_username: "{{ jenkins_admin_active_directory_username }}"
        jenkins_pipeline_library_admin_password: "{{ jenkins_admin_active_directory_password }}"

        jenkins_pipeline_library_jenkins_home: "{{ jenkins_home_dir }}"

        jenkins_pipeline_library_jenkins_hostname: "{{ ansible_fqdn }}"
        jenkins_pipeline_library_jenkins_port: "{{ jenkins_http_port_ }}"
        jenkins_pipeline_library_debug: true

        # Notes about java options:
        # 1. Cloudbees JVM Best Practices:
        #   https://www.jenkins.io/blog/2016/11/21/gc-tuning/
        #   https://docs.cloudbees.com/docs/admin-resources/latest/jvm-troubleshooting/#suggested-specifications
        #   https://support.cloudbees.com/hc/en-us/articles/222446987-Prepare-Jenkins-for-Support
        #   https://support.cloudbees.com/hc/en-us/articles/204859670-Java-Heap-settings-best-practice
        # 2. yaml folded style string format (>) replaces newlines and leading indentation with a single space
        #   Trailing dash (>-) means newline is eliminated at the end of resulting string.
        # 3. -Dhudson.slaves.WorkspaceList=- is there bc poky build cannot handle @ in paths.
        jenkins_java_options_list:
          - "-Djenkins.install.runSetupWizard=false"
          - "-Dhudson.slaves.WorkspaceList=-"
          - "-Dorg.apache.commons.jelly.tags.fmt.timeZone=America/Vancouver"
          - "-Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true"
          - "-Dcom.cloudbees.workflow.rest.external.JobExt.maxRunsPerJob=16"
          # Change Content Security Policy to enable embedding html in job/build pages via htmlpublisher
          # Details:
          # * https://support.cloudbees.com/hc/en-us/articles/360034545912-What-is-Content-Security-Policy-and-how-does-it-impact-Jenkins-
          # * https://wiki.jenkins.io/display/JENKINS/Configuring+Content+Security+Policy
          # * Must include literal \" in string, which is copied into a double-quoted string as JAVA_ARGS in /etc/default/jenkins
          - "-Dhudson.model.DirectoryBrowserSupport.CSP=\\\"sandbox allow-same-origin allow-scripts allow-forms; default-src 'self' 'unsafe-inline' data:; style-src 'self' 'unsafe-inline' fonts.g
          # Extend default docker daemon timeout (from 180sec)
          # https://issues.jenkins-ci.org/browse/JENKINS-42322?focusedCommentId=303679&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-303679                                  - "-Dorg.jenkinsci.plugins.docker.workflow.client.DockerClient.CLIENT_TIMEOUT=300"                                                                                                                 - "-Djenkins.model.Jenkins.logStartupPerformance=true"                                                                                                                                             - "-Xmx{{ (ansible_memtotal_mb / 4 if ansible_memtotal_mb / 4 <= 16384 else 16384) | round | int }}m"                                                                                              - "-Xms{{ (ansible_memtotal_mb / 4 if ansible_memtotal_mb / 4 <= 16384 else 16384) | round | int }}m"                                                                                              - "-XX:+AlwaysPreTouch"                                                                                                                                                                            - "-XX:+HeapDumpOnOutOfMemoryError"                                                                                                                                                                - "-XX:HeapDumpPath={{ jenkins_path_to_gc_and_heap_dump }}"                                                                                                                                        - "-XX:+UseG1GC"                                                                                                                                                                                   - "-XX:+UseStringDeduplication"                                                                                                                                                                    - "-XX:+ParallelRefProcEnabled"                                                                                                                                                                    - "-XX:+DisableExplicitGC"                                                                                                                                                                         - "-XX:+UnlockDiagnosticVMOptions"                                                                                                                                                                 - "-XX:+UnlockExperimentalVMOptions"                                                                                                                                                               - "-verbose:gc"                                                                                                                                                                                    # See here for details: https://c-guntur.github.io/java-gc/#/8/2                                                                                                                                   # - "-Xloggc:{{ jenkins_path_to_gc_and_heap_dump }}/gc-%t.log"  # unrecognized VM option                                                                                                           - "-Xlog:gc:{{ jenkins_path_to_gc_and_heap_dump }}/gc-%t.log"                                                                                                                                      # - "-XX:NumberOfGCLogFiles=2"  # deprecated                                                                                                                                                       # - "-XX:+UseGCLogFileRotation"  # deprecated                                                                                                                                                      # - "-XX:GCLogFileSize=100m"  # deprecated                                                                                                                                                         - "-XX:+PrintGC"                                                                                                                                                                                   # - "-XX:+PrintGCDateStamps"  # deprecated                                                                                                                                                         - "-XX:+PrintGCDetails"                                                                                                                                                                            # - "-XX:+PrintHeapAtGC"  # unrecognized VM option                                                                                                                                                 # - "-XX:+PrintGCCause"  # unrecognized VM option                                                                                                                                                  # - "-XX:+PrintTenuringDistribution"  # unrecognized VM option                                                                                                                                     # - "-XX:+PrintReferenceGC"  # unrecognized VM option                                                                                                                                              # - "-XX:+PrintAdaptiveSizePolicy"  # unrecognized VM option                                                                                                                                       - "-XX:ErrorFile=/hs_err_%p.log"                                                                                                                                                                   - "-XX:+LogVMOutput"                                                                                                                                                                               - "-XX:LogFile={{ jenkins_path_to_gc_and_heap_dump }}/jvm.log"                                                                                                                                   
        jenkins_pipeline_library_jenkins_java_options: "{{ jenkins_java_options_list | join(' ') }}"                                                                                                       # Jenkins args documented here: https://wiki.jenkins.io/display/JENKINS//Starting+and+Accessing+Jenkins                                                                                                            
        jenkins_pipeline_library_jenkins_args: "--httpsPort=8443 --httpsKeyStore=/etc/jenkins/host.jks --httpsKeyStorePassword={{ 
        jenkins_java_keystore_password }} --httpsListenAddress=0.0.0.0"          jenkins_pipeline_library_plugins_present:                                                                                                                                                            
          - name: active-directory                                                                                                                                                                           
            - name: audit-trail                                                                                                                                                                                          
            - name: antisamy-markup-formatter                                                                                                                                                                  
            - name: atlassian-bitbucket-server-integration                                                                                                                                                     
            - name: basic-branch-build-strategies                                                                                                                                                              
            - name: blueocean                                                                                                                                                                                  
            - name: build-timeout                                                                                                                                                                              
            - name: build-monitor-plugin                                                                                                                                                                       
            - name: configuration-as-code                                                                                                                                                                      
            - name: copyartifact                                                                                                                                                                               
            - name: disk-usage                                                                                                                                                                                 
            - name: docker                                                                                                                                                                                     
            - name: email-ext                                                                                                                                                                             
            - name: extended-choice-parameter                                                                                                                                                                  
            - name: htmlpublisher
            - name: git
            - name: git-parameter
            - name: greenballs                                                                                                                                                                                 
            - name: groovy                                                                                                                                                                                     
            - name: jira                                                                                                                                                                                       
            - name: job-dsl                                                                                                                                                                                    
            - name: leastload                                                                                                                                                                                  
            - name: list-git-branches-parameter                                                                                                                                                                
            - name: lockable-resources                                                                                                                                                                         
            - name: matrix-auth                                                                                                                                                                                
            - name: metrics                                                                                                                                                                                    
            - name: monitoring                                                                                                                                                                                 
            - name: Office-365-Connector                                                                                                                                                                       
            - name: parameterized-trigger                                                                                                                                                                      
            - name: pipeline-model-definition                                                                                                                                                                  
            - name: pipeline-utility-steps                                                                                                                                                                     
            - name: prometheus                                                                                                                                                                                 
            - name: simple-theme-plugin                                                                                                                                                                        
            - name: ssh-slaves                                                                                                                                                                                 
            - name: stashNotifier                                                                                                                                                                              
            - name: support-core                                                                                                                                                                               
            - name: test-results-analyzer                                                                                                                                                                      
            - name: tfs                                                                                                                                                                                        
            - name: timestamper                                                                                                                                                                                
            - name: versioncolumn                                                                                                                                                                              
            - name: xunit                                                                                                                                                                                      
            - name: workflow-job                                                                                                                                                                               
            - name: workflow-multibranch                                                                                                                                                                       
            - name: ws-cleanup                                                                                                                                                                               
        # Add items here to uninstall plugins                                                                                                                                                              
        # jenkins_pipeline_library_plugins_absent: []                                                                                                                                                      
        jenkins_pipeline_library_approved_signatures_present:                                                                                                                                                
          - method hudson.model.Run getDescription                                                                                                                                                           
          -  method hudson.model.Run getId                                                                                                                                                                    
          - method hudson.model.Run getPreviousNotFailedBuild                                                                                                                                                
          - method org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper getRawBuild                                                                                                                 
          - staticMethod org.apache.commons.io.FilenameUtils getBaseName java.lang.String                                                                                                                    
          - staticMethod jenkins.model.Jenkins getInstance                                                                                                                                                   
          - staticMethod com.cloudbees.plugins.credentials.CredentialsProvider lookupCredentials                                                                                                             
          - staticMethod com.cloudbees.plugins.credentials.CredentialsProvider lookupCredentials java.lang.Class hudson.model.ItemGroup                                                                      
          - method com.cloudbees.plugins.credentials.common.IdCredentials getId                                                                                                                              
          - method com.cloudbees.plugins.credentials.common.UsernameCredentials getUsername                                                                                                                  
          - method com.cloudbees.plugins.credentials.common.PasswordCredentials getPassword                                                                                                                jenkins_pipeline_library_jenkins_pkg_url: http://mirror.math.princeton.edu/pub/jenkins/debian-stable         

and here is my requirements.yml, which I install roles and collections from ansible-galaxy for this project:

roles:
  - name: geerlingguy.nodejs
    version: 5.1.1
  - name: geerlingguy.docker
    version: 2.8.1
  - name: geerlingguy.java
    version: 1.10.0
  - name: wcm_io_devops.jenkins_pipeline_library
    version: 2.249.2-1
  - name: wcm_io_devops.jenkins_configuration_as_code
    version: 1.9.0
  - name: lean_delivery.jenkins_slave
    # version: 2.1.0
    # using my fork/branch since I'm fixing some things as I go
    src: https://github.com/timblaktu/ansible-role-jenkins-slave.git
    version: feature/dont_clobber_existing_jenkins_user_config
  - name: devoinc.systemd_service
    version: v1.2.0
collections:
  - name: ansible.posix
    version: 1.1.1
  - name: community.crypto
    version: 1.2.0
  - name: sbaerlocher.virtualization
    version: 0.0.10

This configuration was working fine using version 2.222.3 of your role. I upgraded over the course of troubleshooting the "A later version is already installed" problem and the Java version Check bug in Jenkins Debian Package.

Perhaps I will revert the cluster of machines I run this on to their post-OS-install snapshots and repeat provisioning with the old version as a sanity check. Let me know if you have any ideas.. Thanks!

timblaktu commented 3 years ago

Going back to version 2.222.3-1 of this role results in similar issues. There are a lot of "failed to load plugin" errors at startup. Really confused about what changed. Let me know if anyone has any ideas about how to troubleshoot jenkins startup and plugin dependency issues using this role. Thanks.

timblaktu commented 3 years ago

Related, I recently noticed the Jenkins team completed a new plugin installation/management tool. I may use this tomorrow to try to figure out what's going on.

@tobias-richter I wonder if this tool has a useful purpose integrated into this or your jenkins_plugins role?

timblaktu commented 3 years ago

I discovered that when I upgraded my ansible-jenkins-pipeline-library role, ansible-galaxy did not update the ansible-jenkins-plugins role to the new version. This must be at least part of the cause of the problem.

After removing and reinstalling the role, and confirming all roles are at the correct versions, I'm now getting some different behavior. Some of the plugins have installed successfully:

changed: [jenkins-testing] => (item={u'key': u'git', u'value': {u'state': u'present'}})
changed: [jenkins-testing] => (item={u'key': u'monitoring', u'value': {u'state': u'present'}})
changed: [jenkins-testing] => (item={u'key': u'versioncolumn', u'value': {u'state': u'present'}})
changed: [jenkins-testing] => (item={u'key': u'build-monitor-plugin', u'value': {u'state': u'present'}})
changed: [jenkins-testing] => (item={u'key': u'workflow-job', u'value': {u'state': u'present'}})
changed: [jenkins-testing] => (item={u'key': u'workflow-multibranch', u'value': {u'state': u'present'}})
changed: [jenkins-testing] => (item={u'key': u'copyartifact', u'value': {u'state': u'present'}})

but most of them are encountering this failure mode:

failed: [jenkins-testing] (item={u'key': u'build-timeout', u'value': {u'state': u'present'}}) => changed=true
  ansible_loop_var: item
  details: 'Connection failure: timed out'
  item:
    key: build-timeout
    value:
      state: present
  msg: Cannot install plugin.
timblaktu commented 3 years ago

..after re-running the playbook a few times to workaround my need for a local mirror, all plugins seem to have been installed now, but very few of them actually load, and this task is now my first failure:

TASK [wcm_io_devops.jenkins_plugins : assert that there are no failed plugins.]

with msg:

"33 plugin(s) failed to load!"

The full list of failed plugins with theirs reasons, as printed from gather_jenkins_facts - debug, is shown below. I believe this indicates the same errors as I reported in the UPDATE to the original report above, but now these errors are caught by the now-updated jenkins_facts and jenkins_plugins roles.

I will now start tracing through your code to see how plugin versions are specified and "locked", to see why it's not working in my environment.

  - jenkins_facts_plugins_failed
  - atlassian-bitbucket-server-integration:                                                                                                                                                                              cause: |-                                                                                                                                                                                                            Failed to load: Bitbucket Server Integration (2.1.1)                                                                                                                                                                - Failed to load: Pipeline (2.6)                                                                                                                                                                              blueocean:                                                                                                                                                                                                           cause: |-                                                                                                                                                                                                            Failed to load: Blue Ocean (1.24.3)                                                                                                                                                                                 - Failed to load: Bitbucket Pipeline for Blue Ocean (1.24.3)                                                                                                                                                  blueocean-autofavorite:                                                                                                                                                                                              cause: |-                                                                                                                                                                                                            Failed to load: Autofavorite for Blue Ocean (1.2.4)                                                                                                                                                                 - Failed to load: Favorite (2.3.2)                                                                                                                                                                            blueocean-bitbucket-pipeline:                                                                                                                                                                                        cause: |-                                                                                                                                                                                                            Failed to load: Bitbucket Pipeline for Blue Ocean (1.24.3)                                                                                                                                                          - Failed to load: Pipeline implementation for Blue Ocean (1.24.3)                                                                                                                                             blueocean-config:                                                                                                                                                                                                    cause: |-                                                                                                                                                                                                            Failed to load: Config API for Blue Ocean (1.24.3)                                                                                                                                                                  - Plugin is missing: blueocean-jwt (1.24.3)                                                                                                                                                                   blueocean-events:                                                                                                                                                                                                    cause: |-
        Failed to load: Events API for Blue Ocean (1.24.3)
         - Failed to load: Pipeline implementation for Blue Ocean (1.24.3)                                                                                                                                             blueocean-git-pipeline:
      cause: |-
        Failed to load: Git Pipeline for Blue Ocean (1.24.3)
         - Failed to load: Pipeline implementation for Blue Ocean (1.24.3)
    blueocean-jira:
      cause: |-                                                                                                                                                                                                            Failed to load: JIRA Integration for Blue Ocean (1.24.3)                                                                                                                                                            - Failed to load: Jenkins Jira plugin (3.1.3)                                                                                                                                                                 blueocean-personalization:                                                                                                                                                                                           cause: |-                                                                                                                                                                                                            Failed to load: Personalization for Blue Ocean (1.24.3)                                                                                                                                                             - Plugin is missing: blueocean-dashboard (1.24.3)                                                                                                                                                             blueocean-pipeline-api-impl:                                                                                                                                                                                         cause: |-                                                                                                                                                                                                            Failed to load: Pipeline implementation for Blue Ocean (1.24.3)                                                                                                                                                     - Failed to load: REST Implementation for Blue Ocean (1.24.3)                                                                                                                                                 blueocean-pipeline-editor:                                                                                                                                                                                           cause: |-                                                                                                                                                                                                            Failed to load: Blue Ocean Pipeline Editor (1.24.3)                                                                                                                                                                 - Plugin is missing: blueocean-dashboard (1.24.3)                                                                                                                                                                  - Failed to load: Pipeline implementation for Blue Ocean (1.24.3)
    blueocean-rest-impl:
      cause: |-
        Failed to load: REST Implementation for Blue Ocean (1.24.3)
         - Plugin is missing: blueocean-jwt (1.24.3)
         - Failed to load: JUnit Plugin (1.47)
    bootstrap4-api:
      cause: |-
        Failed to load: Bootstrap 4 API Plugin (4.5.3-1)
         - Plugin is missing: font-awesome-api (5.15.1-1)
    cloudbees-bitbucket-branch-source:                                                                                                                                                                   [84/91514]      cause: |-
        Failed to load: Bitbucket Branch Source Plugin (2.9.6)
         - Plugin is missing: mercurial (2.8)
    conditional-buildstep:                                                                                                                                                                                               cause: |-                                                                                                                                                                                                            Failed to load: Conditional BuildStep (1.4.1)                                                                                                                                                                       - Failed to load: Maven Integration plugin (3.8)                                                                                                                                                              copyartifact:                                                                                                                                                                                                        cause: |-                                                                                                                                                                                                            Failed to load: Copy Artifact Plugin (1.45.3)                                                                                                                                                                       - Failed to load: Matrix Project Plugin (1.18)                                                                                                                                                                docker-workflow:                                                                                                                                                                                                     cause: |-                                                                                                                                                                                                            Failed to load: Docker Pipeline (1.25)                                                                                                                                                                              - Failed to load: Pipeline: Basic Steps (2.23)                                                                                                                                                                favorite:                                                                                                                                                                                                            cause: |-                                                                                                                                                                                                            Failed to load: Favorite (2.3.2)                                                                                                                                                                                    - Failed to load: Matrix Project Plugin (1.18)                                                                                                                                                                git-parameter:                                                                                                                                                                                                       cause: |-                                                                                                                                                                                                            Failed to load: Git Parameter Plug-In (0.9.13)                                                                                                                                                                      - Failed to load: JUnit Plugin (1.47)                                                                                                                                                                         github:                                                                                                                                                                                                              cause: |-
        Failed to load: GitHub plugin (1.32.0)
         - Plugin is missing: github-api (1.114.2)
    github-branch-source:
      cause: |-
        Failed to load: GitHub Branch Source Plugin (2.9.2)
         - Failed to load: GitHub plugin (1.32.0)
    htmlpublisher:
      cause: |-
        Failed to load: HTML Publisher plugin (1.25)
         - Failed to load: Matrix Project Plugin (1.18)
    jira:
      cause: |-
        Failed to load: Jenkins Jira plugin (3.1.3)
         - Failed to load: Matrix Project Plugin (1.18)
    junit:
      cause: |-
        Failed to load: JUnit Plugin (1.47)
         - Failed to load: Bootstrap 4 API Plugin (4.5.3-1)
    lockable-resources:
      cause: |-
        Failed to load: Lockable Resources plugin (2.10)
         - Failed to load: Matrix Project Plugin (1.18)
    matrix-project:
      cause: |-
        Failed to load: Matrix Project Plugin (1.18)
         - Failed to load: JUnit Plugin (1.47)
    maven-plugin:
      cause: |-
        Failed to load: Maven Integration plugin (3.8)
         - Failed to load: JUnit Plugin (1.47)
    pipeline-model-definition:
      cause: |-
        Failed to load: Pipeline: Declarative (1.7.2)
         - Failed to load: Pipeline: Basic Steps (2.23)
    prometheus:
      cause: |-
        Failed to load: Prometheus metrics plugin (2.0.8)
         - Failed to load: JUnit Plugin (1.47)
    workflow-aggregator:
      cause: |-
        Failed to load: Pipeline (2.6)
         - Failed to load: Lockable Resources plugin (2.10)
    workflow-basic-steps:
      cause: |-
        Failed to load: Pipeline: Basic Steps (2.23)
         - Jenkins (2.263) or higher required
    ws-cleanup:
      cause: |-
        Failed to load: Jenkins Workspace Cleanup Plugin (0.38)
         - Failed to load: Matrix Project Plugin (1.18)
    xunit:
      cause: |-
        Failed to load: xUnit plugin (2.4.0)
         - Failed to load: JUnit Plugin (1.47)
timblaktu commented 3 years ago

OK, looking at the docs on the role variables for the jenkins_plugins role, I immediately see that each items in the jenkins_plugins_present list supports a version: key.

I suppose I misinterpreted the list of plugin versions updated on your Releases page. I ASSumed that this meant the meta role was handling the specification of all versions for me.

...and that assumption was correct:

Looking at where the meta/main.yml for this role specifies the jenkinsplugins* role variables, and then over at defaults.yml, where these variables are defined, I see that you ARE indeed specifying all these versions.

Catharsis

What I got wrong was that I didn't realize that _I was overriding your plugin version specifications when I define my own jenkins_pipeline_library_plugins_present list where I call your meta role_. And because my plugins list did not specify versions, I was probably causing those plugins to default to "latest".

So now, I'll go and fix this, to make sure my invocation of your meta role specifies something like:

my_jenkins_plugins_present:
    - name: active-directory                                                                                                                                                                           
    - name: audit-trail
    .                                                                                                                                                                                          
    .                                                                                                                                                                                          
    .                                                                                                                                                                                          
jenkins_pipeline_library_plugins_present: "{{ jenkins_pipeline_library_plugins_present + my_jenkins_plugins_present }}"

What I'm unsure of is how to ensure nothing in my_jenkins_plugins_present overlaps with jenkins_pipeline_library_plugins_present. Will report back when I get this fixed.

UPDATE: can't seem to get around the recursive loop detected in template string error whenever I try to define jenkins_pipeline_library_plugins_present as the combination of itself and my_jenkins_plugins_present list. I've tried + operator, and jinja2 combine filter so far, and setting it as a fact in previous task, no dice so far..

timblaktu commented 3 years ago

It appears Ansible does not support self referencing variable definitions like this, so I had no recourse but to explicitly define all the overlapping jenkins plugins in my invocation of your meta role, by copying them from your defaults. Not ideal (bc I'll have to do this manual work every time I pull in a new release) but hey I've already spent at least an hour googling how to do this to no end..

So, in the end I ended up defining the superset of jenkins plugins in my list, including your default versions, and that got me further.

Now I'm down to 3 load errors:

  - atlassian-bitbucket-server-integration:                                                                                                                                    
    - cause: |-                                                                                                                                                                  
    Failed to load: Bitbucket Server Integration (2.1.1)
         - Failed to load: Pipeline (2.6)
  - pipeline-stage-view:                                                                                                                                                       
      - cause: |-
        Failed to load: Pipeline: Stage View Plugin (2.19)
         - Update required: Pipeline: REST API Plugin (2.18) to be updated to 2.19 or higher
  - workflow-aggregator:
      - cause: |-                                                                                                                                                                  
      Failed to load: Pipeline (2.6)                                                                                                                                            
        - Failed to load: Pipeline: Stage View Plugin (2.19)

It appears that root cause for this failure chain is that pipeline-stage-view got installed at 2.19, whereas your defaults/main.yml -specifies it at 2.18. Perhaps this is some remnant from past run of this playbook in which I was inadvertently telling it to "install latest". I will now manually uninstall/reinstall pipeline-stage-view at 2.18, and try again.

timblaktu commented 3 years ago

OK, I think I'm through the last of these problems after reinstalling pipeline-stage-view at 2.18. The moral of that story is "take care with ansible-galaxy". I should probably write a task for all my playbooks to inspect the contents of the roles dirs to make sure they're aligned with requirements.yml..

tobias-richter commented 3 years ago

@timblaktu sorry for the late response. You are right. Ansible Galaxy does not update dependencies automatically when running install. I suggest to always use the -f / --force and try to reproduce issues on a vanilla system, for example using a technology like vagrant.