From 5a17db5d6b1c216d3097fbe7a044d279afc38450 Mon Sep 17 00:00:00 2001 From: Soubinan Date: Thu, 14 Dec 2023 04:23:12 -0500 Subject: [PATCH] Refactoring, remove default root password and unecessary syslog config --- Containerfile | 3 +-- cloudstack-init.env | 2 -- cloudstack-init.service | 8 +++----- cloudstack-management.service | 6 +----- compose.yaml | 24 ++++++++++-------------- 5 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Containerfile b/Containerfile index d6be3e8..88177c2 100644 --- a/Containerfile +++ b/Containerfile @@ -8,8 +8,7 @@ COPY ./rocky.repo /etc/yum.repos.d/rocky.repo RUN yum clean all && \ yum update -y && \ yum upgrade --refresh -y && \ - yum clean all -RUN yum install cloudstack-management hostname -y && \ + yum install cloudstack-management hostname -y && \ yum clean all RUN wget https://download.cloudstack.org/tools/vhd-util -O /usr/share/cloudstack-common/scripts/vm/hypervisor/xenserver/vhd-util diff --git a/cloudstack-init.env b/cloudstack-init.env index 4f6b45c..87e061c 100644 --- a/cloudstack-init.env +++ b/cloudstack-init.env @@ -1,7 +1,5 @@ # Default credentials to be updated DB_HOST=mysql -DB_ADM_USER=root -DB_ADM_PASSWD=root DB_CS_USER=cloud DB_CS_PASSWD=cloud ENCRYPTION_TYPE=file diff --git a/cloudstack-init.service b/cloudstack-init.service index 561325f..fa38e06 100644 --- a/cloudstack-init.service +++ b/cloudstack-init.service @@ -1,17 +1,15 @@ [Unit] Description=Cloudstack Setup Initialization After=network.target +ConditionPathExists=!/etc/default/.cloudstack-provisionned__ [Service] Type=oneshot RemainAfterExit=yes EnvironmentFile=/etc/default/cloudstack-init -ExecStart=/usr/bin/cloudstack-setup-databases ${DB_CS_USER}:${DB_CS_PASSWD}@${DB_HOST} --deploy-as=${DB_ADM_USER}:${DB_ADM_PASSWD} -e ${ENCRYPTION_TYPE} -m ${MGT_SERVER_KEY} -k ${DB_KEY} +ExecStart=/usr/bin/cloudstack-setup-databases ${DB_CS_USER}:${DB_CS_PASSWD}@${DB_HOST} --schema-only -e ${ENCRYPTION_TYPE} -m ${MGT_SERVER_KEY} -k ${DB_KEY} ExecStart=/usr/bin/cloudstack-setup-management - -StandardOutput=syslog -StandardError=syslog -SyslogIdentifier=cloudstack +ExecStart=/usr/bin/touch /etc/default/.cloudstack-provisionned__ [Install] WantedBy=multi-user.target diff --git a/cloudstack-management.service b/cloudstack-management.service index e86c5c9..d067963 100644 --- a/cloudstack-management.service +++ b/cloudstack-management.service @@ -2,9 +2,9 @@ Description=CloudStack Management Server After=syslog.target network.target mariadb.service mysqld.service mysql.service Wants=mariadb.service mysqld.service mysql.service +ConditionPathExists=/etc/default/.cloudstack-provisionned__ [Service] -UMask=0022 Type=simple User=cloud EnvironmentFile=/etc/default/cloudstack-management @@ -12,9 +12,5 @@ WorkingDirectory=/var/log/cloudstack/management PIDFile=/var/run/cloudstack-management.pid ExecStart=/usr/bin/java $JAVA_DEBUG $JAVA_OPTS -cp $CLASSPATH $BOOTSTRAP_CLASS -StandardOutput=syslog -StandardError=syslog -SyslogIdentifier=cloudstack - [Install] WantedBy=multi-user.target \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index a761fee..00fab85 100644 --- a/compose.yaml +++ b/compose.yaml @@ -18,8 +18,8 @@ services: - IPC_LOCK volumes: - ./cloudstack-init.env:/etc/default/cloudstack-init:Z - # - cs-config:/etc/cloudstack:Z - # - cs-data:/var/cloudstack:Z + - cs-config:/etc/cloudstack:Z + - cs-data:/var/cloudstack:Z logging: &default_logging driver: "json-file" options: @@ -29,24 +29,20 @@ services: mysql: image: docker.io/library/mysql:8.0-debian restart: unless-stopped - ports: - - 3306:3306 expose: - 3306 volumes: - ./cloudstack.cnf:/etc/mysql/conf.d/cloudstack.cnf:Z - # - mysql-data:/var/lib/mysql:Z + - mysql-data:/var/lib/mysql:Z environment: - MYSQL_ROOT_PASSWORD=root logging: <<: *default_logging -# To be uncommented if you want to persist your data -# -# volumes: -# cs-config: -# driver: local -# cs-data: -# driver: local -# mysql-data: -# driver: local +volumes: + cs-config: + driver: local + cs-data: + driver: local + mysql-data: + driver: local