I’m trying to create a DO droplet and provision it using a quite long 64 line long
cloud-init file. I would like to end up with a LEMP environment which could be used as a target for a Capistrano deployment of a Bedrock-based WordPress installation. And it’s working great, except that [this config}[do_user_scripts/lemp.yml] leaves MySQL with the single and password-less
Now I would like to tighten the security of MySQL with [
mysql_secure_installation]. It appears that running this wit the
runcmd module is not possible, because
mysql_secure_installation is interactive. Therefore, the best way appears to be by running the SQL directly, However, when I merge the command(s) into the YAML document, I get the following message:
Sorry! We’ve encountered an error creating your Droplet.
Below please find the relevant section. Please note that as soon as I remove the lines starting with “mysql”, I am able to create the droplet.
--- runcmd: - mkdir -p /var/www/html/current - sed -i -e "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php/7.0/fpm/php.ini # Ensure backwards compatible with 14.04 - file=/etc/nginx/fastcgi.conf; if [ ! -f "$file" ]; then ln -s /etc/nginx/fastcgi_params "$file"; fi - service nginx restart - "mysql -u root -e \"CREATE DATABASE wordpress;\"" - "mysql -u root -e \"GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'wordpresspassword'; FLUSH PRIVILEGES;\""
I have tried arranging the above into different formats. I’ve tried putting it on into one
mysql command used several kinds of YAML multiline syntax, bash
HEREDOC to split the query into lines, and every time made sure that it gets validated by the [YAML validator]. Alas, I get the pesky message every time, and it pops out immediately after I hit the “Create” button. This means that the problem happens somewhere on the front-end, and could be with YAML validation. Which is weird, because “User data” isn’t even required to be valid YAML. And also, my YAML is valid. So, could somebody please explain what’s going on?
[this config}[do_user_scripts/lemp.yml]: https://github.com/digitalocean/do_user_scripts/blob/master/Ubuntu-16.04/web-servers/lemp.yml
[YAML validator]: http://www.yamllint.com/
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.