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

Support for explicit proxy using ansible variable instead of environment variable #556

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yodzeb
Copy link

@yodzeb yodzeb commented Jun 23, 2023

SUMMARY

Following issue :
fortinet-ansible-dev/ansible-galaxy-fortios-collection#240

The only way to use a proxy is to set the HTTP(S)_PROXY environment variables which are set globally for the ansible process. Unfortunatelly it does not permit to set a different proxy for different host or host_groups

Adding this option will allow to dynamically set an httpapi ansible variable "ansible_httpapi_explicit_proxy" based on host/hostgroup or any variable.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

httpapi

ADDITIONAL INFORMATION

In the send() fonction, os.environ variable HTTPS_PROXY and HTTP_PROXY are reset with the value provided.

This adds a new dependency with os python library. It may be improved or written differently i guess.

Usage:

- name: xxx
  hosts:
    - xxx
  gather_facts: True
  collections:
    - fortinet.fortios
  vars:
    ansible_httpapi_port: 443
    ansible_httpapi_use_ssl: True
    ansible_httpapi_validate_certs: False
    ansible_httpapi_use_proxy: True
    ansible_network_os: fortinet.fortios.fortios
    ansible_network_import_modules: False
    ansible_httpapi_explicit_proxy: "{{ ps }}"     # <<<<<< 
  connection: httpapi
[...]

yodzeb and others added 3 commits June 23, 2023 10:14
Support for an explicit proxy via ansible variable. 
fortinet-ansible-dev/ansible-galaxy-fortios-collection#240
Support for explicit proxy via ansible variable instead of environment variable
@codecov
Copy link

codecov bot commented Jun 23, 2023

Codecov Report

Merging #556 (2989699) into main (d46298a) will not change coverage.
The diff coverage is n/a.

❗ Current head 2989699 differs from pull request most recent head ccfd02b. Consider uploading reports for the commit ccfd02b to get more accurate results

@@           Coverage Diff           @@
##             main     #556   +/-   ##
=======================================
  Coverage   64.47%   64.47%           
=======================================
  Files          31       31           
  Lines        3868     3868           
  Branches      685      685           
=======================================
  Hits         2494     2494           
  Misses       1231     1231           
  Partials      143      143           

@yodzeb yodzeb marked this pull request as draft June 23, 2023 09:51
@yodzeb yodzeb closed this Jun 23, 2023
@yodzeb yodzeb reopened this Jun 23, 2023
@yodzeb yodzeb marked this pull request as ready for review June 23, 2023 10:00
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/2e88d1ee599445588121ae64b394dcb0

ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 12m 56s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 19m 24s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 05m 32s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39 SUCCESS in 52m 28s
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 13m 13s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 17m 40s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 15m 04s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39 SUCCESS in 18m 28s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 FAILURE in 15m 58s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 24m 14s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 SUCCESS in 16m 40s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 SUCCESS in 17m 25s
✔️ ansible-test-network-integration-nxos-cli-python39-scenario01 SUCCESS in 29m 45s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario02 FAILURE in 36m 47s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario03 SUCCESS in 34m 15s (non-voting)
✔️ ansible-test-network-integration-nxos-cli-python39-scenario04 SUCCESS in 33m 46s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-python39 SUCCESS in 55m 00s (non-voting)
✔️ ansible-test-network-integration-eos-httpapi-python39 SUCCESS in 46m 33s (non-voting)
✔️ ansible-test-network-integration-eos-network_cli-libssh-python39 SUCCESS in 56m 14s (non-voting)
ansible-ee-integration-ios-latest FAILURE in 17m 07s (non-voting)
ansible-ee-integration-ios-stable-2.9 FAILURE in 16m 58s (non-voting)
ansible-ee-integration-ios-stable-2.11 FAILURE in 15m 19s (non-voting)
ansible-ee-integration-ios-stable-2.12 FAILURE in 15m 27s (non-voting)
ansible-ee-integration-ios-libssh-latest FAILURE in 42m 46s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 46m 16s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.11 FAILURE in 50m 01s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.12 FAILURE in 49m 42s (non-voting)
ansible-test-network-integration-vyos-paramiko-python39-devel NODE_FAILURE Node request 200-0006142493 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable214 NODE_FAILURE Node request 200-0006142494 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable213 NODE_FAILURE Node request 200-0006142495 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable212 NODE_FAILURE Node request 200-0006142496 failed in 0s
ansible-test-network-integration-vyos-paramiko-python36-stable29 NODE_FAILURE Node request 200-0006142497 failed in 0s (non-voting)
ansible-test-network-integration-vyos-libssh-python39-devel NODE_FAILURE Node request 200-0006142498 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable214 NODE_FAILURE Node request 200-0006142499 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable213 NODE_FAILURE Node request 200-0006142500 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable212 NODE_FAILURE Node request 200-0006142501 failed in 0s
ansible-test-network-integration-vyos-libssh-python36-stable29 NODE_FAILURE Node request 200-0006142502 failed in 0s
✔️ build-ansible-collection SUCCESS in 15m 36s
✔️ ansible-test-network-integration-ansible-netcommon-junos-vsrx-netconf-python39 SUCCESS in 13m 44s
✔️ ansible-tox-linters SUCCESS in 11m 02s
✔️ ansible-galaxy-importer SUCCESS in 4m 21s

@KB-perByte KB-perByte requested a review from Qalthos June 28, 2023 13:09
@softwarefactory-project-zuul
Copy link
Contributor

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/4563be4b5860495eaa0b16542f1045e0

ansible-test-network-integration-junos-vsrx-netconf-python36-stable29 FAILURE in 12m 53s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-netconf-python36-stable211 SUCCESS in 1h 14m 16s
✔️ ansible-test-network-integration-junos-vsrx-netconf-python39-stable212 SUCCESS in 1h 05m 46s
ansible-test-network-integration-junos-vsrx-netconf-python39 RETRY_LIMIT in 8m 33s
ansible-test-network-integration-junos-vsrx-network_cli-python36-stable29 FAILURE in 12m 46s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python36-stable211 SUCCESS in 17m 02s
✔️ ansible-test-network-integration-junos-vsrx-network_cli-python39-stable212 SUCCESS in 16m 43s
ansible-test-network-integration-junos-vsrx-network_cli-python39 RETRY_LIMIT in 6m 00s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable29 RETRY_LIMIT in 5m 58s (non-voting)
✔️ ansible-test-network-integration-junos-vsrx-network_cli-libssh-python36-stable211 SUCCESS in 18m 39s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39-stable212 FAILURE in 13m 06s
ansible-test-network-integration-junos-vsrx-network_cli-libssh-python39 RETRY_LIMIT in 5m 43s
ansible-test-network-integration-nxos-cli-python39-scenario01 RETRY_LIMIT in 9m 18s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario02 RETRY_LIMIT in 5m 08s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario03 RETRY_LIMIT in 9m 11s (non-voting)
ansible-test-network-integration-nxos-cli-python39-scenario04 RETRY_LIMIT in 5m 12s (non-voting)
ansible-test-network-integration-eos-network_cli-python39 RETRY_LIMIT in 5m 44s (non-voting)
ansible-test-network-integration-eos-httpapi-python39 RETRY_LIMIT in 1m 01s (non-voting)
ansible-test-network-integration-eos-network_cli-libssh-python39 RETRY_LIMIT in 5m 20s (non-voting)
ansible-ee-integration-ios-latest FAILURE in 12m 32s (non-voting)
ansible-ee-integration-ios-stable-2.9 FAILURE in 15m 00s (non-voting)
ansible-ee-integration-ios-stable-2.11 FAILURE in 15m 00s (non-voting)
ansible-ee-integration-ios-stable-2.12 FAILURE in 12m 28s (non-voting)
ansible-ee-integration-ios-libssh-latest FAILURE in 15m 06s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.9 FAILURE in 12m 32s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.11 FAILURE in 13m 03s (non-voting)
ansible-ee-integration-ios-libssh-stable-2.12 FAILURE in 14m 03s (non-voting)
ansible-test-network-integration-vyos-paramiko-python39-devel NODE_FAILURE Node request 200-0006197232 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable214 NODE_FAILURE Node request 200-0006197233 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable213 NODE_FAILURE Node request 200-0006197234 failed in 0s
ansible-test-network-integration-vyos-paramiko-python39-stable212 NODE_FAILURE Node request 200-0006197235 failed in 0s
ansible-test-network-integration-vyos-paramiko-python36-stable29 NODE_FAILURE Node request 200-0006197236 failed in 0s (non-voting)
ansible-test-network-integration-vyos-libssh-python39-devel NODE_FAILURE Node request 200-0006197237 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable214 NODE_FAILURE Node request 200-0006197238 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable213 NODE_FAILURE Node request 200-0006197239 failed in 0s
ansible-test-network-integration-vyos-libssh-python39-stable212 NODE_FAILURE Node request 200-0006197240 failed in 0s
ansible-test-network-integration-vyos-libssh-python36-stable29 NODE_FAILURE Node request 200-0006197241 failed in 0s
✔️ build-ansible-collection SUCCESS in 15m 18s
ansible-test-network-integration-ansible-netcommon-junos-vsrx-netconf-python39 RETRY_LIMIT in 8m 20s
✔️ ansible-tox-linters SUCCESS in 10m 30s
✔️ ansible-galaxy-importer SUCCESS in 4m 39s

@rohitthakur2590 rohitthakur2590 requested review from NilashishC and removed request for Qalthos July 10, 2024 10:16
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

Successfully merging this pull request may close these issues.

2 participants