Question

Cannot Create Droplet With CloudInit Config

Hi,

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 root user.

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 [mysql_secure_installation]: https://dev.mysql.com/doc/refman/5.7/en/mysql-secure-installation.html [YAML validator]: http://www.yamllint.com/

Show comments

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Accepted Answer

TL;DR

There’s a filter, and nothing can be done about it. Use the API instead.

Full Answer

DO support acknowledges the problem, admits the existence of a filter. Please find their final reply below.

I believe the filtering is in place on the front-end to avoid injection attempts. Unfortunately, we aren’t able to loosen the current grips of that filtering. As a solution to the issue without reconfiguring the scripts, we’d recommend utilizing the API instead of the web panel for this creation

This comment has been deleted

    Try DigitalOcean for free

    Click below to sign up and get $200 of credit to try our products over 60 days!

    Sign up

    card icon
    Get our biweekly newsletter

    Sign up for Infrastructure as a Newsletter.

    Sign up
    card icon
    Hollie's Hub for Good

    Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

    Learn more
    card icon
    Become a contributor

    You get paid; we donate to tech nonprofits.

    Learn more
    Welcome to the developer cloud

    DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

    Learn more ->
    DigitalOcean Cloud Control Panel