diff --git a/WordPress/package/Classes/WordPress.yaml b/WordPress/package/Classes/WordPress.yaml index f0a4c2a2..75c267a5 100644 --- a/WordPress/package/Classes/WordPress.yaml +++ b/WordPress/package/Classes/WordPress.yaml @@ -16,6 +16,7 @@ Namespaces: sys: io.murano.system db: io.murano.databases srv: io.murano.apps.apache + conf: io.murano.configuration Name: WordPress @@ -59,11 +60,9 @@ Methods: - Throw: DependencyMissingError Message: $msg - - $resources: new(sys:Resources) - # Deploy Wordpress - - $template: $resources.yaml('DeployWordPress.template') - - $.server.instance.agent.call($template, $resources) + - $file: sys:Resources.string('deployWordPress.sh') + - conf:Linux.runCommand($.server.instance.agent, $file) # Configure access to MySql - $._environment.reporter.report($this, 'Ensuring Database is deployed.') @@ -71,18 +70,19 @@ Methods: - $.database.createUser($.dbUser, $.dbPassword) - $.database.assignUser($.dbUser, $.dbName) - $._environment.reporter.report($this, 'Configure access to MySql.') - - $template: $resources.yaml('ConfigureAccessToMySql.template').bind(dict( - database => $.dbName, - username => $.dbUser, - password => $.dbPassword, - host => $.database.instance.ipAddresses[0] - )) - - $.server.instance.agent.call($template, $resources) + - $replacements: + "%DATABASE%": $.dbName + "%USERNAME%": $.dbUser + "%HOST%": $.database.instance.ipAddresses.first() + "%PASSWORD%": $.dbPassword + + - $file: sys:Resources.string('configureAccessToMySql.sh').replace($replacements) + - conf:Linux.runCommand($.server.instance.agent, $file) - If: $.monitoring != null Then: - $.monitoring.setUpAgent($.server.instance) - + - $._environment.reporter.report($this, 'Application is installed') - If: $.server.instance.assignFloatingIp Then: diff --git a/WordPress/package/Resources/ConfigureAccessToMySql.template b/WordPress/package/Resources/ConfigureAccessToMySql.template deleted file mode 100644 index 948ad04c..00000000 --- a/WordPress/package/Resources/ConfigureAccessToMySql.template +++ /dev/null @@ -1,34 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -FormatVersion: 2.0.0 -Version: 1.0.0 -Name: Configure database access credentails - -Parameters: - database: $database - username: $username - password: $password - host: $host - -Body: | - return configure('{0} {1} {2} {3}'.format(args.database, args.username, args.password, args.host)).stdout - -Scripts: - configure: - Type: Application - Version: 1.0.0 - EntryPoint: configureAccessToMySql.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/WordPress/package/Resources/DeployWordPress.template b/WordPress/package/Resources/DeployWordPress.template deleted file mode 100644 index 83c8d762..00000000 --- a/WordPress/package/Resources/DeployWordPress.template +++ /dev/null @@ -1,31 +0,0 @@ -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -FormatVersion: 2.0.0 -Version: 1.0.0 -Name: Deploy WordPress - -Parameters: - appName: $appName - -Body: | - return deploy(args.appName).stdout - -Scripts: - deploy: - Type: Application - Version: 1.0.0 - EntryPoint: deployWordPress.sh - Files: [] - Options: - captureStdout: true - captureStderr: true diff --git a/WordPress/package/Resources/scripts/configureAccessToMySql.sh b/WordPress/package/Resources/configureAccessToMySql.sh similarity index 61% rename from WordPress/package/Resources/scripts/configureAccessToMySql.sh rename to WordPress/package/Resources/configureAccessToMySql.sh index 699acdda..d80140e0 100644 --- a/WordPress/package/Resources/scripts/configureAccessToMySql.sh +++ b/WordPress/package/Resources/configureAccessToMySql.sh @@ -12,9 +12,9 @@ # under the License. -sudo sed -e "s/define('DB_NAME'.*$/define('DB_NAME', '$1');/" -i /var/www/html/wordpress/wp-config.php -sudo sed -e "s/define('DB_USER'.*$/define('DB_USER', '$2');/" -i /var/www/html/wordpress/wp-config.php -sudo sed -e "s/define('DB_PASSWORD'.*$/define('DB_PASSWORD', '$3');/" -i /var/www/html/wordpress/wp-config.php -sudo sed -e "s/define('DB_HOST'.*$/define('DB_HOST', '$4');/" -i /var/www/html/wordpress/wp-config.php +sudo sed -e "s/define('DB_NAME'.*$/define('DB_NAME', '%DATABASE%');/" -i /var/www/html/wordpress/wp-config.php +sudo sed -e "s/define('DB_USER'.*$/define('DB_USER', '%USERNAME%');/" -i /var/www/html/wordpress/wp-config.php +sudo sed -e "s/define('DB_PASSWORD'.*$/define('DB_PASSWORD', '%PASSWORD%');/" -i /var/www/html/wordpress/wp-config.php +sudo sed -e "s/define('DB_HOST'.*$/define('DB_HOST', '%HOST%');/" -i /var/www/html/wordpress/wp-config.php sudo service apache2 restart diff --git a/WordPress/package/Resources/scripts/deployWordPress.sh b/WordPress/package/Resources/deployWordPress.sh similarity index 100% rename from WordPress/package/Resources/scripts/deployWordPress.sh rename to WordPress/package/Resources/deployWordPress.sh