Copy the inventory for standalone deploy in output_dir

In order to be re-used by post deployment action, this review
copy the ansible inventory into the output_dir as:
standalone-inventory.yaml.
If file exist it will replace the old one.

Change-Id: Ied14f40cf074755225abe1e8f1c859bacbe9022f
(cherry picked from commit 0736e447f9)
This commit is contained in:
Mathieu Bultel 2021-02-25 13:02:07 +01:00 committed by mbu
parent 1683e1bff9
commit 75aa21e91e
3 changed files with 10 additions and 3 deletions

View File

@ -98,9 +98,10 @@ VALIDATIONS_LOG_BASEDIR = '/var/log/validations'
DEFAULT_WORK_DIR = os.path.join(os.environ.get('HOME', '~/'), DEFAULT_WORK_DIR = os.path.join(os.environ.get('HOME', '~/'),
'config-download') 'config-download')
ANSIBLE_INVENTORY = os.path.join(DEFAULT_WORK_DIR, TRIPLEO_STATIC_INVENTORY = 'tripleo-ansible-inventory.yaml'
'{}/tripleo-ansible-inventory.yaml')
ANSIBLE_INVENTORY = os.path.join(DEFAULT_WORK_DIR,
'{}/', TRIPLEO_STATIC_INVENTORY)
ANSIBLE_VALIDATION_DIR = ( ANSIBLE_VALIDATION_DIR = (
os.path.join(DEFAULT_VALIDATIONS_LEGACY_BASEDIR, 'playbooks') os.path.join(DEFAULT_VALIDATIONS_LEGACY_BASEDIR, 'playbooks')
if os.path.exists(os.path.join(DEFAULT_VALIDATIONS_LEGACY_BASEDIR, if os.path.exists(os.path.join(DEFAULT_VALIDATIONS_LEGACY_BASEDIR,

View File

@ -816,7 +816,9 @@ class TestDeployUndercloud(TestPluginV1):
@mock.patch('tripleo_common.utils.config.Config', @mock.patch('tripleo_common.utils.config.Config',
autospec=True) autospec=True)
@mock.patch('os.path.join', return_value='/twd/inventory.yaml') @mock.patch('os.path.join', return_value='/twd/inventory.yaml')
def test_download_ansible_playbooks(self, mock_join, mock_stack_config, @mock.patch('shutil.copyfile')
def test_download_ansible_playbooks(self, mock_shutil, mock_join,
mock_stack_config,
mock_launch_heat, mock_importInv, mock_launch_heat, mock_importInv,
createdir_mock): createdir_mock):

View File

@ -869,6 +869,10 @@ class Deploy(command.Command):
} }
inventory.write_static_inventory(inv_path, extra_vars) inventory.write_static_inventory(inv_path, extra_vars)
# Move inventory in output_dir in order to be reusable by users:
shutil.copyfile(inv_path,
os.path.join(self.output_dir,
constants.TRIPLEO_STATIC_INVENTORY))
self.log.info(_('** Downloaded {0} ansible to {1} **').format( self.log.info(_('** Downloaded {0} ansible to {1} **').format(
stack_name, self.tmp_ansible_dir)) stack_name, self.tmp_ansible_dir))