Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Edit a file in 16VPSs
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Edit a file in 16VPSs

Hi,
I have 16VPSs in the same dedicated server and I have 1 file in the documents folder in all 16VPSs
The file is exacly the same in every VPS, I edit it very often and to edit it I waste a great amount of time conecting in each one of them and etc etc
I was wondering if there's a faster and easier way to do it.
If you have a suggestion please ay it :)
Thanks!

Comments

  • 0xdragon0xdragon Member
    edited November 2015

    Ancible recipe.

    Or

    SaltStack deploy.

    Or

    Many SSH clients allow you to execute a snippet of code on many servers.

    Thanked by 1Virpus
  • @0xdragon said:
    Antilles recipe.

    Or

    SaltStack deploy.

    Or

    Many SSH clients allow you to execute a snippet of code on many servers.

    Is there any tut for it? I googled and found nothing :S

  • jarjar Patron Provider, Top Host, Veteran
    edited November 2015

    Could even do an sed one liner in a for loop.

    for i in $(cat serverlist); do ssh root@$i sed -i 's/old/new/g' filename; done

  • Maybe make all vps download the file on daily basis from 1 server. You probably could script this in python.

    Thanked by 2Rolter mahjong
  • from the above response lets assume you can't be arsed to work out how something like salt works?

    Why not point all of your servers at a single copy of the file on a network share, or cron the VMs to check for a new file via http every minute or two?

  • @Mark_R said:
    Maybe make all vps download the file on daily basis from 1 server. You probably could script this in python.

    This , its simple and will work just fine , I would use wget though.

  • or rsync

    Thanked by 1ATHK
  • Ansible - then all you need is SSH and a playbook and you're away.

    Thanked by 1TheLinuxBug
  • raindog308raindog308 Administrator, Veteran

    Um, or just a local nfs mount...edit in one place, every vps sees the same file mmediately, no scripting needed.

  • emreemre Member, LIR

    terminator > broadcast all

    https://launchpad.net/terminator

    will do.

    it will basically broadcast everything you write to all 16 connected ssh terminals.

  • Simple:

    Step 1:

    • Add the rsa.pub key of your main server or the the server will help to edit to the 16 servers. (you must add it to the authorized_keys files located on .ssh/authorized_keys).

    Step 2:

    • Create a file with any name and add you servers ip.

    1.1.1.1
    2.2.2.2
    3.3.3.3
    4.4.4.4

    Step 3:

    • In your edit server get a copy of the file and just make your changes.

    Step 4:

    • Create a mini script like sync_server.sh:

    https://gist.github.com/martip07/9b3e67c2c8a3d64375c1

    After that do a simple "chmod +x sync_server.sh" and run it with "sh sync_server.sh".

    And thats all I recomend you to test it with simple files before do it on production.

    Thanked by 1teknolaiz
  • Rsync the files from a central server.

  • I have never been more happier to use pssh.

  • @jarland said:
    Could even do an sed one liner in a for loop.

    for i in $(cat serverlist); do ssh root@$i sed -i 's/old/new/g' filename; done

    I second this approach. If you want to push the files frequently by having SSH key so you won't have to write passwords.

  • @Sady said:

    Yap it works only for one line.

  • oneilonlineoneilonline Member, Host Rep

    Do you not have access to the node level? I would push it via ssh with key access, as recommended above.

  • I forgot to mencione that I'm kind of nooby in this area.... And I'm trying to figure out what you are trying to say

  • Give me some hours and I will post something that will really help you.

  • @martip07 said:
    Give me some hours and I will post something that will really help you.

    Can you send me a link via PM when you do please?
    Thanks a lot!

  • aglodekaglodek Member
    edited November 2015

    @francis2 said: I forgot to mencione that I'm kind of nooby in this area.... And I'm trying to figure out what you are trying to say

    Basically, you have 2 choices: push or pull. Either way will work just fine. Personally, playing with multiple servers, I would go with the push option, using Ansible for example. Granted that it's a bit of overkill for this particular job at hand, but worth the learning curve if you have 16 servers. SaltStack or Chef will work, too, but you will find more support/tutorials online for Ansible.

  • martip07martip07 Member
    edited November 2015

    Ya ansible works but read all he said he is new in someway here. So ansible may not be a good idea right now.

  • @francis2 said:

    Driving home, in 2 houra or less you will get your tutorial hope it helpa you.

  • @francis2

    cehck PM

Sign In or Register to comment.