how do you automate server creation?

there is a lot of things I need to do manully before I can add server to the stack..

lets say I have php app and I want to spawn another server I need to:

set hostname

configure etc/hosts

configure private ip

configure iptable to allow private networking

and all this annoying things that I dont always remember how so I search for articles, and all the articles are for digital ocean so I need to change some things and so on..

there must be some solution that i am missing?

5 Replies

There exists an entire ecosystem of configuration management projects with various goals / scopes / dreams:

  • Salt – http://saltstack.com/

  • Puppet -- https://puppetlabs.com/

  • Chef -- https://www.chef.io/

  • Ansible -- http://www.ansible.com/home

The basic idea is that you stop doing these things manually and start defining in your config management what you want done. It then does the actual day-to-day legwork of applying your configuration onto your systems.

  • Les

akeri's answer is absolutely the way to go; however, there is a learning curve at the beginning and you have to dedicate sometime to learn about the different server provisioning tools out there, and then decide on which one fits your needs and again learn the basic usage scenarios to that specific tool you chose.

I myself tend to be a little lazy when it comes to provisioning servers, and I have relied always on simple bash scripts which I have written myself.

First I have a script called provisionroot.sh. I use this script immediately after I Rebuild my server with Ubuntu 14.04 LTS. I call it provisionroot.sh because this is the one I use when I log into the VPS as root, and it does root operations; such as, creating users, changing hostname, etc…

I then scp this script provision_root.sh to the vps

$ scp provision_root.sh root@your-ip-address

I log into the server as root and I simply run it

$ ./provision_root.sh

This script contains all the commands that you would have written manually on the command line. All of them stacked vertically, for example:

apt-get install vim

echo "your host name" > /etc/hosts

createuser myusername

….

.

reboot now

Then I have another script called provisionmyuser_name.sh

Once the server is up again after the final reboot I again scp this script into the vps

$ scp provisionmyuser_name.sh

and I log into it…you can get the picture

Now let's say you're production environment is a rails + postgres + unicorn + nginx.

This bash script will contain all commands that will install all components needed for production

\curl rvm | source ~/.rvm

rvm install ruby

gem install rails

gem install bundler

apt-get install nginx

apt-get install postgres

..

.

reboot now

And that's it! your server is ready. I hope this helps.

@boynet:

there is a lot of things I need to do manully before I can add server to the stack..

lets say I have php app and I want to spawn another server I need to:

set hostname

configure etc/hosts

configure private ip

configure iptable to allow private networking

and all this annoying things that I dont always remember how so I search for articles, and all the articles are for digital ocean so I need to change some things and so on..

there must be some solution that i am missing?

If you cant remember how then I suggest you only to continue doing it manually until you will be able to remember what to do. Other wise you're going to remember only how to launch scripts. And manual configuration is important thing to learn. Otherwise without understanding what are you doing you're just going to make yourself easy to pwn. Especially when Ubuntu is most automated and easiest to handle server of all.

Automation becomes vital only when you need to configure hundreds of servers. So no clue how ti configure few of them. Going to leave you dependent not only on whole ubuntu automation, but as well as on someones scripts. and forums full of asking of dumb questions.

I think you can also build a custom script to automate the server creation and VPS creation by installing that script on your main node or main server.

You can create a StackScript that configures a Linode the way you want on deployment. https://www.linode.com/stackscripts

In your scenario, I would create a StackScript that deploys your distro with one of the configuration management tools akerl mentioned. Then have that tool (say Salt) configure the rest.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct