saltstack / saltstack/salt

[BUG] pecl.installed does not work behind proxy

Open
#58,613 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
The pecl.installed state fails behind a proxy server.
This could be mitigated with different aproaches (see below).

Setup
Sample state:

install-php-yaz:
  pecl.installed:
    - name: yaz
    - defaults: true

Steps to Reproduce the behavior
Run a pecl.installed stated on a server behind a proxy-server.
This is a sample log output from /var/log/salt/minion:

2020-10-02 16:42:50,842 [salt.loaded.int.module.cmdmod:854 ][ERROR ][2412048] Command 'yes '' | pecl -d preferred_state=stable install yaz' failed with return code: 1
2020-10-02 16:42:50,843 [salt.loaded.int.module.cmdmod:856 ][ERROR ][2412048] stdout: Connection to `ssl://pecl.php.net:443' failed: Connection timed out
2020-10-02 16:42:50,843 [salt.loaded.int.module.cmdmod:860 ][ERROR ][2412048] retcode: 1
2020-10-02 16:42:50,844 [salt.loaded.int.module.pecl:55 ][ERROR ][2412048] Problem running pecl. Is php-pear installed?

Expected behavior
It is possible to install pecl packages behind a proxy.

A solution could be to create an option for pecl.installed to pass "-c " to pecl.
This config-file could then contain a proxy-server setting.
Another way could be to use pecl config-set http_proxy just before the pecl install command.

Workaround
The following can be used as workaround. Just do it with cmd.run, as pecl.installed would do.

pear_proxy_config:
  file.managed:
    - name: /tmp/pearrc
    - contents:
      - '#PEAR_Config 0.9'
      - 'a:2:{s:10:"__channels";a:3:{s:5:"__uri";a:0:{}s:11:"doc.php.net";a:0:{}s:12:"pecl.php.net";a:0:{}}s:10:"http_proxy";s:42:"http://<proxy-server>:<port>";}'

install-php-yaz:
  cmd.run:
    - name: yes "" | pecl -c /tmp/pearrc install yaz
    - unless:
      - "pecl list | grep yaz"
    - require:
      - pear_proxy_config

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
           Salt: 3001.1
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 2.7.3
      docker-py: Not Installed
          gitdb: 2.0.6
      gitpython: 3.0.7
         Jinja2: 2.10.1
        libgit2: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.6.2
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: 3.6.1
         pygit2: Not Installed
         Python: 3.8.2 (default, Jul 16 2020, 14:00:26)
   python-gnupg: 0.4.5
         PyYAML: 5.3.1
          PyZMQ: 18.1.1
          smmap: 2.0.5
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2
 
System Versions:
           dist: ubuntu 20.04 focal
         locale: utf-8
        machine: x86_64
        release: 5.4.0-48-generic
         system: Linux
        version: Ubuntu 20.04 focal

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the pecl.installed state implementation and trace how it builds and runs the pecl install command. Reproduce the proxy failure using the supplied state and compare the -c configuration-file and config-set approaches; done means PECL packages can be installed through a proxy with a documented, tested option.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.