wcm-io-devops / ansible-jenkins-plugins

Ansible role for maintaining plugins on Jenkins instances
Apache License 2.0
5 stars 12 forks source link

The following plugins are deactivated because of cyclic dependencies, most likely you can resolve the issue by updating these to a newer version #12

Closed patsevanton closed 2 years ago

patsevanton commented 2 years ago

Hello! Thanks a lot of ansible-jenkins-plugins!

I try install and configure jenkins as code by ansible.

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

fatal: [jenkins]: FAILED! => changed=false 
  assertion: jenkins_facts_plugins_failed | length == 0
  evaluated_to: false
  msg: |-
    33 plugin(s) failed to load! {'ssh-credentials': {'cause': 'Cycle detected: Plugin:ssh-credentials 

Inventory

all:
  children:
    jenkins:
      hosts:
        "jenkins":
          ansible_host: "IP"
  vars:
    jenkins_casc_admin_password: XXXX
    jenkins_admin_password: XXXXX
    jenkins_hostname: "jenkins.IP.sslip.io"
    jenkins_plugins:
      - cloudbees-folder
      - antisamy-markup-formatter
      - build-timeout
      - credentials-binding
      - timestamper
      - ws-cleanup
      - ant
      - gradle
      - workflow-aggregator
      - github-branch-source
      - pipeline-github-lib
      - pipeline-stage-view
      - git
      - ssh-slaves
      - matrix-auth
      - pam-auth
      - ldap
      - email-ext
      - mailer
      - github-oauth
      - configuration-as-code

playbook.yml

- name: "Deploy java, jenkins, letsencrypt, nginx"
  hosts: jenkins
  become: true
  roles:
    - role: robertdebock.java
    - role: geerlingguy.jenkins

- name: "Deploy jcasc"
  hosts: jenkins
  become: true
  vars:
    jenkins_casc_config_path_configure: true
    jenkins_casc_config_path: "/var/lib/jenkins/jcasc-folder"
    jenkins_casc_config_fileglobs:
        - file/jcasc/*.yml
        - file/jcasc/*.yaml
  roles:
    - wcm_io_devops.jenkins_configuration_as_code

*file/jcasc/.yml**

jenkins:
  systemMessage: "Jenkins configured automatically by Jenkins Configuration as Code plugin\n\n"
  globalNodeProperties:
  - envVars:
      env:
      - key: VARIABLE1
        value: foo
      - key: VARIABLE2
        value: bar

image

patsevanton commented 2 years ago
{
   "ssh-credentials":{
      "cause":"Cycle detected: Plugin:ssh-credentials -> Plugin:credentials -> Plugin:configuration-as-code -> Plugin:snakeyaml-api -> Plugin:sshd -> Plugin:mina-sshd-api-core -> Plugin:ssh-credentials"
   },
   "credentials":{
      "cause":"Cycle detected: Plugin:ssh-credentials -> Plugin:credentials -> Plugin:configuration-as-code -> Plugin:snakeyaml-api -> Plugin:sshd -> Plugin:mina-sshd-api-core -> Plugin:ssh-credentials"
   },
   "configuration-as-code":{
      "cause":"Cycle detected: Plugin:ssh-credentials -> Plugin:credentials -> Plugin:configuration-as-code -> Plugin:snakeyaml-api -> Plugin:sshd -> Plugin:mina-sshd-api-core -> Plugin:ssh-credentials"
   },
   "snakeyaml-api":{
      "cause":"Cycle detected: Plugin:ssh-credentials -> Plugin:credentials -> Plugin:configuration-as-code -> Plugin:snakeyaml-api -> Plugin:sshd -> Plugin:mina-sshd-api-core -> Plugin:ssh-credentials"
   },
   "sshd":{
      "cause":"Cycle detected: Plugin:ssh-credentials -> Plugin:credentials -> Plugin:configuration-as-code -> Plugin:snakeyaml-api -> Plugin:sshd -> Plugin:mina-sshd-api-core -> Plugin:ssh-credentials"
   },
   "mina-sshd-api-core":{
      "cause":"Cycle detected: Plugin:ssh-credentials -> Plugin:credentials -> Plugin:configuration-as-code -> Plugin:snakeyaml-api -> Plugin:sshd -> Plugin:mina-sshd-api-core -> Plugin:ssh-credentials"
   },
   "jackson2-api":{
      "cause":"Failed to load: Jackson 2 API Plugin (jackson2-api 2.13.3-285.vc03c0256d517)\n - Required plugin is disabled: Snakeyaml API Plugin (snakeyaml-api)"
   },
   "echarts-api":{
      "cause":"Failed to load: ECharts API Plugin (echarts-api 5.3.3-1)\n - Failed to load: Jackson 2 API Plugin (jackson2-api 2.13.3-285.vc03c0256d517)"
   },
   "junit":{
      "cause":"Failed to load: JUnit Plugin (junit 1119.1121.vc43d0fc45561)\n - Failed to load: ECharts API Plugin (echarts-api 5.3.3-1)"
   },
   "plain-credentials":{
      "cause":"Failed to load: Plain Credentials Plugin (plain-credentials 1.8)\n - Required plugin is disabled: Credentials Plugin (credentials)"
   },
   "credentials-binding":{
      "cause":"Failed to load: Credentials Binding Plugin (credentials-binding 523.vd859a_4b_122e6)\n - Failed to load: Plain Credentials Plugin (plain-credentials 1.8)\n - Required plugin is disabled: Credentials Plugin (credentials)"
   },
   "jsch":{
      "cause":"Failed to load: Jenkins JSch dependency plugin (jsch 0.1.55.2)\n - Required plugin is disabled: SSH Credentials Plugin (ssh-credentials)"
   },
   "git-client":{
      "cause":"Failed to load: Jenkins Git client plugin (git-client 3.11.0)\n - Failed to load: Jenkins JSch dependency plugin (jsch 0.1.55.2)\n - Required plugin is disabled: Credentials Plugin (credentials)"
   },
   "matrix-project":{
      "cause":"Failed to load: Matrix Project Plugin (matrix-project 785.v06b_7f47b_c631)\n - Failed to load: JUnit Plugin (junit 1119.1121.vc43d0fc45561)"
   },
   "git":{
      "cause":"Failed to load: Git plugin (git 4.11.3)\n - Failed to load: Credentials Binding Plugin (credentials-binding 523.vd859a_4b_122e6)"
   },
   "jjwt-api":{
      "cause":"Failed to load: Java JSON Web Token (JJWT) Plugin (jjwt-api 0.11.5-77.v646c772fddb_0)\n - Failed to load: Jackson 2 API Plugin (jackson2-api 2.13.3-285.vc03c0256d517)"
   },
   "github-api":{
      "cause":"Failed to load: GitHub API Plugin (github-api 1.303-400.v35c2d8258028)\n - Failed to load: Jackson 2 API Plugin (jackson2-api 2.13.3-285.vc03c0256d517)"
   },
   "github":{
      "cause":"Failed to load: GitHub plugin (github 1.34.4)\n - Failed to load: Git plugin (git 4.11.3)\n - Required plugin is disabled: Credentials Plugin (credentials)"
   },
   "github-branch-source":{
      "cause":"Failed to load: GitHub Branch Source Plugin (github-branch-source 1677.v731f745ea_0cf)\n - Failed to load: GitHub plugin (github 1.34.4)"
   },
   "github-oauth":{
      "cause":"Failed to load: GitHub Authentication plugin (github-oauth 0.39)\n - Failed to load: Git plugin (git 4.11.3)"
   },
   "configuration-as-code-groovy":{
      "cause":"Failed to load: Configuration as Code Plugin - Groovy Scripting Extension (configuration-as-code-groovy 1.1)\n - Required plugin is disabled: Configuration as Code Plugin (configuration-as-code)"
   }
}
tobias-richter commented 2 years ago

Hi @patsevanton,

since reproducing this would be pretty timeconsuming I would recommend to try these things:

  1. use a fixed (LTS) Version of Jenkins using jenkins_version and jenkins_prefer_lts variables of geerlingguy.jenkins
  2. Add ssh-credentials to the top of your plugin list and see what happens
  3. Explicitely apply the wcm_io_devops.jenkins_plugins role after applying geerlingguy.jenkins - for me it looks like you are calling it implicitely by applying the wcm_io_devops.jenkins_configuration_as_code role

Beside that I recommend to use fixed version numbers of the plugins - even if this is harder to maintain - especially when older versions of the plugins are not available anymore.

You can have a look at the https://github.com/wcm-io-devops/ansible-jenkins-pipeline-library role as reference how we set up a complete jenkins with a defined version and plugin list. Since we have currently no complete CI on this Role i could not really tell you if this is working but there will be an updated version for a newer Jenkins version soon.

patsevanton commented 2 years ago

Thanks for answer. I try again with you advice:

Output

TASK [wcm_io_devops.jenkins_plugins : assert that there are no failed plugins.] 
fatal: [jenkins]: FAILED! => changed=false 
  assertion: jenkins_facts_plugins_failed | length == 0
  evaluated_to: false
  msg: |-
    3 plugin(s) failed to load! {'configuration-as-code': {'cause': 'Failed to load: Configuration as Code Plugin (1414.v878271fc496f)\n - Plugin is missing: caffeine-api (2.9.2-29.v717aac953ff3)'}, 'configuration-as-code-groovy': {'cause': 'Failed to load: Configuration as Code Plugin - Groovy Scripting Extension (1.1)\n - Failed to load: Configuration as Code Plugin (1414.v878271fc496f)'}, 'job-dsl': {'cause': 'Failed to load: Job DSL (1.78.3)\n - Plugin is missing: structs (1.19)\n - Plugin is missing: cloudbees-folder (5.14)'}}

playbook.yml

- name: "Deploy java, jenkins, letsencrypt, nginx"
  hosts: jenkins
  become: true
  roles:
    - role: robertdebock.java
    - role: geerlingguy.jenkins
    - role: systemli.letsencrypt
    - role: geerlingguy.nginx
  post_tasks:
    - name: Jenkins Skip startUp for MI. below works for 2.332.1 or latest
      lineinfile:
        dest=/usr/lib/systemd/system/jenkins.service
        regexp='^Environment="JAVA_OPTS=-Djava.awt.headless=true'
        line='Environment="JAVA_OPTS=-Djava.awt.headless=true -Djenkins.install.runSetupWizard=false"'
      when: jenkins_version is not defined
      register: jenkins_service

    - name: Restart service jenkins, also issue daemon-reload to pick up config changes
      ansible.builtin.systemd:
        state: restarted
        daemon_reload: yes
        name: jenkins
      when: jenkins_service.changed

    - name: Print ansible_host var
      debug:
        var: ansible_host

- name: "Deploy jcasc"
  hosts: jenkins
  become: true
  vars:
    jenkins_casc_config_path_configure: true
    jenkins_casc_config_path: "/var/lib/jenkins/jcasc-folder"
    jenkins_casc_config_fileglobs:
        - file/jcasc/*.yml
        - file/jcasc/*.yaml
  roles:
    - wcm_io_devops.jenkins_configuration_as_code

inventory.yml

all:
  children:
    jenkins:
      hosts:
        "jenkins":
          ansible_host: "IP"
  vars:
    ansible_user:  ubuntu
    ansible_ssh_private_key_file: ~/.ssh/id_rsa

    jenkins_version: "2.319"
    jenkins_casc_admin_password: my_password
    jenkins_admin_password: my_password
    jenkins_hostname: "jenkins.IP.sslip.io"
    jenkins_plugins_present:
      - name: ssh-credentials
        version: "1.19"
      - name: ace-editor
        version: "1.1"
      - name: analysis-model-api
        version: "10.9.2"
      - name: antisamy-markup-formatter
        version: "2.7"
      - name: apache-httpcomponents-client-4-api
        version: "4.5.13-1.0"
      - name: authentication-tokens
        version: "1.4"
      - name: bootstrap4-api
        version: "4.6.0-3"
      - name: bootstrap5-api
        version: "5.1.3-6"
      - name: bouncycastle-api
        version: "2.25"
      - name: branch-api
        version: "2.7.0"
      - name: caffeine-api
        version: "2.9.2-29.v717aac953ff3"
      - name: checks-api
        version: "1.7.2"
      - name: cloudbees-folder
        version: "6.708.ve61636eb_65a_5"
      - name: command-launcher
        version: "1.6"
      - name: config-file-provider
        version: "3.9.0"
      - name: configuration-as-code
        version: "1414.v878271fc496f"
      - name: credentials
        version: "1074.v60e6c29b_b_44b_"
      - name: credentials-binding
        version: "1.27.1"
      - name: data-tables-api
        version: "1.11.4-1"
      - name: display-url-api
        version: "2.3.5"
      - name: docker-workflow
        version: "1.28"
      - name: docker-commons
        version: "1.19"
      - name: durable-task
        version: "493.v195aefbb0ff2"
      - name: echarts-api
        version: "5.3.0-2"
      - name: extended-choice-parameter
        version: "346.vd87693c5a_86c"
      - name: email-ext
        version: "2.87"
      - name: font-awesome-api
        version: "6.0.0-1"
      - name: forensics-api
        version: "1.8.1"
      - name: git
        version: "4.10.3"
      - name: git-client
        version: "3.11.0"
      - name: git-server
        version: "1.10"
      - name: handlebars
        version: "3.0.8"
      - name: http_request
        version: "1.14"
      - name: jackson2-api
        version: "2.13.1-246.va8a9f3eaf46a"
      - name: javadoc
        version: "217.v905b_86277a_2a_"
      - name: javax-activation-api
        version: "1.2.0-2"
      - name: javax-mail-api
        version: "1.6.2-5"
      - name: jdk-tool
        version: "1.5"
      - name: junit
        version: "1.54"
      - name: jquery
        version: "1.12.4-1"
      - name: jquery-detached
        version: "1.2.1"
      - name: jquery3-api
        version: "3.6.0-2"
      - name: jsch
        version: "0.1.55.2"
      - name: managed-scripts
        version: "1.5.4"
      - name: mailer
        version: "408.vd726a_1130320"
      - name: managed-scripts
        version: "1.5.4"
      - name: mattermost
        version: "3.1.1"
      - name: matrix-project
        version: "1.20"
      - name: maven-plugin
        version: "3.16"
      - name: momentjs
        version: "1.1.1"
      - name: mqtt-notification-plugin
        version: "1.8"
      - name: nodejs
        version: "1.5.1"
      - name: Office-365-Connector
        version: "4.15.2"
      - name: pipeline-aggregator-view
        version: "1.11"
      - name: pipeline-build-step
        version: "2.16"
      - name: pipeline-graph-analysis
        version: "188.v3a01e7973f2c"
      - name: pipeline-input-step
        version: "446.vf27b_0b_83500e"
      - name: pipeline-milestone-step
        version: "100.v60a_03cd446e1"
      - name: pipeline-model-definition
        version: "1.9.3"
      - name: pipeline-model-api
        version: "1.9.3"
      - name: pipeline-model-extensions
        version: "1.9.3"
      - name: pipeline-rest-api
        version: "2.22"
      - name: pipeline-stage-step
        version: "291.vf0a8a7aeeb50"
      - name: pipeline-stage-tags-metadata
        version: "1.9.3"
      - name: pipeline-stage-view
        version: "2.22"
      - name: pipeline-utility-steps
        version: "2.12.0"
      - name: plain-credentials
        version: "1.8"
      - name: plugin-util-api
        version: "2.14.0"
      - name: popper-api
        version: "1.16.1-2"
      - name: popper2-api
        version: 2.11.2-1
      - name: prism-api
        version: "1.26.0-2"
      - name: rebuild
        version: "1.33"
      - name: scm-api
        version: "595.vd5a_df5eb_0e39"
      - name: script-security
        version: "1138.v8e727069a_025"
      - name: ssh-steps
        version: "2.0.0"
      - name: ssh-slaves
        version: "1.33.0"
      - name: sshd
        version: "3.1.0"
      - name: snakeyaml-api
        version: "1.29.1"
      - name: structs
        version: "308.v852b473a2b8c"
      - name: token-macro
        version: "280.v97a_82642793c"
      - name: trilead-api
        version: "1.0.13"
      - name: warnings-ng
        version: "9.11.1"
      - name: workflow-api
        version: "1138.v619fd5201b_2f"
      - name: workflow-basic-steps
        version: "2.24"
      - name: workflow-cps
        version: "2659.v52d3de6044d0"
      - name: workflow-cps-global-lib
        version: "564.ve62a_4eb_b_e039"
      - name: workflow-durable-task-step
        version: "1121.va_65b_d2701486"
      - name: workflow-job
        version: "1145.v7f2433caa07f"
      - name: workflow-multibranch
        version: "711.vdfef37cda_816"
      - name: workflow-scm-step
        version: "2.13"
      - name: workflow-step-api
        version: "622.vb_8e7c15b_c95a_"
      - name: workflow-support
        version: "813.vb_d7c3d2984a_0"

    letsencrypt_opts_extra: "--register-unsafely-without-email"
    letsencrypt_cert:
      name: jenkins.IP.sslip.io
      domains:
        - jenkins.IP.sslip.io
      challenge: http
      http_auth: standalone
      reuse_key: True

    nginx_remove_default_vhost: true
    nginx_vhosts:
      - listen: "80"
        server_name: "jenkins.IP.sslip.io"
        return: "301 https://jenkins.IP.sslip.io$request_uri"
        filename: "jenkins.IP.sslip.io.80.conf"
      - listen: "443 ssl"
        server_name: jenkins.IP.sslip.io
        state: "present"
        extra_parameters: |
          location / {
            proxy_set_header        Host $host:$server_port;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Proto $scheme;

            # Fix the "It appears that your reverse proxy set up is broken" error.
            proxy_pass          http://127.0.0.1:8080;
            proxy_read_timeout  90;

          }
          ssl_certificate     /etc/letsencrypt/live/jenkins.IP.sslip.io/cert.pem;
          ssl_certificate_key /etc/letsencrypt/live/jenkins.IP.sslip.io/privkey.pem;
tobias-richter commented 2 years ago

@patsevanton looking at your output I suggest to add the missing plugins in the correct version to your plugin list. For example the cloudbees-folder plugin and the job-dsl plugin is not listed in your plugin list.

patsevanton commented 2 years ago

Thanks. I check later. Now i am busy.

tobias-richter commented 2 years ago

See my closing comment in #13. If you want to install plugins also with their dependencies you could omit the version parameter. But in this case you will not have a specified plugin/version state. If there are startup issues in Jenkins due to missing plugins you have to add them explicitely to your plugin list. Closing since it is not a issue with our role.