semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Login fails when using the docker image

Open distributev opened this issue 2 years ago • 19 comments

Using the below basic docker compose ansible semaphore is up but I get 'Incorrect login or password' when I try to login using adminuser/adminpassword

When I try to debug and run commands like semaphore user list this doesn't work because I'm running semaphore using docker and these commands are not documented for the docker installation.

I tried to check the Dockerfile of semaphore but is not clear how to run adhoc commands since it uses ENTRYPOINT ["/sbin/tini", "--"] and wrappers like /usr/local/bin/semaphore-wrapper so it is not straightforward to understand how to execute a simple command like semaphore user list

Please document how adhoc commands should be executed on the docker image.


services:

  semaphore:
    container_name: semaphore
    image: semaphoreui/semaphore:latest
    environment:
      SEMAPHORE_DB_DIALECT: bolt
      SEMAPHORE_PLAYBOOK_PATH: /home/infraworker/run/automations/conf-manag/ansible
      SEMAPHORE_ADMIN: adminuser
      SEMAPHORE_ADMIN_NAME: Admin
      SEMAPHORE_ADMIN_PASSWORD: adminpassword
      SEMAPHORE_ADMIN_EMAIL: admin@localhost
    volumes:
      - /home/infraworker/apps/cvs/custom-semaphore/config:/etc/semaphore
      - /home/infraworker/apps/cvs/custom-semaphore/data-boltdb:/var/lib/semaphore # database.boltdb location (Not required if using mysql or postgres)
    restart: unless-stopped
    networks:
      - bridge_current_host_cross_containers_net

networks:
  bridge_current_host_cross_containers_net:
    driver: bridge
    external: true

distributev avatar Sep 27 '23 07:09 distributev

You can run adhoc commands in the running container with sudo docker exec -it semaphore_semaphore_1 /bin/sh

eg

$ semaphore user list --config /etc/semaphore/config.json 
Loading config
Validating config
admin

hmoffatt avatar Sep 27 '23 09:09 hmoffatt

OK, this is one step further

~ $ semaphore user list --config /etc/semaphore/config.json Loading config Validating config

no user is found because i have no user in config.json

The initial user I added in docker-compose.yml

environment: SEMAPHORE_ADMIN: adminuser SEMAPHORE_ADMIN_NAME: Admin SEMAPHORE_ADMIN_PASSWORD: adminpassword SEMAPHORE_ADMIN_EMAIL: admin@localhost

my understanding was that it should work like this, isn't so?

distributev avatar Sep 27 '23 10:09 distributev

I am using the example docker-compose.yml (https://docs.ansible-semaphore.com/administration-guide/installation#docker) and haven't added any other users, and I see admin listed. I don't know why it wouldn't work for you.

hmoffatt avatar Sep 27 '23 11:09 hmoffatt

Having the same problem, runing postgres as DB. Also

semaphore user list --config /etc/semaphore/config.json 
Loading config
Validating config

cuz there is no user inside defined.

@hmoffatt Can you show us your config.json ?

K1kc4 avatar Sep 27 '23 11:09 K1kc4

Its version problem, i have just tried with 2.9.16 and its working.

K1kc4 avatar Sep 27 '23 11:09 K1kc4

I'm using the latest beta 2.9.39 with postgres and it's working for me.

hmoffatt avatar Sep 27 '23 12:09 hmoffatt

Try with boltdb with environment in docker-compose.yml like this

environment: SEMAPHORE_DB_DIALECT: bolt SEMAPHORE_PLAYBOOK_PATH: /home/infraworker/run/automations/conf-manag/ansible SEMAPHORE_ADMIN: adminuser SEMAPHORE_ADMIN_NAME: Admin SEMAPHORE_ADMIN_PASSWORD: adminpassword SEMAPHORE_ADMIN_EMAIL: admin@localhost

and do not declare admin user in config.json, start semaphore and then try to login with the admin user declared in docker-compose.yml

another thing is that I added

SEMAPHORE_PLAYBOOK_PATH: /home/infraworker/run/automations/conf-manag/ansible

but it does not seem to be taken into account either - after login (admin added with cmd line) I cannot see any inventory declared and, further more, when I try to manually add the local inventory I am not allowed because it asks for an Access Key which I am not allowed to enter.

flowkraft avatar Sep 27 '23 12:09 flowkraft

I'm using the latest beta 2.9.39 with postgres and it's working for me.

Have you fresh installed, or its older instance being updated?

K1kc4 avatar Sep 27 '23 12:09 K1kc4

Have you fresh installed, or its older instance being updated?

Fresh.

hmoffatt avatar Sep 27 '23 12:09 hmoffatt

Possibly same as #1522

hmoffatt avatar Sep 28 '23 00:09 hmoffatt

Вы можете запускать специальные команды в работающем контейнере с помощьюsudo docker exec -it semaphore_semaphore_1 /bin/sh

например

$ semaphore user list --config /etc/semaphore/config.json 
Loading config
Validating config
admin

Can I use this to install winrm in my container? If yes, then show me how, please

NikitaIVll avatar Sep 29 '23 20:09 NikitaIVll

+1 on this issue. Even with using the latest image it seems that the env variables doesn't get taken into account. And when exec into the container and manually adding a Admin user i get a messsage saying not "Authorized"

mrjson79 avatar Jan 03 '24 07:01 mrjson79

Same. Only default SEMAPHORE_ADMIN_PASSWORD: changeme works.

deadnews avatar May 02 '24 15:05 deadnews

The environment variables are only used on the first start of semaphore.

tboerger avatar May 02 '24 15:05 tboerger

The environment variables are only used on the first start of semaphore.

If the settings values cannot be changed, then I don’t understand why users need such settings at all.

Setting up the password says changeme. And if you do exactly this, you get an incomprehensible error.

deadnews avatar May 02 '24 15:05 deadnews

@DeadNews you can set any password.

fiftin avatar May 02 '24 16:05 fiftin

you can set any password.

You can not. Incorrect login or password then. The whole issue is about this.

deadnews avatar May 02 '24 16:05 deadnews

I checked again by first deleting the database. Yes, you can set any password. Apparently the problem was that the first time it was started with SEMAPHORE_ADMIN_PASSWORD: changeme.

The environment variables are only used on the first start of semaphore.

It would be nice to add this comment to the docker-compose examples, if not already. Or even rename the variables to something like SEMAPHORE_INITIAL_ADMIN_PASSWORD to better reflect their behavior.

deadnews avatar May 02 '24 17:05 deadnews

@DeadNews you can use semaphore change-by-login CLI command to set password of existing user.

fiftin avatar May 02 '24 17:05 fiftin