In 'GRUB_CMDLINE_LINUX_DEFAULT', do values that come later override the earlier ones?












0















I'm using Ubuntu 14.04.5 and the latest version of docker-ce in my project. I want to enable the cgroup swap limit capabilities so I'm looking at the section Your kernel does not support cgroup swap limit capabilities.



Instead of doing that manually, I want to modify the /etc/default/grub file in an Ansible playbook because I already have many playbooks to set up the IT infrastructures.



The simplest solution is to find the GRUB_CMDLINE_LINUX_DEFAULT line and append cgroup_enable=memory swapaccount=1 without checking if they already exist. The playbook task would look like this:



- name: Enable the memory limit.
lineinfile:
path: /etc/default/grub
backrefs: yes
regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")(.*)(".*)$'
line: '12 cgroup_enable=memory swapaccount=13'
when: <String `cgroup_enable=memory swapaccount=1` is not present>


(Note the last when line is not valid Ansible syntax. I put it there to show the idea.)



I set a when condition so if these two flags with the desired values are already there, they won't be appended again. However, they are still appended in the cases like the following:




  • Only one is present, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory"

  • Both are present but with different values, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999" (just some stupid values)

  • Both are present but separated by something else, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory somekey=somevalue swapaccount=1"

  • etc..


In summary, the playbook task is not perfect, and I will improve it soon.



My questions are:




  1. If I end up with a line like GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999 cgroup_enable=memory swapaccount=1", would the values that come later ("memory" and "1" in this case) override the earlier values ("something" and "999") of the same keys?? I tested and it seems to be working this way.

  2. If it does or does not override the earlier values, where is the official documentation that specifies this behavior? I've tried to find it in the links below but wasn't lucky:


    • GNU GRUB Manual 2.02

    • Configuring GRUB 2












share|improve this question





























    0















    I'm using Ubuntu 14.04.5 and the latest version of docker-ce in my project. I want to enable the cgroup swap limit capabilities so I'm looking at the section Your kernel does not support cgroup swap limit capabilities.



    Instead of doing that manually, I want to modify the /etc/default/grub file in an Ansible playbook because I already have many playbooks to set up the IT infrastructures.



    The simplest solution is to find the GRUB_CMDLINE_LINUX_DEFAULT line and append cgroup_enable=memory swapaccount=1 without checking if they already exist. The playbook task would look like this:



    - name: Enable the memory limit.
    lineinfile:
    path: /etc/default/grub
    backrefs: yes
    regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")(.*)(".*)$'
    line: '12 cgroup_enable=memory swapaccount=13'
    when: <String `cgroup_enable=memory swapaccount=1` is not present>


    (Note the last when line is not valid Ansible syntax. I put it there to show the idea.)



    I set a when condition so if these two flags with the desired values are already there, they won't be appended again. However, they are still appended in the cases like the following:




    • Only one is present, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory"

    • Both are present but with different values, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999" (just some stupid values)

    • Both are present but separated by something else, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory somekey=somevalue swapaccount=1"

    • etc..


    In summary, the playbook task is not perfect, and I will improve it soon.



    My questions are:




    1. If I end up with a line like GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999 cgroup_enable=memory swapaccount=1", would the values that come later ("memory" and "1" in this case) override the earlier values ("something" and "999") of the same keys?? I tested and it seems to be working this way.

    2. If it does or does not override the earlier values, where is the official documentation that specifies this behavior? I've tried to find it in the links below but wasn't lucky:


      • GNU GRUB Manual 2.02

      • Configuring GRUB 2












    share|improve this question



























      0












      0








      0








      I'm using Ubuntu 14.04.5 and the latest version of docker-ce in my project. I want to enable the cgroup swap limit capabilities so I'm looking at the section Your kernel does not support cgroup swap limit capabilities.



      Instead of doing that manually, I want to modify the /etc/default/grub file in an Ansible playbook because I already have many playbooks to set up the IT infrastructures.



      The simplest solution is to find the GRUB_CMDLINE_LINUX_DEFAULT line and append cgroup_enable=memory swapaccount=1 without checking if they already exist. The playbook task would look like this:



      - name: Enable the memory limit.
      lineinfile:
      path: /etc/default/grub
      backrefs: yes
      regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")(.*)(".*)$'
      line: '12 cgroup_enable=memory swapaccount=13'
      when: <String `cgroup_enable=memory swapaccount=1` is not present>


      (Note the last when line is not valid Ansible syntax. I put it there to show the idea.)



      I set a when condition so if these two flags with the desired values are already there, they won't be appended again. However, they are still appended in the cases like the following:




      • Only one is present, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory"

      • Both are present but with different values, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999" (just some stupid values)

      • Both are present but separated by something else, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory somekey=somevalue swapaccount=1"

      • etc..


      In summary, the playbook task is not perfect, and I will improve it soon.



      My questions are:




      1. If I end up with a line like GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999 cgroup_enable=memory swapaccount=1", would the values that come later ("memory" and "1" in this case) override the earlier values ("something" and "999") of the same keys?? I tested and it seems to be working this way.

      2. If it does or does not override the earlier values, where is the official documentation that specifies this behavior? I've tried to find it in the links below but wasn't lucky:


        • GNU GRUB Manual 2.02

        • Configuring GRUB 2












      share|improve this question
















      I'm using Ubuntu 14.04.5 and the latest version of docker-ce in my project. I want to enable the cgroup swap limit capabilities so I'm looking at the section Your kernel does not support cgroup swap limit capabilities.



      Instead of doing that manually, I want to modify the /etc/default/grub file in an Ansible playbook because I already have many playbooks to set up the IT infrastructures.



      The simplest solution is to find the GRUB_CMDLINE_LINUX_DEFAULT line and append cgroup_enable=memory swapaccount=1 without checking if they already exist. The playbook task would look like this:



      - name: Enable the memory limit.
      lineinfile:
      path: /etc/default/grub
      backrefs: yes
      regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=")(.*)(".*)$'
      line: '12 cgroup_enable=memory swapaccount=13'
      when: <String `cgroup_enable=memory swapaccount=1` is not present>


      (Note the last when line is not valid Ansible syntax. I put it there to show the idea.)



      I set a when condition so if these two flags with the desired values are already there, they won't be appended again. However, they are still appended in the cases like the following:




      • Only one is present, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory"

      • Both are present but with different values, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999" (just some stupid values)

      • Both are present but separated by something else, e.g.: GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=memory somekey=somevalue swapaccount=1"

      • etc..


      In summary, the playbook task is not perfect, and I will improve it soon.



      My questions are:




      1. If I end up with a line like GRUB_CMDLINE_LINUX_DEFAULT="cgroup_enable=something swapaccount=999 cgroup_enable=memory swapaccount=1", would the values that come later ("memory" and "1" in this case) override the earlier values ("something" and "999") of the same keys?? I tested and it seems to be working this way.

      2. If it does or does not override the earlier values, where is the official documentation that specifies this behavior? I've tried to find it in the links below but wasn't lucky:


        • GNU GRUB Manual 2.02

        • Configuring GRUB 2









      grub2 kernel






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 11 at 20:35







      yaobin

















      asked Jan 11 at 20:29









      yaobinyaobin

      1837




      1837






















          0






          active

          oldest

          votes











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2faskubuntu.com%2fquestions%2f1108967%2fin-grub-cmdline-linux-default-do-values-that-come-later-override-the-earlier%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1108967%2fin-grub-cmdline-linux-default-do-values-that-come-later-override-the-earlier%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 change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents