semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

winrm or requests is not installed: No module named ''winrm

Open jsinic opened this issue 2 years ago • 15 comments

Hi

I have problems with running task template in Semaphore GUI.

fatal: [IP_ADRESS]: FAILED! => msg: 'winrm or requests is not installed: No module named ''winrm'''

If i run same playbook and same host in the CLI mode it works.

My specs are: ansible 2.7.0 python version = 3.6.8 (default, Nov 9 2021, 14:44:26) [GCC 8.5.0 20210514 (Red Hat 8.5.0-3)] Semaphore version 2.8.53

Do you have any advices how to solve this issue?

jsinic avatar Feb 28 '22 21:02 jsinic

What Semaphore installation do you use (snap, docker or binary)?

fiftin avatar Mar 06 '22 07:03 fiftin

I use snap.

jsinic avatar Mar 06 '22 07:03 jsinic

Same issue using Snap installer.

Br4v3St4rr avatar Mar 08 '22 15:03 Br4v3St4rr

I use the docker install and getting the same issue.

heatwebs22 avatar Apr 29 '22 15:04 heatwebs22

I also encountered the same situation using docker. As I understand it, openshift uses the docker image too, it should probably have the same return.

Probably when trying to connect using psrp you will get a message similar to “Failed to connect to the host via PSRP”, because it is necessary to include pypsrp.

WinRM and PSRP are part of ansible-core and are included with all Ansible installations, but the pywinrm and pypsrp requirements are required on the local controller node that makes this connection.

For docker I believe it is possible to change the Dockerfile and include py3-pip, pywinrm and/or pypsrp.

I changed the Dockerfile:

RUN apk add --no-cache sshpass git curl ansible py3-pip mysql-client openssh-client tini && \
    adduser -D -u 1001 -G root semaphore && \
    pip3 install pywinrm && \
    pip3 install pypsrp && \    
    mkdir -p /tmp/semaphore && \
    mkdir -p /etc/semaphore && \
    chown -R semaphore:0 /tmp/semaphore && \
    chown -R semaphore:0 /etc/semaphore

I created three images to compare with the prod-compose image: context=prod tag=winrm-psrp task docker:build context=prod tag=psrp task docker:build context=prod tag=winrm task docker:build

Result:

REPOSITORY                   TAG                 IMAGE ID       CREATED          SIZE
ansiblesemaphore/semaphore   prod-compose        c92d8c1395be   2 minutes ago    447MB
ansiblesemaphore/semaphore   winrm               74e585559e3f   8 minutes ago    463MB
ansiblesemaphore/semaphore   psrp                50600db239f8   23 minutes ago   464MB
ansiblesemaphore/semaphore   winrm-psrp          5e7df09b83de   34 minutes ago   465MB

The image size has increased by approximately 18MB.

I believe that to include it in the Snap installer or binary it is necessary to change the ansible-semaphore-snap/snapcraft.yaml:

  ansible:
    plugin: python
    source: .
    build-packages:
    - python3-venv
    - python3-dev
    stage-packages:
    - python3-venv
    override-build: |
      python3 -m venv ansible_env
      export PATH=ansible_env/bin:$PATH
      CRYPTOGRAPHY_DONT_BUILD_RUST=1
      pip3 install --upgrade pip
      pip3 install setuptools_rust wheel setuptools botocore boto3
      pip3 install ansible
      pip3 install pywinrm
      pip3 install pypsrp            
      tar cfz ansible_env.tar.gz ansible_env
      cp ansible_env.tar.gz $SNAPCRAFT_PART_INSTALL 

Both support basic, certificate and NTLM authentication, but to use Kerberos or CredSSP extra libraries are still needed.

If this is correct, is it possible that the semaphore project includes support for winrm, psrp, or both?

edineicolli avatar May 03 '22 18:05 edineicolli

It would be nice to add pywinrm to docker container. Because now it is needed to build my own image before usage. Thanks in advance.

iFFgen avatar Oct 04 '22 11:10 iFFgen

Could you try to install via ansible role?

Example Role: https://github.com/fiftin/ansible-semaphore-deploy-test/blob/master/roles/deps/tasks/main.yml Playbook: https://github.com/fiftin/ansible-semaphore-deploy-test/blob/master/deps.yml

fiftin avatar Oct 04 '22 14:10 fiftin

I'm using this image in K8s cluster. That's why I need this package in Semaphore container.

iFFgen avatar Oct 04 '22 18:10 iFFgen

So... I am trying first time semaphore as I love ansible but need some noobs around me to love it too so need UI and its for win targets

I am using docker compose

Will this get fixed by the official docker image? Or does anyone have publicly available image containing those winrm python dependencies?

DoTheEvo avatar Dec 17 '22 14:12 DoTheEvo

Hello! we also use the semaphore docker image as an azure web app. and we are running it to the same error.

As @edineicolli are pointing out it an easy fix to get ansible-semaphore to work with windows host, over powershell remote/winrm.

its just to pip3 install pywinrm && pip3 install pypsrp during the build of the official docker image, i have try to found it in this repo but no luck. Any one knowing the location of the Dockerfile?

Likned issues are: 1175

I hope we can see a update on this ASAP

Best regards

urskog84 avatar Jun 09 '23 12:06 urskog84

@urskog84 Dockerfile is here.

https://github.com/ansible-semaphore/semaphore/blob/develop/deployment/docker/prod/Dockerfile

cfredericksen avatar Jun 20 '23 17:06 cfredericksen

Looks like the problem is still open.

Ubuntu 22.04.3 Snap Installer

SB97 avatar Oct 16 '23 12:10 SB97

I solved this by folowing @cfredericksen example.

FROM semaphoreui/semaphore:latest

USER root
RUN apk add --no-cache python3 py3-pip
RUN pip install pywinrm jmespath netaddr passlib requests matrix_client

USER semaphore

ADD config.json /etc/semaphore/

urskog84 avatar Oct 16 '23 15:10 urskog84

Hello, I am new to managing Ansible, as well as Semaphore UI. I am trying to manage Windows machines using WINRM from Semaphore, which I installed using Docker Desktop. After configuring it, I couldn't get it to ping the Windows machines. The only way I found is to enter the Semaphore container terminal as root and install the necessary packages with the following commands:

apk add py3-pip pip install pywinrm

This way, I managed to handle my Windows machines from Semaphore. I apologize if what I'm posting is not relevant; I'm just trying to learn how to manage Ansible and Semaphore.

AndresGuty avatar Jan 30 '24 02:01 AndresGuty