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

FileExistsError on rc.prepare() #407

Open
jfmrm opened this issue Jan 27, 2020 · 6 comments
Open

FileExistsError on rc.prepare() #407

jfmrm opened this issue Jan 27, 2020 · 6 comments
Labels

Comments

@jfmrm
Copy link

jfmrm commented Jan 27, 2020

when ansible_runner.run() is called it initiates a Runner instance, and on the prepare() method it creates a couple of files on the private dir, the thing is: when the ssh private key fille already exists it raises an uncaught exception

  File "/home/joao.moura/workspace/concierge/inloco_tower/test/test_installer.py", line 20, in test_installer
    result = self.installer.run(target_instance="localhost", user="root")
  File "/home/joao.moura/workspace/concierge/inloco_tower/app/installer.py", line 19, in run
    runner = ansible_runner.run(
  File "/home/joao.moura/workspace/concierge/inloco_tower/venv/lib/python3.8/site-packages/ansible_runner/interface.py", line 177, in run
    r = init_runner(**kwargs)
  File "/home/joao.moura/workspace/concierge/inloco_tower/venv/lib/python3.8/site-packages/ansible_runner/interface.py", line 65, in init_runner
    rc.prepare()
  File "/home/joao.moura/workspace/concierge/inloco_tower/venv/lib/python3.8/site-packages/ansible_runner/runner_config.py", line 186, in prepare
    open_fifo_write(self.ssh_key_path, self.ssh_key_data)
  File "/home/joao.moura/workspace/concierge/inloco_tower/venv/lib/python3.8/site-packages/ansible_runner/utils.py", line 362, in open_fifo_write
    os.mkfifo(path, stat.S_IRUSR | stat.S_IWUSR)
FileExistsError: [Errno 17] File exists

Testing locally I simply added:

try:
  os.mkfifo(path, stat.S_IRUSR | stat.S_IWUSR)
except:
  pass

and solved the issue.

@matburt
Copy link
Member

matburt commented Jan 31, 2020

If you can make a PR for that we can get it merged in and close this out. Add an info or debug logger statement to note the skip.

@jfmrm
Copy link
Author

jfmrm commented Jan 31, 2020

sure, gonna do it!

@matburt
Copy link
Member

matburt commented Apr 7, 2020

Circling back to this, the only way I could see hitting this situation is if you passed ssh key data into Runner as well as having the file on the filesystem. Is that what you were doing here?

@jfmrm
Copy link
Author

jfmrm commented Apr 14, 2020

Yes, actually because on the first run of it the runner creates a file with the ssh key on the filesystem

@jfmrm
Copy link
Author

jfmrm commented Apr 14, 2020

and I actually forgot about it, sorry for that. I'll make this week

@AlanCoding
Copy link
Member

It may be possible to ignore the error in this particular case...

But I'm wondering if this is just one more consequence of #493. I guess there's no way to avoid writing this file, so the same solution wouldn't be possible, so I guess it is a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants