Skip to content

FileExistsError on rc.prepare() #407

@jfmrm

Description

@jfmrm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions