Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proxy Configuration step failure #75

Open
Hokonoken opened this issue Jul 28, 2021 · 9 comments
Open

Proxy Configuration step failure #75

Hokonoken opened this issue Jul 28, 2021 · 9 comments
Assignees

Comments

@Hokonoken
Copy link

Hokonoken commented Jul 28, 2021

TASK [ansible-role-jenkins : Proxy Configuration] ****************************************************************************************************************************************************************************************************************************************************************************************************
task path: /home/cfm/ansible/roles/ansible-role-jenkins/tasks/install_plugins.yml:3
Using module file /usr/lib/python2.7/site-packages/ansible/modules/web_infrastructure/jenkins_script.py
Pipelining is enabled.
ESTABLISH SSH CONNECTION FOR USER: None
SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o ControlPath=/home/cfm/.ansible/cp/ef04de8b1e SRV0000 '/bin/sh -c '"'"'sudo -H -S -p "[sudo via ansible, key=euyujfparygopguhceypmkxsqfewbdnp] password:" -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-euyujfparygopguhceypmkxsqfewbdnp ; no_proxy='"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'*.*, '"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"'"' https_proxy=http_proxy=/usr/libexec/platform-python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
(1, '\n{"msg": "HTTP error 404 HTTP Error 404: Not Found", "output": "", "failed": true, "invocation": {"module_args": {"script": "def host = 'proxy.mgnt.zas..ch'\ndef port = 8080\ndef username = '[]'\ndef password = '[]'\ndef noProxyHosts = '[]'\n\nif (host != \"\") {\n def proxy = new hudson.ProxyConfiguration(host, port, username, noProxyHosts)\n proxy.save()\n jenkins.model.Jenkins.instance.proxy = proxy\n} else {\n def xmlFile = hudson.ProxyConfiguration.xmlFile\n xmlFile.delete()\n jenkins.model.Jenkins.instance.proxy = null\n}\n", "url": "http://SERV0000:8080", "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "timeout": 240, "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "validate_certs": false, "args": null, "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "force_basic_auth": true}}}\n', '')
Failed to connect to the host via ssh:
fatal: [SERV0000]: FAILED! => {
"changed": false,
"invocation": {
"module_args": {
"args": null,
"force_basic_auth": true,
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"script": "def host = 'proxy
.
.ch'\ndef port = 8080\ndef username = '[]'\ndef password = '[]'\ndef noProxyHosts = '[]'\n\nif (host != "") {\n def proxy = new hudson.ProxyConfiguration(host, port, username, noProxyHosts)\n proxy.save()\n jenkins.model.Jenkins.instance.proxy = proxy\n} else {\n def xmlFile = hudson.ProxyConfiguration.xmlFile\n xmlFile.delete()\n jenkins.model.Jenkins.instance.proxy = null\n}\n",
"timeout": 240,
"url": "http://SERV0000:8080",
"url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"validate_certs": false
}
},
"msg": "HTTP error 404 HTTP Error 404: Not Found",
"output": ""
}

What am i missing ? 
The Url is working fine ... 
Can someone help me ? 

Many Thanks,

Regards,
Laurent 
@pavelpikta
Copy link
Member

Hi @Hokonoken
Could you please describe your playbook, ansible version?

@pavelpikta pavelpikta self-assigned this Jul 28, 2021
@Hokonoken
Copy link
Author

Hello :)
Playbook

  • hosts: jenkins
    tasks:
    • name: Déploiement des prérequis
      yum:
      name: java-1.8.0-openjdk.x86_64
      state: latest

    • name: Deploiement du role jenkins
      import_role:
      name: ansible-role-jenkins
      environment:
      http_proxy: ****************:8080
      https_proxy: ****************:8080
      no_proxy: **********

ansible 2.9.21
config file = /home/cfm/ansible/ansible.cfg
configured module search path = [u'/home/cfm/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

Many thanks for your support :)

@pavelpikta
Copy link
Member

Not sure, maybe this problem with this script
Need tests to reproduce this.

@Hokonoken
Copy link
Author

Normaly the script should create a proxy.xml file to be use by the jenkins.war...

@pavelpikta
Copy link
Member

pavelpikta commented Jul 29, 2021

@Hokonoken Could you please try to update the proxy jinja template with this code

import jenkins.model.*

def instance = Jenkins.getInstance()

final String name = "{{ jenkins2_proxy_host }}"
final int port = {{ jenkins2_proxy_port }}
final String userName = "{{ jenkins2_proxy_username }}"
final String password = "{{ jenkins2_proxy_password }}"
final String noProxyHost = "{{ jenkins2_proxy_no_proxy_hosts }}"

if (name != "") {
  final def pc = new hudson.ProxyConfiguration(name, port, userName, password, noProxyHost)
  instance.proxy = pc
  instance.save()
} else {
  instance.proxy = null
  instance.save()
}

@sikhshadow
Copy link

Hello,

I am also running into an issue when I try to run this through my scripts. I get the following error on the "proxy configuration step".
TASK [lean_delivery.jenkins : Proxy Configuration] *****************************************************************************************************
fatal: [172.31.37.134]: FAILED! => {"changed": false, "msg": "HTTP error -1 Request failed: <urlopen error [Errno 111] Connection refused>", "output": ""}

PLAY RECAP *********************************************************************************************************************************************
172.31.37.134 : ok=23 changed=0 unreachable=0 failed=1 skipped=9 rescued=0 ignored=0

I know my SSH connection works between my two EC2 instances, master/slave. Can someone point me in the right direction.

@wodowod
Copy link

wodowod commented Feb 22, 2022

Have the same issue. No proxy at all. No changes in the defaults/main.yml

TASK [ansible-role-jenkins-2.4.1 : Proxy Configuration] ********************************************************************************************************************* task path: /home/XXXXXX/Code/XXXXXX/roles/ansible-role-jenkins-2.4.1/tasks/install_plugins.yml:2 fatal: [amzn]: FAILED! => {"changed": false, "msg": "HTTP error -1 Request failed: <urlopen error [Errno 111] Connection refused>", "output": ""}

OS: Linux amznlnx2 4.14.262-200.489.amzn2.x86_64 #1 SMP Fri Feb 4 20:34:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux, running in VirtualBox.

Tried new edition of /templates/jenkins_install_plugins/proxy_configuration.groovy.j2. No luck.

@gitisha84
Copy link

Same issue ...

TASK [lean_delivery.jenkins : Jenkins confuguration] *****************************************************************************************
skipping: [172.31.2.78] => (item=/etc/ansible/roles/lean_delivery.jenkins/tasks/configure/RedHat.yml)

TASK [lean_delivery.jenkins : include_tasks] *************************************************************************************************
included: /etc/ansible/roles/lean_delivery.jenkins/tasks/install_plugins.yml for 172.31.2.78

TASK [lean_delivery.jenkins : Proxy Configuration] *******************************************************************************************
fatal: [172.31.2.78]: FAILED! => {"changed": false, "msg": "HTTP error -1 Request failed: <urlopen error [Errno 111] Connection refused>", "output": ""}

@kraker
Copy link

kraker commented Jun 1, 2023

I'm also experiencing issues with this, except in my case I'm getting an HTTP error 401 HTTP Error 401: Unauthorized error:

TASK [lean_delivery.jenkins : Proxy Configuration] ******************************************************
task path: /home/akraker/avvale_repos/jenkins/roles/lean_delivery.jenkins/tasks/install_plugins.yml:2
redirecting (type: modules) ansible.builtin.jenkins_script to community.general.jenkins_script
redirecting (type: modules) ansible.builtin.jenkins_script to community.general.jenkins_script
Using module file /usr/local/lib/python3.9/dist-packages/ansible_collections/community/general/plugins/modules/jenkins_script.py
Pipelining is enabled.
<10.0.0.4> ESTABLISH SSH CONNECTION FOR USER: vagrant
<10.0.0.4> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="vagrant"' -o ConnectTimeout=10 -o 'ControlPath="/home/akraker/.ansible/cp/e38b1de10c"' 10.0.0.4 '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-cqgxsuuihqpwhuisedpfdvdsppcxkkkk ; /usr/libexec/platform-python'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<10.0.0.4> (1, b'\n{"output": "", "failed": true, "msg": "HTTP error 401 HTTP Error 401: Unauthorized", "invocation": {"module_args": {"url": "http://0.0.0.0:8080", "script": "def host = \'\'\\ndef port = 0\\ndef username = \'\'\\ndef password = \'\'\\ndef noProxyHosts = \'\'\\n\\nif (host != \\"\\") {\\n    def proxy = new hudson.ProxyConfiguration(host, port, username, password, noProxyHosts)\\n    proxy.save()\\n    jenkins.model.Jenkins.instance.proxy = proxy\\n} else {\\n    def xmlFile = hudson.ProxyConfiguration.xmlFile\\n    xmlFile.delete()\\n    jenkins.model.Jenkins.instance.proxy = null\\n}\\n", "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "validate_certs": false, "timeout": 240, "args": null, "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", "force_basic_auth": true}}}\n', b'/tmp/ansible_jenkins_script_payload_nz1_gsu6/ansible_jenkins_script_payload.zip/ansible/module_utils/urls.py:190: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.\n')
<10.0.0.4> Failed to connect to the host via ssh: /tmp/ansible_jenkins_script_payload_nz1_gsu6/ansible_jenkins_script_payload.zip/ansible/module_utils/urls.py:190: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for it is deprecated in cryptography. The next release of cryptography will remove support for Python 3.6.
fatal: [rocky8]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "args": null,
            "force_basic_auth": true,
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "script": "def host = ''\ndef port = 0\ndef username = ''\ndef password = ''\ndef noProxyHosts = ''\n\nif (host != \"\") {\n    def proxy = new hudson.ProxyConfiguration(host, port, username, password, noProxyHosts)\n    proxy.save()\n    jenkins.model.Jenkins.instance.proxy = proxy\n} else {\n    def xmlFile = hudson.ProxyConfiguration.xmlFile\n    xmlFile.delete()\n    jenkins.model.Jenkins.instance.proxy = null\n}\n",
            "timeout": 240,
            "url": "http://0.0.0.0:8080",
            "url_password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "url_username": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "validate_certs": false
        }
    },
    "msg": "HTTP error 401 HTTP Error 401: Unauthorized",
    "output": ""
}

Playbook:

---
# Setup Jenkins CI

- name: Install and Configure Jenkins
  hosts: all
  become: true
  roles:
    - role: lean_delivery.java
      java_distribution: openjdk
      java_major_version: 11
      transport: repositories
    - role: lean_delivery.jenkins

I'm targeting a Rocky Linux 8 sandbox VM:

[vagrant@rocky8 ~]$ cat /etc/os-release
NAME="Rocky Linux"
VERSION="8.7 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.7 (Green Obsidian)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-8"
ROCKY_SUPPORT_PRODUCT_VERSION="8.7"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.7"
[vagrant@rocky8 ~]$ uname -a
Linux rocky8 4.18.0-425.10.1.el8_7.x86_64 #1 SMP Thu Jan 12 16:32:13 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Workaround

In my case, I've found a workaround. First I need to make sure that the firewall is open so that I can open Jenkins in a browser:

[vagrant@rocky8 ~]$ sudo firewall-cmd --add-port=8080/tcp --permanent
success
[vagrant@rocky8 ~]$ sudo firewall-cmd --reload
success

Then I'll open Jenkins in a browser at http://<ip_address>:8080 and "Unlock Jenkins" using the initialAdminPassword file.

[vagrant@rocky8 ~]$ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
92b9f037ba56431fa3f724a7e90c05d8

I setup Jenkins with the default username and password of:

username: admin
password: admin

Skip installing recommended plugins and finish the setup wizard.

Then if I re-run the playbook it successfully completes the "Proxy Configuration" task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants