The inventory backup process takes the running inventory json file and
adds it to a tar archive. This process has no limits and will add files
to the tar archive until that is no longer possible and limited by the
underlying operating system. This change automatically prunes the backup
file and retains only the last 15 inventory files. This should provide
the same backup capabilities we've had without trying to saving
archives indefinitely.
> It should be noted that this change is using a subprocess call to
prune the tar file. This is being done because the "tarfile" library
does not provide an interface for deleting a file within an archive.
Change-Id: Ida5a9be0d0910c223fe05401bc4f75aef100e456
Closes-Bug: #1750233
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
When multiple users and process are accessing the dynamic inventory
the inventory backup and json can get corrupted. This change checks
for inventory modifictions and only saves if needed. The backup
is also moved to right before the actual save.
Change-Id: Ifd348ddd9c21526f5b523963dd1fd247edd6b109
Closes-Bug: #1750233
Change Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7 restructured the python
inventory generation code so that it would be possible to install it
with pip. This change removes (most) of the import path hacks and
switches to using a pip-installed version of osa_toolkit.
Of note, the path hacks are left in place for the dynamic_inventory.py
file for now, as that file is really more of an endpoint, but is tested.
Also, the bootstrap-ansible.sh script was modified to install the code;
this is unnecessary with the tox environments because the tox directive
'usedevelop=True' does that already. Production environments still need
this, though.
Finally, to maintain usability when called directly, the interpreter for
dynamic_inventory.py was updated from `/usr/bin/env` to
`/opt/ansible-runime/python`. This change ensures that in a full
deployment the user is using the exact same code paths whether Ansible
invokes the script, or it is called directly. This also means that using
the script locally on a development machine, it must be invoked as an
argument to Python, unless the ansible-runtime directory exists.
Change-Id: Iafa573b1b144f98528d5e0aceb3f36e9de2a22a2
This change allows the currently existing modules to be imported from
the `osa_toolkit` package.
In order to install the python modules used by the inventory via
setup.py with pbr, we need to rename the lib directory to match the name
of the package we wish to install.
pbr doesn't allow for doing any kind of directory renaming within the
setup.{cfg,py} files, but we need to keep using it in order to consume
global requirements updates.
Change-Id: Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7