Recommendations for editing same file on different machines












0















Our Rails app is scaled at multiple machines, from time to time, we need to change settings at production.yml , right now we have to ssh into each server and do the editing at each machine individually.



What's the right way to handle this case?










share|improve this question



























    0















    Our Rails app is scaled at multiple machines, from time to time, we need to change settings at production.yml , right now we have to ssh into each server and do the editing at each machine individually.



    What's the right way to handle this case?










    share|improve this question

























      0












      0








      0








      Our Rails app is scaled at multiple machines, from time to time, we need to change settings at production.yml , right now we have to ssh into each server and do the editing at each machine individually.



      What's the right way to handle this case?










      share|improve this question














      Our Rails app is scaled at multiple machines, from time to time, we need to change settings at production.yml , right now we have to ssh into each server and do the editing at each machine individually.



      What's the right way to handle this case?







      synchronization settings deployment yaml






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 29 at 14:05









      simosimo

      1033




      1033






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Configuration management systems like Puppet and Chef are made for this exact purpose.



          If you don't want to use them, you can use a script to SCP the file to the server:



          while read host; do
          scp -i yourKey production.yml user@$host:/destination/production.yml
          # Add an ssh command here if you need to restart any services
          done < hosts.txt;





          share|improve this answer


























          • currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

            – simo
            Jan 29 at 14:12











          • Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

            – Farhan.K
            Jan 29 at 14:21











          • thanks allot, that's what I needed

            – simo
            Jan 29 at 14:26






          • 1





            I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

            – Farhan.K
            Jan 29 at 14:27











          • If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

            – John Doe
            Jan 29 at 16:20





















          0














          Better to use rsync instead of scp. Advantages of rsync :



          First, it will check whether any changes are there or not in source file when compared with file in destination. Only if there is a change then it will transfer so it will take less time and be faster when compared with scp.



          while read host
          do
          rsync -avzh production.yml userid@$host:/destination_location/production.yml
          done < hosts.txt





          share|improve this answer


























          • using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

            – pizdelect
            Feb 1 at 9:21











          • @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

            – terdon
            Feb 1 at 9:42













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497459%2frecommendations-for-editing-same-file-on-different-machines%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Configuration management systems like Puppet and Chef are made for this exact purpose.



          If you don't want to use them, you can use a script to SCP the file to the server:



          while read host; do
          scp -i yourKey production.yml user@$host:/destination/production.yml
          # Add an ssh command here if you need to restart any services
          done < hosts.txt;





          share|improve this answer


























          • currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

            – simo
            Jan 29 at 14:12











          • Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

            – Farhan.K
            Jan 29 at 14:21











          • thanks allot, that's what I needed

            – simo
            Jan 29 at 14:26






          • 1





            I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

            – Farhan.K
            Jan 29 at 14:27











          • If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

            – John Doe
            Jan 29 at 16:20


















          0














          Configuration management systems like Puppet and Chef are made for this exact purpose.



          If you don't want to use them, you can use a script to SCP the file to the server:



          while read host; do
          scp -i yourKey production.yml user@$host:/destination/production.yml
          # Add an ssh command here if you need to restart any services
          done < hosts.txt;





          share|improve this answer


























          • currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

            – simo
            Jan 29 at 14:12











          • Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

            – Farhan.K
            Jan 29 at 14:21











          • thanks allot, that's what I needed

            – simo
            Jan 29 at 14:26






          • 1





            I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

            – Farhan.K
            Jan 29 at 14:27











          • If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

            – John Doe
            Jan 29 at 16:20
















          0












          0








          0







          Configuration management systems like Puppet and Chef are made for this exact purpose.



          If you don't want to use them, you can use a script to SCP the file to the server:



          while read host; do
          scp -i yourKey production.yml user@$host:/destination/production.yml
          # Add an ssh command here if you need to restart any services
          done < hosts.txt;





          share|improve this answer















          Configuration management systems like Puppet and Chef are made for this exact purpose.



          If you don't want to use them, you can use a script to SCP the file to the server:



          while read host; do
          scp -i yourKey production.yml user@$host:/destination/production.yml
          # Add an ssh command here if you need to restart any services
          done < hosts.txt;






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 29 at 16:27









          terdon

          130k32255433




          130k32255433










          answered Jan 29 at 14:07









          Farhan.KFarhan.K

          1243




          1243













          • currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

            – simo
            Jan 29 at 14:12











          • Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

            – Farhan.K
            Jan 29 at 14:21











          • thanks allot, that's what I needed

            – simo
            Jan 29 at 14:26






          • 1





            I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

            – Farhan.K
            Jan 29 at 14:27











          • If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

            – John Doe
            Jan 29 at 16:20





















          • currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

            – simo
            Jan 29 at 14:12











          • Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

            – Farhan.K
            Jan 29 at 14:21











          • thanks allot, that's what I needed

            – simo
            Jan 29 at 14:26






          • 1





            I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

            – Farhan.K
            Jan 29 at 14:27











          • If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

            – John Doe
            Jan 29 at 16:20



















          currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

          – simo
          Jan 29 at 14:12





          currently we are not using those tools, wouldn't this approach involve full deployment cycle ? we only need this particular sync

          – simo
          Jan 29 at 14:12













          Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

          – Farhan.K
          Jan 29 at 14:21





          Not necessarily, there's nothing wrong with using them to deploy files outside of the development cycle. Although they might be overkill for something small like this. I've edited my answer

          – Farhan.K
          Jan 29 at 14:21













          thanks allot, that's what I needed

          – simo
          Jan 29 at 14:26





          thanks allot, that's what I needed

          – simo
          Jan 29 at 14:26




          1




          1





          I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

          – Farhan.K
          Jan 29 at 14:27





          I would consider using one of these tools if I were you. It makes it much easier to manage multiple machines.

          – Farhan.K
          Jan 29 at 14:27













          If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

          – John Doe
          Jan 29 at 16:20







          If there are any chances that those files will be changed by someone else after you modify them , thus causing a configuration drift , I would suggest going with @Farhan.K's suggestion as Puppet and Chef will check periodically if there has been any change to the file and if so , change it to what you define . If not , Puppet and Chef could have an overhead since they are agent based , and in this case I would strongly recommend using Ansible which is agentless and uses SSH to connect to managed hosts. You could manage one file and push it to managed hosts. good luck

          – John Doe
          Jan 29 at 16:20















          0














          Better to use rsync instead of scp. Advantages of rsync :



          First, it will check whether any changes are there or not in source file when compared with file in destination. Only if there is a change then it will transfer so it will take less time and be faster when compared with scp.



          while read host
          do
          rsync -avzh production.yml userid@$host:/destination_location/production.yml
          done < hosts.txt





          share|improve this answer


























          • using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

            – pizdelect
            Feb 1 at 9:21











          • @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

            – terdon
            Feb 1 at 9:42


















          0














          Better to use rsync instead of scp. Advantages of rsync :



          First, it will check whether any changes are there or not in source file when compared with file in destination. Only if there is a change then it will transfer so it will take less time and be faster when compared with scp.



          while read host
          do
          rsync -avzh production.yml userid@$host:/destination_location/production.yml
          done < hosts.txt





          share|improve this answer


























          • using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

            – pizdelect
            Feb 1 at 9:21











          • @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

            – terdon
            Feb 1 at 9:42
















          0












          0








          0







          Better to use rsync instead of scp. Advantages of rsync :



          First, it will check whether any changes are there or not in source file when compared with file in destination. Only if there is a change then it will transfer so it will take less time and be faster when compared with scp.



          while read host
          do
          rsync -avzh production.yml userid@$host:/destination_location/production.yml
          done < hosts.txt





          share|improve this answer















          Better to use rsync instead of scp. Advantages of rsync :



          First, it will check whether any changes are there or not in source file when compared with file in destination. Only if there is a change then it will transfer so it will take less time and be faster when compared with scp.



          while read host
          do
          rsync -avzh production.yml userid@$host:/destination_location/production.yml
          done < hosts.txt






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 29 at 16:26









          terdon

          130k32255433




          130k32255433










          answered Jan 29 at 15:41









          Praveen Kumar BSPraveen Kumar BS

          1,464138




          1,464138













          • using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

            – pizdelect
            Feb 1 at 9:21











          • @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

            – terdon
            Feb 1 at 9:42





















          • using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

            – pizdelect
            Feb 1 at 9:21











          • @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

            – terdon
            Feb 1 at 9:42



















          using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

          – pizdelect
          Feb 1 at 9:21





          using while read; do ... done < hosts.txt is horrible -- same comment as here. Also @terdon.

          – pizdelect
          Feb 1 at 9:21













          @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

          – terdon
          Feb 1 at 9:42







          @pizdelect no, it isn't. It is the best and safest way to read lines from a file. The absolute safest is while IFS= read -r var; do..., but this is not needed here. IN any case, using a while read loop instead of something truly awful such as for line in $(cat file) is both standard and the best practice recommended pretty much everywhere. Also see 1, 2, 3, 4, 5.

          – terdon
          Feb 1 at 9:42




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f497459%2frecommendations-for-editing-same-file-on-different-machines%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀