semaphoreui / semaphore

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

always using user 'semaphore' to connect to managed servers #1115

Open goldenpine opened 1 year ago

goldenpine commented 1 year ago

I deployed the latest semaphoreui/semaphore docker image to EKS; The actual inventory is managed by source code on a github repo, instead of being configured on UI. So in the task template, providing the inventory by args like below

[
  "-i", 
  "ansible/inventories/production/", 
  "-vv", 
  "-D"
]

In ansible/inventories/production/hosts, a host is defined as below,

myhost ansible_host=<fqdn of myhost>     ansible_user=aaa.bbb ansible_become_password="{{ aaa_bbb_password }}" ansible_password="{{ aaa_bbb_password  }}"

When running the task, it always fails with error "msg": "Invalid/incorrect password:..." After checking the logs, it's noticed a log of " Authenticating to ...:22 as 'semaphore'" It indicates the configuration of 'ansible_user' doesn't take effective, and the default user 'semaphore' was used.

Also tried to add 'remote_user' in my playbook, but the same issue. If I go to where my source is pulled, e.g. /tmp/semaphore/repository_2_7/ansible I can use command line to run playbook successfully.

So the question why ansible-semaphore ignores the configuration of ansible_user when connecting to a managed server? I doubt if there are any configurations I messed up.

exactoph commented 1 year ago

Have the same problem here. There is a workaround mentioned in #424 You can define the ansible_user variable in the extra_vars of the environment. However this only works, if you use the same username for all hosts in this environment.

Even with this workaround, this should be fixed as it's not possible to set user per hsot and defining in the inventory is the "ansible way" to do this ...

decanthus314 commented 1 year ago

Been working my way through a Semaphore deployment lately. Any reason you can't define your inventories in the UI, set the type to File, so it can pull from your git inventories? This way you can map your inventory to a user credential configured in the UI.