ansible-role-jenkins icon indicating copy to clipboard operation
ansible-role-jenkins copied to clipboard

jenkins_plugins_install_dependencies dont work if set version for main plugin

Open patsevanton opened this issue 3 years ago • 2 comments

Hello! Thanks for jenkins role!

image

output

TASK [geerlingguy.jenkins : Install Jenkins plugins using password.] ***************************************************************************
task path: /home/user/.ansible/roles/geerlingguy.jenkins/tasks/plugins.yml:42
Воскресенье 24 июля 2022  15:27:37 +0600 (0:00:00.670)       0:03:16.380 ****** 
redirecting (type: modules) ansible.builtin.jenkins_plugin to community.general.jenkins_plugin
redirecting (type: modules) community.general.jenkins_plugin to community.general.web_infrastructure.jenkins_plugin
redirecting (type: modules) ansible.builtin.jenkins_plugin to community.general.jenkins_plugin
redirecting (type: modules) community.general.jenkins_plugin to community.general.web_infrastructure.jenkins_plugin
Using module file /usr/lib/python3/dist-packages/ansible_collections/community/general/plugins/modules/web_infrastructure/jenkins_plugin.py
Pipelining is enabled.
<84.252.142.219> ESTABLISH SSH CONNECTION FOR USER: ubuntu
<84.252.142.219> SSH: EXEC ssh -vvv -o ControlMaster=auto -o ControlPersist=15m -o PreferredAuthentications=publickey -o 'IdentityFile="/home/user/.ssh/id_rsa"' -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ubuntu"' -o ConnectTimeout=10 -o 'ControlPath="/home/user/.ansible/cp/14647d5e3e"' 84.252.142.219 '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-gxlfvljpcwckgprcsweqrlzlbnlyvxpn ; /usr/bin/python3'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<84.252.142.219> (0, b'\n{"changed": true, "plugin": "timestamper", "state": "present", "invocation": {"module_args": {"name": "timestamper", "version": "1.18", "jenkins_home": "/var/lib/jenkins", "url_username": "admin", "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "state": "present", "timeout": 30.0, "updates_expiration": 86400, "updates_url": ["https://updates.jenkins.io"], "url": "http://jenkins.84.252.142.219.sslip.io:8080", "with_dependencies": true, "force": false, "http_agent": "ansible-httpget", "use_proxy": true, "validate_certs": true, "force_basic_auth": true, "use_gssapi": false, "group": "jenkins", "mode": "0644", "owner": "jenkins", "update_json_url_segment": ["update-center.json", "updates/update-center.json"], "latest_plugins_url_segments": ["latest"], "versioned_plugins_url_segments": ["download/plugins", "plugins"], "unsafe_writes": false, "client_cert": null, "client_key": null, "seuser": null, "serole": null, "selevel": null, "setype": null, "attributes": null}}}\n', b"OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022\r\ndebug1: Reading configuration data /home/user/.ssh/config\r\ndebug1: /home/user/.ssh/config line 1: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files\r\ndebug1: /etc/ssh/ssh_config line 21: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 84.252.142.219 is address\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/user/.ssh/known_hosts'\r\ndebug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/user/.ssh/known_hosts2'\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 48922\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\n")
changed: [jenkins] => (item={'name': 'timestamper', 'version': 1.18}) => changed=true 
  ansible_loop_var: item
  attempts: 1
  invocation:
    module_args:
      attributes: null
      client_cert: null
      client_key: null
      force: false
      force_basic_auth: true
      group: jenkins
      http_agent: ansible-httpget
      jenkins_home: /var/lib/jenkins
      latest_plugins_url_segments:
      - latest
      mode: '0644'
      name: timestamper
      owner: jenkins
      selevel: null
      serole: null
      setype: null
      seuser: null
      state: present
      timeout: 30.0
      unsafe_writes: false
      update_json_url_segment:
      - update-center.json
      - updates/update-center.json
      updates_expiration: 86400
      updates_url:
      - https://updates.jenkins.io
      url: http://jenkins.84.252.142.219.sslip.io:8080
      url_password: VALUE_SPECIFIED_IN_NO_LOG_PARAMETER
      url_username: admin
      use_gssapi: false
      use_proxy: true
      validate_certs: true
      version: '1.18'
      versioned_plugins_url_segments:
      - download/plugins
      - plugins
      with_dependencies: true
  item:
    name: timestamper
    version: 1.18
  plugin: timestamper
  state: present
NOTIFIED HANDLER geerlingguy.jenkins : restart jenkins for jenkins
META: role_complete for jenkins

Playbook

- 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

Inventory

all:
  children:
    jenkins:
      hosts:
        "jenkins":
          ansible_host: "IP"
  vars:
    jenkins_prefer_lts: true
    jenkins_external_url: "https://jenkins.IP.sslip.io"
    ansible_user:  ubuntu
    ansible_ssh_private_key_file: ~/.ssh/id_rsa

    jenkins_admin_password: password
    jenkins_hostname: "jenkins.IP.sslip.io"
    jenkins_plugins:
      - name: timestamper
        version: 1.18


    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;

patsevanton avatar Jul 24 '22 09:07 patsevanton

Related to https://docs.ansible.com/ansible/latest/collections/community/general/jenkins_plugin_module.html#parameter-with_dependencies

zhan9san avatar Sep 16 '22 16:09 zhan9san

@geerlingguy

This is limited by jenkins_plugin_module.

Would you mind if I refactor this feature by using plugin-installation-manager-tool in a PR?

plugin-installation-manager-tool has already been involved in Jenkins Official Docker Image.

zhan9san avatar Sep 19 '22 05:09 zhan9san

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] avatar Dec 21 '22 04:12 stale[bot]

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

stale[bot] avatar Jan 22 '23 06:01 stale[bot]