7 Commits

Author SHA1 Message Date
Zuul
c8619eed66 Merge "Automatically prune the inventory backup" 2019-04-01 19:52:51 +00:00
Kevin Carter
ac28ad1329 Automatically prune the inventory backup
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>
2019-03-21 09:29:26 -05:00
Shannon Mitchell
71a067abf2 Dynamic inventory backup corruption fix
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
2019-02-17 18:02:57 -06:00
Maxime Guyot
d080a61d69 Add a warning in openstack_hostnames_ips.yml
Change-Id: I94de38ab0d314e7a029680ec6fc95a3f1bc056e2
2018-02-26 11:50:43 +01:00
Nolan Brubaker
ea6954f72f Use python import machinery for inventory code
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
2017-07-28 16:39:52 +00:00
Nolan Brubaker
e2f56ec634 Fix Python 3 bytes vs strings differences
Writing files was done fairly naively with our Python 2 code - this
change introduces explicit ASCII encoding when writing files.

Change-Id: I93c9fa4ba2fd8af9c9bf9424adaec602dbdca5f0
2017-06-08 18:42:07 +00:00
Nolan Brubaker
2be3319ac9 Restructure lib directory to install via pip
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
2017-03-30 10:19:01 -04:00