diff --git a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py index 1f47ee3ee50..a90e42604b3 100644 --- a/base/server/python/pki/server/deployment/scriptlets/instance_layout.py +++ b/base/server/python/pki/server/deployment/scriptlets/instance_layout.py @@ -52,11 +52,95 @@ def spawn(self, deployer): # Create /var/lib/pki/ instance.makedirs(instance.base_dir, exist_ok=True) - logger.info('Creating %s', instance.conf_dir) + # Create /etc/pki/ instance.makedirs(instance.conf_dir, exist_ok=True) + # Create /var/log/pki/ + instance.makedirs(instance.log_dir, exist_ok=True) + + # Create /var/lib/pki//temp + instance.makedirs(instance.temp_dir, exist_ok=True) + + # Create /var/lib/pki//work + instance.makedirs(instance.work_dir, exist_ok=True) + + # Create /etc/pki//certs instance.makedirs(instance.certs_dir, exist_ok=True) + # Create /etc/pki//Catalina + catalina_dir = os.path.join(instance.conf_dir, 'Catalina') + instance.makedirs(catalina_dir, exist_ok=True) + + # Create /etc/pki//Catalina/localhost + localhost_dir = os.path.join(catalina_dir, 'localhost') + instance.makedirs(localhost_dir, exist_ok=True) + + shared_conf_path = os.path.join( + pki.server.PKIServer.SHARE_DIR, + 'server', + 'conf') + + # Link /etc/pki//catalina.properties + # to /usr/share/pki/server/conf/catalina.properties. + instance.symlink( + os.path.join(shared_conf_path, 'catalina.properties'), + os.path.join(instance.conf_dir, 'catalina.properties'), + exist_ok=True) + + # Link /etc/pki//context.xml + # to /usr/share/tomcat/conf/context.xml. + context_xml = os.path.join(pki.server.Tomcat.CONF_DIR, 'context.xml') + instance.symlink( + context_xml, + instance.context_xml, + exist_ok=True) + + # Link /etc/pki//logging.properties + # to /usr/share/pki/server/conf/logging.properties. + instance.symlink( + os.path.join(shared_conf_path, 'logging.properties'), + os.path.join(instance.conf_dir, 'logging.properties'), + exist_ok=True) + + # Link /etc/pki//web.xml + # to /usr/share/tomcat/conf/web.xml. + web_xml = os.path.join(pki.server.Tomcat.CONF_DIR, 'web.xml') + instance.symlink( + web_xml, + instance.web_xml, + exist_ok=True) + + # Rewrite rules are subsystem-specific, but the config is server-wide. + # So we deploy them as part of the server config, regardless of which + # subsystem(s) will eventually be deployed. + logger.info('Deploying HTTP rewrite rules (rewrite.config)') + instance.symlink( + os.path.join(shared_conf_path, 'Catalina', 'localhost', 'rewrite.config'), + os.path.join(localhost_dir, 'rewrite.config'), + exist_ok=True, + ) + + # Link /var/lib/pki//bin to /usr/share/tomcat/bin + bin_dir = os.path.join(pki.server.Tomcat.SHARE_DIR, 'bin') + instance.symlink( + bin_dir, + instance.bin_dir, + exist_ok=True) + + # Link /var/lib/pki//conf to /etc/pki/ + conf_link = os.path.join(instance.base_dir, 'conf') + instance.symlink( + instance.conf_dir, + conf_link, + exist_ok=True) + + # Link /var/lib/pki//logs to /var/log/pki/ + logs_link = os.path.join(instance.base_dir, 'logs') + instance.symlink( + instance.log_dir, + logs_link, + exist_ok=True) + # Configuring internal token password internal_token = deployer.mdict['pki_self_signed_token'] @@ -124,37 +208,8 @@ def spawn(self, deployer): logger.info('Installing %s instance', instance.name) return - deployer.directory.create(instance.log_dir) - - shared_conf_path = os.path.join( - pki.server.PKIServer.SHARE_DIR, - 'server', - 'conf') - deployer.configure_server_xml() - # Link /etc/pki//catalina.properties - # to /usr/share/pki/server/conf/catalina.properties. - instance.symlink( - os.path.join(shared_conf_path, 'catalina.properties'), - os.path.join(instance.conf_dir, 'catalina.properties'), - exist_ok=True) - - # Link /etc/pki//context.xml - # to /usr/share/tomcat/conf/context.xml. - context_xml = os.path.join(pki.server.Tomcat.CONF_DIR, 'context.xml') - instance.symlink( - context_xml, - instance.context_xml, - exist_ok=True) - - # Link /etc/pki//logging.properties - # to /usr/share/pki/server/conf/logging.properties. - instance.symlink( - os.path.join(shared_conf_path, 'logging.properties'), - os.path.join(instance.conf_dir, 'logging.properties'), - exist_ok=True) - # Copy /usr/share/pki/server/conf/tomcat.conf # to /etc/sysconfig/ @@ -176,33 +231,6 @@ def spawn(self, deployer): os.path.join(instance.conf_dir, 'tomcat.conf'), overwrite_flag=True) - # Link /etc/pki//web.xml - # to /usr/share/tomcat/conf/web.xml. - web_xml = os.path.join(pki.server.Tomcat.CONF_DIR, 'web.xml') - instance.symlink( - web_xml, - instance.web_xml, - exist_ok=True) - - # Create /etc/pki//Catalina - catalina_dir = os.path.join(instance.conf_dir, 'Catalina') - instance.makedirs(catalina_dir, exist_ok=True) - - # Create /etc/pki//Catalina/localhost - localhost_dir = os.path.join(catalina_dir, 'localhost') - instance.makedirs(localhost_dir, exist_ok=True) - - # Rewrite rules are subsystem-specific, but the config is server-wide. - # So we deploy them as part of the server config, regardless of which - # subsystem(s) will eventually be deployed. - # - logger.info('Deploying HTTP rewrite rules (rewrite.config)') - instance.symlink( - os.path.join(shared_conf_path, 'Catalina', 'localhost', 'rewrite.config'), - os.path.join(localhost_dir, 'rewrite.config'), - exist_ok=True, - ) - logger.info('Deploying ROOT web application') # Copy /usr/share/pki/server/conf/ROOT.xml # to /etc/pki//Catalina/localhost/ROOT.xml @@ -232,36 +260,6 @@ def spawn(self, deployer): instance.with_maven_deps = deployer.with_maven_deps instance.create_libs(force=True) - # Create /var/lib/pki//temp - deployer.directory.create(instance.temp_dir) - - # Create /var/lib/pki//work - deployer.directory.create(instance.work_dir) - - # Link /var/lib/pki//bin to /usr/share/tomcat/bin - instance.symlink( - deployer.mdict['pki_tomcat_bin_path'], - instance.bin_dir, - exist_ok=True) - - # Link /var/lib/pki//conf to /etc/pki/ - conf_link = os.path.join(instance.base_dir, 'conf') - instance.symlink( - instance.conf_dir, - conf_link, - exist_ok=True) - - # Create /etc/pki//certs - certs_path = os.path.join(instance.conf_dir, 'certs') - deployer.directory.create(certs_path) - - # Link /var/lib/pki//logs to /var/log/pki/ - logs_link = os.path.join(instance.base_dir, 'logs') - instance.symlink( - instance.log_dir, - logs_link, - exist_ok=True) - if config.str2bool(deployer.mdict['pki_registry_enable']): instance.create_registry()