1

I'm trying to automate a deployment of an application by Python-fabric. The installation has to be done without any human intervention.

In CentOS 6.4 server the if i install mysql through

$yum install mysql-server

Then mysql is installed with a NULL password.

Now the problem is when i reset the mysql root password from fabric by issuing :

run("mysqladmin -u %s -p password %s " % ('root','khd5u8bWN'))

It prompts for a password (which is NULL) and i have to press the return key to proceed.

Now as i want to achieve "full" automation, i want this "pressing enter" automatically. How can i achieve this in python-fabric?

Aftnix
  • 4,461
  • 6
  • 26
  • 43

2 Answers2

1

When a mysql password is empty you can login to that account by omitting the -p option. So change your run command to:

run("mysqladmin -u %s password %s " % ('root','khd5u8bWN'))

nmgeek
  • 2,127
  • 1
  • 23
  • 31
0

You could either set the environment variable password in the env dict ("" should work if the password is no password) or invoke fab with the -I <pwd> option.

I generally use the latter option, since it's code agnostic.

Edit in response to OP's comment:

Try switching from using run to sudo to run the command (while still using one of the methods above).

Edit 2 in response to OP's follow-up comment:

I'm pretty sure sudo is the key here, based on the info provided, but perhaps with certain arguments set. See http://docs.fabfile.org/en/latest/api/core/operations.html#fabric.operations.sudo

Edit 3 in response to add'l OP follow-up comment:

Re: it being the mysql root password and not an OS password, this may provide some food for thought: install mysql on ubuntu without password prompt

Community
  • 1
  • 1
khampson
  • 14,700
  • 4
  • 41
  • 43