Move from /opt/dc/ansible to /var/opt/dc/ansible

Move the /opt/dc/ansible directory to /var tree in order
to use the writeable partition in ostree environment.

The directory is changed for both debian and centos
environments.

Test Plan:

For both debian and centos:
- Bootstrap system controller
- Bootstrap subcloud
- Verify ansible is successful, including generation of
  inventory files used when invoking ansible.
- Centos only: manage subcloud, verify that it comes in-sync

Story: 2010119
Task: 45799

Signed-off-by: Kyle MacLeod <kyle.macleod@windriver.com>
Change-Id: I24766798728a647de1de447644b02e11709ed103
This commit is contained in:
Kyle MacLeod 2022-07-12 20:52:39 -04:00 committed by Kyle MacLeod
parent 1242c26b9e
commit a127f4d5ef
7 changed files with 53 additions and 35 deletions

View File

@ -182,7 +182,7 @@ cd %{_builddir}/%{pypi_name}-%{version} && oslo-config-generator --config-file .
install -p -D -m 640 %{_builddir}/%{pypi_name}-%{version}%{_sysconfdir}/dcdbsync/dcdbsync.conf.sample %{buildroot}%{_sysconfdir}/dcdbsync/dcdbsync.conf
# install ansible overrides dir
install -d -m 600 ${RPM_BUILD_ROOT}/opt/dc/ansible
install -d -m 600 ${RPM_BUILD_ROOT}/var/opt/dc/ansible
# install dcorch cleaner
install -m 755 -D -p %{SOURCE12} %{buildroot}/%{_bindir}/clean-dcorch
@ -217,7 +217,7 @@ install -m 755 -D -p %{SOURCE12} %{buildroot}/%{_bindir}/clean-dcorch
%dir %attr(0755,root,root) %{_sysconfdir}/dcmanager
%config(noreplace) %attr(-, root, root) %{_sysconfdir}/dcmanager/dcmanager.conf
%dir %attr(0755,root,root) /usr/lib/ocf/resource.d/openstack
%dir %attr(0600,root,root) /opt/dc/ansible
%dir %attr(0600,root,root) /var/opt/dc/ansible
%defattr(-,root,root,-)
/usr/lib/ocf/resource.d/openstack/dcmanager-*

View File

@ -1394,7 +1394,7 @@ class SubcloudsController(object):
# Pseudo code:
# - Retrieve install_values of the subcloud from the database.
# If it does not exist, try to retrieve the bootstrap address
# from its ansible inventory file (/opt/dc/ansible).
# from its ansible inventory file (/var/opt/dc/ansible).
# - If the bootstrap address can be obtained, add install_values
# to the payload and continue.
# - If the bootstrap address cannot be obtained, abort with an

View File

@ -207,7 +207,7 @@ ALARM_DEGRADED_STATUS = "degraded"
ALARM_CRITICAL_STATUS = "critical"
# subcloud deploy file options
ANSIBLE_OVERRIDES_PATH = '/opt/dc/ansible'
ANSIBLE_OVERRIDES_PATH = '/var/opt/dc/ansible'
DEPLOY_PLAYBOOK = "deploy_playbook"
DEPLOY_OVERRIDES = "deploy_overrides"
DEPLOY_CHART = "deploy_chart"

View File

@ -1323,9 +1323,12 @@ class TestSubcloudAPIOther(testroot.DCManagerApiTest):
bootstrap_file = sc._get_config_file_path("subcloud1")
install_values = sc._get_config_file_path("subcloud1", "install_values")
deploy_config = sc._get_config_file_path("subcloud1", consts.DEPLOY_CONFIG)
self.assertEqual(bootstrap_file, "/opt/dc/ansible/subcloud1.yml")
self.assertEqual(install_values, "/opt/dc/ansible/subcloud1/install_values.yml")
self.assertEqual(deploy_config, "/opt/dc/ansible/subcloud1_deploy_config.yml")
self.assertEqual(bootstrap_file,
"/var/opt/dc/ansible/subcloud1.yml")
self.assertEqual(install_values,
"/var/opt/dc/ansible/subcloud1/install_values.yml")
self.assertEqual(deploy_config,
"/var/opt/dc/ansible/subcloud1_deploy_config.yml")
@mock.patch.object(rpc_client, 'ManagerClient')
def test_format_ip_address(self, mock_rpc_client):

View File

@ -1299,31 +1299,36 @@ class TestSubcloudManager(base.DCManagerTestCase):
sm = subcloud_manager.SubcloudManager()
filename = sm._get_ansible_filename('subcloud1',
consts.INVENTORY_FILE_POSTFIX)
self.assertEqual(filename, '/opt/dc/ansible/subcloud1_inventory.yml')
self.assertEqual(filename,
'/var/opt/dc/ansible/subcloud1_inventory.yml')
def test_compose_install_command(self):
sm = subcloud_manager.SubcloudManager()
install_command = sm.compose_install_command(
'subcloud1', '/opt/dc/ansible/subcloud1_inventory.yml')
'subcloud1', '/var/opt/dc/ansible/subcloud1_inventory.yml')
self.assertEqual(
install_command,
[
'ansible-playbook', subcloud_manager.ANSIBLE_SUBCLOUD_INSTALL_PLAYBOOK,
'-i', '/opt/dc/ansible/subcloud1_inventory.yml', '--limit', 'subcloud1',
'-e', "@/opt/dc/ansible/subcloud1/install_values.yml"
'ansible-playbook',
subcloud_manager.ANSIBLE_SUBCLOUD_INSTALL_PLAYBOOK,
'-i', '/var/opt/dc/ansible/subcloud1_inventory.yml',
'--limit', 'subcloud1',
'-e', "@/var/opt/dc/ansible/subcloud1/install_values.yml"
]
)
def test_compose_apply_command(self):
sm = subcloud_manager.SubcloudManager()
apply_command = sm.compose_apply_command(
'subcloud1', '/opt/dc/ansible/subcloud1_inventory.yml')
'subcloud1', '/var/opt/dc/ansible/subcloud1_inventory.yml')
self.assertEqual(
apply_command,
[
'ansible-playbook', subcloud_manager.ANSIBLE_SUBCLOUD_PLAYBOOK, '-i',
'/opt/dc/ansible/subcloud1_inventory.yml', '--limit', 'subcloud1', '-e',
"override_files_dir='/opt/dc/ansible' region_name=subcloud1"
'ansible-playbook',
subcloud_manager.ANSIBLE_SUBCLOUD_PLAYBOOK, '-i',
'/var/opt/dc/ansible/subcloud1_inventory.yml',
'--limit', 'subcloud1', '-e',
"override_files_dir='/var/opt/dc/ansible' region_name=subcloud1"
]
)
@ -1335,27 +1340,33 @@ class TestSubcloudManager(base.DCManagerTestCase):
"deploy_chart": "test_chart.yaml",
"deploy_config": "subcloud1.yaml"}
deploy_command = sm.compose_deploy_command(
'subcloud1', '/opt/dc/ansible/subcloud1_inventory.yml', fake_payload)
'subcloud1',
'/var/opt/dc/ansible/subcloud1_inventory.yml',
fake_payload)
self.assertEqual(
deploy_command,
[
'ansible-playbook', 'test_playbook.yaml', '-e',
'@/opt/dc/ansible/subcloud1_deploy_values.yml', '-i',
'/opt/dc/ansible/subcloud1_inventory.yml', '--limit', 'subcloud1'
'@/var/opt/dc/ansible/subcloud1_deploy_values.yml', '-i',
'/var/opt/dc/ansible/subcloud1_inventory.yml',
'--limit', 'subcloud1'
]
)
def test_compose_rehome_command(self):
sm = subcloud_manager.SubcloudManager()
rehome_command = sm.compose_rehome_command(
'subcloud1', '/opt/dc/ansible/subcloud1_inventory.yml')
'subcloud1', '/var/opt/dc/ansible/subcloud1_inventory.yml')
self.assertEqual(
rehome_command,
[
'ansible-playbook', subcloud_manager.ANSIBLE_SUBCLOUD_REHOME_PLAYBOOK, '-i',
'/opt/dc/ansible/subcloud1_inventory.yml', '--limit', 'subcloud1',
'ansible-playbook',
subcloud_manager.ANSIBLE_SUBCLOUD_REHOME_PLAYBOOK, '-i',
'/var/opt/dc/ansible/subcloud1_inventory.yml',
'--limit', 'subcloud1',
'--timeout', subcloud_manager.REHOME_PLAYBOOK_TIMEOUT,
'-e', "override_files_dir='/opt/dc/ansible' region_name=subcloud1"
'-e',
"override_files_dir='/var/opt/dc/ansible' region_name=subcloud1"
]
)
@ -1579,28 +1590,32 @@ class TestSubcloudManager(base.DCManagerTestCase):
def test_compose_check_target_command(self):
sm = subcloud_manager.SubcloudManager()
check_target_command = sm.compose_check_target_command(
'subcloud1', '/opt/dc/ansible/subcloud1_inventory.yml',
'subcloud1', '/var/opt/dc/ansible/subcloud1_inventory.yml',
FAKE_SUBCLOUD_RESTORE_PAYLOAD)
self.assertEqual(
check_target_command,
[
'ansible-playbook', subcloud_manager.ANSIBLE_HOST_VALIDATION_PLAYBOOK,
'-i', '/opt/dc/ansible/subcloud1_inventory.yml', '--limit', 'subcloud1',
'-e', '@/opt/dc/ansible/subcloud1_check_target_values.yml'
'ansible-playbook',
subcloud_manager.ANSIBLE_HOST_VALIDATION_PLAYBOOK,
'-i', '/var/opt/dc/ansible/subcloud1_inventory.yml',
'--limit', 'subcloud1',
'-e', '@/var/opt/dc/ansible/subcloud1_check_target_values.yml'
]
)
def test_compose_restore_command(self):
sm = subcloud_manager.SubcloudManager()
restore_command = sm.compose_restore_command(
'subcloud1', '/opt/dc/ansible/subcloud1_inventory.yml',
'subcloud1', '/var/opt/dc/ansible/subcloud1_inventory.yml',
FAKE_SUBCLOUD_RESTORE_PAYLOAD)
self.assertEqual(
restore_command,
[
'ansible-playbook', subcloud_manager.ANSIBLE_SUBCLOUD_RESTORE_PLAYBOOK,
'-i', '/opt/dc/ansible/subcloud1_inventory.yml', '--limit', 'subcloud1',
'-e', '@/opt/dc/ansible/subcloud1_restore_values.yml'
'ansible-playbook',
subcloud_manager.ANSIBLE_SUBCLOUD_RESTORE_PLAYBOOK,
'-i', '/var/opt/dc/ansible/subcloud1_inventory.yml',
'--limit', 'subcloud1',
'-e', '@/var/opt/dc/ansible/subcloud1_restore_values.yml'
]
)

View File

@ -1,2 +1,2 @@
opt/dc/ansible
var/opt/dc/ansible
var/log/dcmanager

View File

@ -47,7 +47,7 @@ override_dh_install:
install -m 755 -D -p files/clean-dcorch $(BIN_DIR)/clean-dcorch
# install ansible overrides dir
install -d -m 600 $(ROOT)/opt/dc/ansible
install -d -m 600 $(ROOT)/var/opt/dc/ansible
# Generate sample config and add the current directory to PYTHONPATH so
# oslo-config-generator doesn't skip heat's entry points.
@ -99,5 +99,5 @@ override_dh_fixperms:
--exclude etc/dcorch/dcorch.conf
execute_after_dh_fixperms:
# forcing 600 for /opt/dc/ansible
chmod 600 debian/distributedcloud-dcmanager/opt/dc/ansible
# forcing 600 for /var/opt/dc/ansible
chmod 600 debian/distributedcloud-dcmanager/var/opt/dc/ansible