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

Windows / WinRM Support? #56

Closed
prelegalwonder opened this issue Dec 22, 2015 · 10 comments
Closed

Windows / WinRM Support? #56

prelegalwonder opened this issue Dec 22, 2015 · 10 comments

Comments

@prelegalwonder
Copy link
Contributor

I've been having issues similar to issue 23 except I get the bugsnag ENOENT when semaphore goes to execute the playbook.

I've tried running it with debug logs as well as strace but can't tell why I'm getting the spawn error on ansible-playbook.

I've confirmed that I can run the ansible-playbook command manually against the downloaded playbook. Git is installed and semaphore connects to git just fine and downloads the playbook.

I tried debugging the runner.js but I'm no whiz at javascript and I couldn't find anything out of place and I'm guessing it's either an issue with my vault key or the fact that I'm using winrm?

Here's the basic error -

 node /srv/semaphore/bin/semaphore.js
app.js:110 Semaphore listening on port 80
app.js:47 Mongodb connection established


express deprecated res.send(status): Use res.sendStatus(status) instead ../srv/semaphore/lib/routes/task/tasks.js:79:6
::ffff:10.10.0.50 - - [22/Dec/2015:14:54:13 +0000] "POST /playbook/56787e7e389c472a006f0d6c/job/56787ece389c472a006f0d6d/run HTTP/1.1" 201 7 "http://semaphore-host.example.com/playbook/56787e7e389c472a006f0d6c/jobs" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36"
runner.js:240 Updating SSH Keys

runner.js:240 SSH Keys Updated.

runner.js:240
Downloading Playbook.

runner.js:240 Cloning into 'playbook_56787e7e389c472a006f0d6c'...

runner.js:240

Playbook Downloaded.

runner.js:240
Set up Ansible Hosts file with contents:
[windows]
192.168.1.10


runner.js:240
Starting play config/2012/Base.yml.

../node_modules/bugsnag/lib/logger.js:29 Bugsnag:  Error: spawn ansible-playbook ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1054:32)
    at child_process.js:1145:20
    at process._tickDomainCallback (node.js:381:11)

I've attached more detailed logs (strace and node-debug) as well as my customized Dockerfile if you want to try and reproduce. I needed a later ansible to get some of the newer win_modules.

This is nodejs v0.12.9

semaphore_logs.zip

Dockerfile-sempahore.txt

@prelegalwonder
Copy link
Contributor Author

I believe I just ruled out vault issues by decrypting the one vault protected group_vars yml and creating a new playbook that doesn't leverage vault at all.

@prelegalwonder
Copy link
Contributor Author

I've identified the issue. Its partly due to my custom docker file and where it installs ansible, and partly due to the fact that runner.js has hard-coded environment variables.

What do you think about doing a loop over the existing environment variables and adding them to runner?

What I had to modify was PATH, so maybe make PATH what you've currently got it set as then append :$PATH

As well as adding other ENV vars (I added PYTHONPATH) to the nodejs env for spawn?

@matejkramny
Copy link
Contributor

Hmm that should be configured in the ansible admin console and not when running.

How are you running semaphore?

I haven't tested semaphore on windows but its node.js / docker therefore I assumed it would be ok. The paths in runner.js expect a UNIX sort of system.

@prelegalwonder
Copy link
Contributor Author

Sorry,

I could have been more clear. My ansible server / source is a docker linux system. The nodes I'm managing are Windows over winrm. Regardless, it wasn't windows / winrm related as I had initially thought.

You mentioned ansible admin console is where ENV vars and PATH should be set, what url/uri would that be in Semaphore? (I probably just missed it).

If you want to reproduce what I'm seeing, I attached my Dockerfile in the first post. You can remove all of the artifactory and openssl stuff thats specific to me just running in a corp environment.

I'll poke around a bit more in semaphore and see if I can find what you're referring to and if not, fork and submit a PR and see what you think.

Cheers,
Andrew

@matejkramny
Copy link
Contributor

Right I was suggesting that if the ENV paths were to be configurable then it should be via the config in the web interface.

See if changing the paths here: https://github.com/ansible-semaphore/semaphore/blob/master/lib/runner.js#L206 lead to anything.

Locate the ansible-playbook binary and add it to the path. See if that works and ping back! :)

Cheers,
Matej

@prelegalwonder
Copy link
Contributor Author

Yep, thats the issue. I've got ansible-playbook in my $PATH but runner.js sets a specific environment that doesn't take into account the existing environment. When I added my path to ansible on that line it works fine.

Using that as a work-around, will see if I can submit a PR to pull in existing ENV when executing runner unless you can think of reasons you wouldn't want that to be default behavior.

@matejkramny
Copy link
Contributor

What is the path that you needed?

It might be good to use that path while semaphore is running under your environment.

@prelegalwonder
Copy link
Contributor Author

@matejkramny

What do you think about these for a PR?

Essentially for the PATH, just prepend existing ENV PATH, and for PYTHONPATH, if it's not set, it shouldn't impact anything since you're not setting it in the runner.js already?

Changes:
pullGit - PATH
playTheBook - PATH and PYTHONPATH

@matejkramny
Copy link
Contributor

prelegalwonder@199b82a looks ok.

If you make a PR i can merge that straight away..

Thanks

@corystein
Copy link

This is a workaround to use WinRM.

https://www.ansible.com/blog/connecting-to-a-windows-host

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

No branches or pull requests

3 participants