Multiple python-tripleoclient commands can run concurrently
and all attempt to update the same inventory file in
~/tripleo-ansible-inventory.yaml. Make the update atomic to
ensure the inventory file is always complete/valid.
(cherry picked from commit 8e082f45dd)
(squashing commits as the 1st patch is failing in the stein gate without
the fix from the 2nd patch)
Ensure atomic inventory file rename runs on the same mountpoint
Linux rename system call is only supported on the same mountpoint [1].
/tmp is often a tmpfs mount, so instead generate the temp inventory file in
the same directory as the target inventory file.
[1] See EXDEV in https://man7.org/linux/man-pages/man2/rename.2.html
Closes-bug: #1892008
Change-Id: Ifa41bfcb921496978f82aee4e67fdb419cf9ffc5
(cherry picked from commit 77a0c827cb)