Skip to content

TASK: [wordpress | Create MySQL database] #85

Closed

Description

@connorblack

Hi guys,

So I'm trying to provision a joyent server running ubuntu 12.04, and after the script changes the owner of /var/www/ to deploy I get this error:

TASK: [wordpress | Create MySQL database] *************************************
 ** [out :: staging.****.******.**] failed: [127.0.0.1] => {"failed": true, "item": ""}
 ** [out :: staging.****.******.**] msg: unable to connect, check login_user and login_password are correct, or alternatively check ~/.my.cnf contains credentials
 ** [out :: staging.****.******.**]
 **[out :: staging.****.******.**] FATAL: all hosts have already failed -- aborting

I think the place the error is running is in /bower_components/wordpress/tasks/main.yml.


---
- name:           Change ownership of /var/www to deploy
  file:           path=/var/www state=directory owner=deploy group=deploy
  sudo:           yes

- name:           Create MySQL database
  mysql_db:       name=${mysql.name}

- name:           Create MySQL user
  mysql_user:     name=${mysql.user} host=${mysql.host} password=${mysql.password} priv=${mysql.name}.*:GRANT,ALL

- name:           Disable default apache site
  command:        a2dissite 000-default removes=/etc/apache2/sites-enabled/000-default

- name:           Create apache vhosts
  template:       src=vhosts/${item} dest=/etc/apache2/sites-available/${item}.${domain} mode=0644
  with_items:     ${apache_vhosts}
  sudo:           true

- name:           Enable apache vhosts
  command:        a2ensite ${item}.${domain}
  with_items:     ${apache_vhosts}
  sudo:           true
  notify:
    - restart apache

Any thoughts?

Activity

  1. connorblack commented on Dec 7, 2013

    @connorblack
    Author

    Additional info:

    • I've tried editing "Create MySQL" with my root credentials in main.yml, but it didn't work, and I'm pretty sure it was a ditch effort since the provision script should be creating a new user attributed to deploy, no?
    • It's running fine locally, no errors in provisioning vagrant
    • I've created a user "deploy" on my server, and have given it root access
      • cap staging genesis:ssh and cap production genesis:ssh work fine
    • I've added all the DNS records for my domain
    • I get this error during the provision script: ** [out :: ******.******.*****.**] unable to resolve host ***My host****, but it continues
    • I get this error, which might be the most useful, but it also continues even though it seems a little more severe:
     ** [out :: ******.******.*****.**] TASK: [common | Check for vagrant user] ***************************************
     ** [out :: ******.******.*****.**] failed: [127.0.0.1] => {"changed": true, "cmd": ["id", "-u", "vagrant"], "delta": "0:00:00.052632", "end": "2013-12-07 17:17:51.785590", "item": "", "rc": 1, "start": "2013-12-07 17:17:51.732958"}
     ** [out :: ******.******.*****.**] stderr: id: vagrant: No such user
    

    And also this:

    /bower_components/genesis-wordpress/provisioning/roles/common/tasks/main.yml was failing on tasksel install lamp-server:

    - name:           Install LAMP stack
      shell:          DEBIAN_FRONTEND=noninteractive tasksel install lamp-server
      sudo:           yes
    

    So I fixed it by switching it out with apt-get install lamp-server^.

    I'm at my wits/googling ability's end, so I'm going to reinstall everything and try again- I'll get his thread updated with anything I find.

  2. EvanK commented on Dec 9, 2013

    @EvanK
    Contributor

    Do you have the exact error message(s) from the failure of tasksel install lamp-server?

  3. connorblack commented on Dec 9, 2013

    @connorblack
    Author

    I do:

    Can't call method "set" on an undefined value at /usr/share/perl5/Debconf/FrontEnd.pm line 126, <GEN0> line 5.
    Use of uninitialized value $ret in scalar chomp at /usr/share/perl5/Debconf/Client/ConfModule.pm line 132, <STDIN> line 4.
    Use of uninitialized value $ret in split at /usr/share/perl5/Debconf/Client/ConfModule.pm line 133, <STDIN> line 4.
    Use of uninitialized value $ret[0] in string eq at /usr/share/perl5/Debconf/Client/ConfModule.pm line 134, <STDIN> line 4.
    Use of uninitialized value $ret[0] in string eq at /usr/bin/debconf-apt-progress line 350, <STDIN> line 4.
    tasksel: aptitude failed (255)
    

    Could this change be causing some issues?

  4. EvanK commented on Dec 9, 2013

    @EvanK
    Contributor

    When you run apt-get install lamp-server^ (which should be functionally equivalent to tasksel install lamp-server), are you still prefixing it with DEBIAN_FRONTEND=noninteractive?

    We did the noninteractive to avoid prompting for a root password on install, which gives us a local root mysql user with a blank password. This is what the mysql_db task should be using by default, according to the ansible docs.

    Can you test whether you are able to log in to mysql as root?

    mysql -u root
  5. connorblack commented on Dec 9, 2013

    @connorblack
    Author

    Yes, I left in DEBIAN_FRONTEND=noninteractive, just changed out the actual command.

    And yes I can sign in to mysql but I use:

    mysql -u root -p
    

    and enter my password I set for root.

  6. EvanK commented on Dec 9, 2013

    @EvanK
    Contributor

    If your mysql install has a "root"@"localhost" user with a non-empty password, that would explain why it's failing to create the database. When did you set that password, if not during the lamp-server install?

    That still wouldn't explain why tasksel failed in the first place, though. Can you run tasksel -t install lamp-server and respond with its output? (The -t is a test flag, it shouldn't actually change anything)

  7. connorblack commented on Dec 9, 2013

    @connorblack
    Author

    I set it when I first set up my server a while back. Is there a place I can edit in genesis where I can set my root password? Also, isn't it bad security practice to have an empty root password?

    Here's my output for that command:

    debconf-apt-progress -- apt-get -q -y install lamp-server^
    
  8. EvanK commented on Dec 9, 2013

    @EvanK
    Contributor

    For a server used by multiple people, or used for multiple purposes, a blank root password for mysql would be a bad practice.

    We're using genesis on single-use servers, with the only way to access them being as root or deploy (which requires an ssh private key); hence the provisioning process installing everything from scratch. Once someone has gained shell access to the box, we're pretty much assuming they're supposed to be there. (Also, see #71 for our pending firewall hardening).

    You can manually specify a mysql password in two ways; by defining credentials in /home/deploy/my.cnf, or by adding a login_password to the file provisioning/roles/wordpress/tasks/main.yml:

    - name:           Create MySQL database
      mysql_db:       name=${mysql.name} login_password=opensesame
  9. connorblack commented on Dec 9, 2013

    @connorblack
    Author

    Awesome, thanks! I'll try it out by specifying a password.

  10. EvanK commented on Dec 9, 2013

    @EvanK
    Contributor

    Upon double-checking my work, I got the filename wrong: it should be /home/deploy/.my.cnf

  11. ericclemmons commented on Dec 16, 2013

    @ericclemmons
    Contributor

    @connorblack Any word back on this one? This sounds like an issue that exists because of an existing machine that's already been provisioned, which isn't quite something we're anticipating here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions