semaphoreui / semaphore

Modern UI and powerful API for Ansible, Terraform, OpenTofu, PowerShell and other DevOps tools.
https://semaphoreui.com
MIT License
10.6k stars 1.07k forks source link

Ansible Galaxy Collections behind Proxy #999

Closed SzZoli closed 1 year ago

SzZoli commented 2 years ago

Hi all,

I am trying to run a Semaphore task that requires ansible galaxy module. Similar to this: https://github.com/ansible-semaphore/semaphore/issues/682#issuecomment-1071008705

The issue is I am behind a proxy. How could I configure my proxy settings for a Semaphore task run?

Background: I am running Semaphore on a VM, Ubuntu 20.04. I created requirements.yml that contains the module I need. During the task run the galaxy collection finds this and tries to install the module. For this the process tries to access the net and gets blocked by my corp proxy.

So far I've tried the following

  1. setting http_proxy and https_proxy parameters
  2. setting proxy in /etc/environment
  3. installing the galaxy collection from CLI on my VM: ansible-galaxy install -r roles/requirements.yml --force -> that completes successfully

None of this helped, my proxy parameters are not used. Still getting the following error when running the task from Semaphore:

   ERROR! Error when finding available api versions from default (https://galaxy.ansible.com) 
   Running galaxy failed: exit status 1

Any idea how I could feed my proxy settings to Semaphore?

Thanks

andreas-marschke commented 1 year ago

I suggest looking into https://docs.ansible.com/ansible/2.9/user_guide/playbooks_environment.html Which describes how to configure for a http(s) proxy environment. This should be your ansible.cfg in the repo that you cloned to run an ansible task.

OsodracPT commented 1 year ago

Here's what worked for me. If you are running the semaphore as a service then edit this file /etc/systemd/system/semaphore.service. Edit the following lines:

[Service] Environment="https_proxy=YOURPROXY" Environment="http_proxy=YOURPROXY"

And then restart the semaphore service.

SzZoli commented 1 year ago

Thanks for the response Osodrac, that is also the solution I am using!