1

We host a lot of sites on 3rd party hosts. For each one of these sites, we also have corresponding staging sites - usually on another server by the same host provider. I started using Digital Ocean for staging sites simply because they're quicker to setup and most importantly we get root access. Sometimes, when we push from staging to live it breaks certain aspects because the server environments are not the same - for example running different versions of Php. Is there a command that I could run on the hosted servers to get a full list of the system variables, packages and configuration? Then I would be able to "build" an exact replica on Digital Ocean.

Haim
  • 111
  • 3
  • I would consider consolidating on a single hosting provider, or at least a single operating system, in order to simplify provisioning and management of your servers. – Pak May 27 '17 at 10:52

2 Answers2

2

You can use some provisioning tool like Ansible, CFEngine3, puppet etc. for creating "scripts" how servers should look like and then use it for setup of production and stage. Same script will results in same server (if you will write it correctly) plus you have disaster recovery plan to fix your servers when something bad happen.

Ondra Sniper Flidr
  • 2,653
  • 12
  • 18
  • Thanks - but how do i figure out what the setup is for the current environment that I'm in – Haim May 24 '17 at 14:54
  • 1
    You go through the server *very* methodically to see how things are configured, and then iterate on ansible plays, running against a test server until things match. – EEAA May 25 '17 at 00:46
  • is there a bash command that will output all the packages on the server so that I can duplicate? – Haim May 26 '17 at 03:16
  • @Haim Yes, both Yum and Apt can generate a list of installed packages, but there's a lot more to it than that. You'll need the configurations too. – ceejayoz May 26 '17 at 17:46
1

There is not a one size fits all command in bash to get that package information as centOS and Ubuntu use 2 very different package managers, and then BSD is a completely different beast. Now you can go look at the distributions forms and such and find commands that will tell you all that is installed, but when a lot of those are ancillary packages that are / will be installed with other software packages. If you know you can fiddly with a server and eventually get it to "work" will help. So here is what I would do

First you will want to choose and learn a configuration management tool. I use Ansible, as I am a sysadmin and love Linux even on my desktop. Ansible is python based and ssh dependent making it fit into my development and devops workflow. Solo developer at my company and I run my own infrastructure. Some other tools would be Chef, Puppet, Salt, and Fabric, but this is not an extensive list just the ones I can think of off the top of my head.

Next invest time in building a replicate-able(sp?) system. most configuration management tools can tie into a lot of services and other modules which when dealing with multiple hosts and providers can be a good thing. Building this system will standardize your whole stack no matter where it is hosted, and this will take away the difference between staging and production. i.e not more "what version of PHP is installed", or "is this box locked down".

Something else a lot of these config managmet tools can do is integrate into your company chat tools. which means you can deploy from a chat room and not have to touch any command lines. this idea is called "ChatOps" and may interest you down the road.

Profit???

TLDR; no one answer

  1. choose a tool
  2. Learn and deploy tool
  3. Extend
  4. profit???