I passed some scripts to EC2 userdata to install at starup. One of those is sudo tasksel install lamp-server

When this process runs, it prompts for mysql password,twice, to bypass this, I use

sudo debconf-set-selections <<< "mysql-server mysql-server/root_password password pass"
sudo debconf-set-selections <<< "mysql-server mysql-server/root_password_again password pass"
sudo tasksel install lamp-server

The script runs fine when I ssh into the instance and manually run it. However when I put this into user-data of an EC2, this error happened can't open /dev/tty: No such device or address

So is there any work-around?

  • 2
    Why not make an AMI with all your packages installed, rather than duplicating the effort every time one starts up? – ceejayoz Oct 23 '15 at 22:57
  • No I don't want to use custom AMI – Casper Nov 6 '15 at 18:28
  • Why not? Easier, takes 2 min, you can do it in the AWS Console. Having MySQL install as part of the userdata is a little bit crazy. – ceejayoz Nov 6 '15 at 19:24
  • It's just a requirement, so something simple as this can't be done using bash? – Casper Nov 6 '15 at 19:41
  • Installing an entire LAMP setup isn't really "simple", and that's a fairly bizarre client requirement. – ceejayoz Nov 6 '15 at 20:15

Try those two AWS options: OpsWorks (Chef), CloudFormation; or build your own AMI.

| improve this answer | |
  • May be Chef is my choice since I don't want a custom AMI...but I don't know Chef – Casper Nov 6 '15 at 18:29
  • @Casper Then this is what you should read through (and try yourself): docs.aws.amazon.com/opsworks/latest/userguide/… Been using it in production ever since AWS introduced it. – jpaljasma Nov 6 '15 at 19:20
  • It looks complex to me and currently I'm too lazy to read all that, all I need is to just install LAMP stack, can I just simply install chef and use a cookbook (probably be me) to install it? – Casper Nov 6 '15 at 19:29
  • 1
    I'm too lazy to read all that - sounds like you need to hire a good AWS specialist. – jpaljasma Nov 6 '15 at 19:30
  • Well I don't need all that just to install a lamp stack on an EC2 at start-up... – Casper Nov 6 '15 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.