community.general icon indicating copy to clipboard operation
community.general copied to clipboard

Install jenkins plugins with a specific version: "Some plugins could not be loaded due to unsatisfied dependencies."

Open patsevanton opened this issue 1 year ago • 3 comments

Summary

Hello! I try install jenkins plugin by ansible.

image

My code


- name: Jenkins Master play
  hosts: jenkins
  become: true
  vars:
    my_jenkins_plugins:
      timestamper:
        version: "1.18"
        enabled: yes
  tasks:
    - name: Install plugins with a specific version
      community.general.jenkins_plugin:
        name: "{{ item.key }}"
        version: "{{ item.value['version'] }}"
        url_username: "admin"
        url_password: "password"
        url: http://localhost:8080
        timeout: 30
        state: present
      register: my_jenkins_plugin_versioned
      when: >
        'version' in item.value
      with_dict: "{{ my_jenkins_plugins }}"

    - name: Initiate the fact
      ansible.builtin.set_fact:
        jenkins_restart_required: no

    - name: Check if restart is required by any of the versioned plugins
      ansible.builtin.set_fact:
        jenkins_restart_required: yes
      when: item.changed
      with_items: "{{ my_jenkins_plugin_versioned.results }}"

    - name: Restart Jenkins if required
      ansible.builtin.systemd:
        state: restarted
        daemon_reload: yes
        name: jenkins
      when:  jenkins_restart_required

    - name: Wait for Jenkins to start up
      ansible.builtin.uri:
        url: http://localhost:8080
        status_code: 200
        timeout: 5
      register: jenkins_service_status
      # Keep trying for 5 mins in 5 sec intervals
      retries: 60
      delay: 5
      until: >
         'status' in jenkins_service_status and
         jenkins_service_status['status'] == 200
      when: jenkins_restart_required

Issue Type

Bug Report

Component Name

jenkins_plugin module

Ansible Version

$ ansible --version
ansible [core 2.13.2]
  config file = /home/user/github/infrastructure-as-a-code-example/jenkins-geerlingguy-jenkins/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/bin/ansible
  python version = 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0]
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
community.general 5.3.0

Configuration

$ ansible-config dump --only-changed
CALLBACKS_ENABLED(/home/user/github/infrastructure-as-a-code-example/jenkins-geerlingguy-jenkins/ansible.cfg) = ['profile_tasks']
DEFAULT_GATHERING(/home/user/github/infrastructure-as-a-code-example/jenkins-geerlingguy-jenkins/ansible.cfg) = smart
DEFAULT_STDOUT_CALLBACK(/home/user/github/infrastructure-as-a-code-example/jenkins-geerlingguy-jenkins/ansible.cfg) = yaml

OS / Environment

Ubuntu 22.04

Steps to Reproduce

- 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: Create directory /var/lib/jenkins/jcasc
      ansible.builtin.file:
        path: /var/lib/jenkins/jcasc
        state: directory
        owner: jenkins
        group: jenkins

    - name: Copy jcasc.yaml with owner and permissions
      ansible.builtin.copy:
        src: jcasc.yaml
        dest: /var/lib/jenkins/jcasc/jcasc.yaml
        owner: jenkins
        group: jenkins
        mode: '0644'

    - name: Create directory /etc/systemd/system/jenkins.service.d
      ansible.builtin.file:
        path: /etc/systemd/system/jenkins.service.d
        state: directory
        owner: jenkins
        group: jenkins

    - name: Copy env-jenkins.conf with owner and permissions
      ansible.builtin.copy:
        src: env-jenkins.conf
        dest: /etc/systemd/system/jenkins.service.d/env-jenkins.conf
        owner: jenkins
        group: jenkins
        mode: '0644'
      register: env_jenkins_conf

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

    - name: Print ansible_host var
      debug:
        var: ansible_host

    # - name: install pip3
    #   apt: name=python3-pip state=present
    # - name: Install multi python packages with version specifiers
    #   pip:
    #     name:
    #       - jenkins-job-builder

    # - name: Install plugin
    #   community.general.jenkins_plugin:
    #     name: "{{ item }}"
    #     url_username: "admin"
    #     url_password: "password"
    #     url: http://localhost:8080
    #     timeout: 30
    #     state: present
    #   with_items:  
    #     - timestamper
    #   register: jenkins_plugin

- name: Jenkins Master play
  hosts: jenkins
  become: true
  vars:
    my_jenkins_plugins:
      timestamper:
        version: "1.18"
        enabled: yes
  tasks:
    - name: Install plugins with a specific version
      community.general.jenkins_plugin:
        name: "{{ item.key }}"
        version: "{{ item.value['version'] }}"
        url_username: "admin"
        url_password: "password"
        url: http://localhost:8080
        timeout: 30
        state: present
      register: my_jenkins_plugin_versioned
      when: >
        'version' in item.value
      with_dict: "{{ my_jenkins_plugins }}"

    - name: Initiate the fact
      ansible.builtin.set_fact:
        jenkins_restart_required: no

    - name: Check if restart is required by any of the versioned plugins
      ansible.builtin.set_fact:
        jenkins_restart_required: yes
      when: item.changed
      with_items: "{{ my_jenkins_plugin_versioned.results }}"

    - name: Restart Jenkins if required
      ansible.builtin.systemd:
        state: restarted
        daemon_reload: yes
        name: jenkins
      when:  jenkins_restart_required

    - name: Wait for Jenkins to start up
      ansible.builtin.uri:
        url: http://localhost:8080
        status_code: 200
        timeout: 5
      register: jenkins_service_status
      # Keep trying for 5 mins in 5 sec intervals
      retries: 60
      delay: 5
      until: >
         'status' in jenkins_service_status and
         jenkins_service_status['status'] == 200
      when: jenkins_restart_required

Expected Results

install plugin with dependencies

Actual Results

Some plugins could not be loaded due to unsatisfied dependencies. Fix these issues and restart Jenkins to re-enable these plugins.

Dependency errors:

Timestamper (1.18)
Plugin is missing: antisamy-markup-formatter (2.7)
Plugin is missing: workflow-api (1153.vb_912c0e47fb_a_)
Plugin is missing: workflow-step-api (625.vd896b_f445a_f8)

Code of Conduct

  • [X] I agree to follow the Ansible Code of Conduct

patsevanton avatar Jul 24 '22 14:07 patsevanton

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Jul 24 '22 14:07 ansibullbot

cc @jtyr click here for bot help

ansibullbot avatar Jul 24 '22 14:07 ansibullbot

I am running into the same issue

alok15ee avatar Aug 05 '22 20:08 alok15ee

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot avatar Nov 09 '22 22:11 ansibullbot