Is there a way to try out a netplan configuration without altering the system?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












I work on remote servers, and its a painfull process to go into Rescue Mode everytime I screw something up when it comes to network configuraitons.



Are there a way to implement something like:



Netplan apply /customscript.yaml


That I can use when I troubleshoot network configurations.
So the server gets its "defaults" if I do a cold reboot.










share|improve this question























  • Are you trying to restore the default .yaml file and then netplan apply? Can you save the default as default.yaml.bak and then: sudo mv default.yaml.bak 01-netcfg.yaml && netplan apply ?
    – chili555
    Mar 10 at 15:45










  • this is an valid option as long as you have local access to the server, not over network. I only have 1 network card, and can only access the server using ssh. So if i mess something up in the netplan, and load it. then i have to boot the server up in recovery mode and do this you just described. What I want is to be able to apply settings in netplan, that are reversed back to a default setup when i reboot the server, incase i mess up.
    – BD Bear
    Mar 11 at 16:48






  • 1




    What I can try to create a bash script that load on boot, where i use cat to write the defaults to 01-netctf.yaml.
    – BD Bear
    Mar 11 at 16:50






  • 1




    I'd look into /etc/rc.local.
    – chili555
    Mar 11 at 17:22






  • 3




    One thing I'm working on is "netplan try", so that configuration could be "attempted" live and if you don't answer a prompt, it is automatically reverted to the previous configuration. Would that help in your case?
    – Mathieu Trudel-Lapierre
    Mar 13 at 15:43














up vote
2
down vote

favorite












I work on remote servers, and its a painfull process to go into Rescue Mode everytime I screw something up when it comes to network configuraitons.



Are there a way to implement something like:



Netplan apply /customscript.yaml


That I can use when I troubleshoot network configurations.
So the server gets its "defaults" if I do a cold reboot.










share|improve this question























  • Are you trying to restore the default .yaml file and then netplan apply? Can you save the default as default.yaml.bak and then: sudo mv default.yaml.bak 01-netcfg.yaml && netplan apply ?
    – chili555
    Mar 10 at 15:45










  • this is an valid option as long as you have local access to the server, not over network. I only have 1 network card, and can only access the server using ssh. So if i mess something up in the netplan, and load it. then i have to boot the server up in recovery mode and do this you just described. What I want is to be able to apply settings in netplan, that are reversed back to a default setup when i reboot the server, incase i mess up.
    – BD Bear
    Mar 11 at 16:48






  • 1




    What I can try to create a bash script that load on boot, where i use cat to write the defaults to 01-netctf.yaml.
    – BD Bear
    Mar 11 at 16:50






  • 1




    I'd look into /etc/rc.local.
    – chili555
    Mar 11 at 17:22






  • 3




    One thing I'm working on is "netplan try", so that configuration could be "attempted" live and if you don't answer a prompt, it is automatically reverted to the previous configuration. Would that help in your case?
    – Mathieu Trudel-Lapierre
    Mar 13 at 15:43












up vote
2
down vote

favorite









up vote
2
down vote

favorite











I work on remote servers, and its a painfull process to go into Rescue Mode everytime I screw something up when it comes to network configuraitons.



Are there a way to implement something like:



Netplan apply /customscript.yaml


That I can use when I troubleshoot network configurations.
So the server gets its "defaults" if I do a cold reboot.










share|improve this question















I work on remote servers, and its a painfull process to go into Rescue Mode everytime I screw something up when it comes to network configuraitons.



Are there a way to implement something like:



Netplan apply /customscript.yaml


That I can use when I troubleshoot network configurations.
So the server gets its "defaults" if I do a cold reboot.







boot networking netplan






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 14 at 2:36









dpb

4,90911545




4,90911545










asked Mar 9 at 17:30









BD Bear

11013




11013











  • Are you trying to restore the default .yaml file and then netplan apply? Can you save the default as default.yaml.bak and then: sudo mv default.yaml.bak 01-netcfg.yaml && netplan apply ?
    – chili555
    Mar 10 at 15:45










  • this is an valid option as long as you have local access to the server, not over network. I only have 1 network card, and can only access the server using ssh. So if i mess something up in the netplan, and load it. then i have to boot the server up in recovery mode and do this you just described. What I want is to be able to apply settings in netplan, that are reversed back to a default setup when i reboot the server, incase i mess up.
    – BD Bear
    Mar 11 at 16:48






  • 1




    What I can try to create a bash script that load on boot, where i use cat to write the defaults to 01-netctf.yaml.
    – BD Bear
    Mar 11 at 16:50






  • 1




    I'd look into /etc/rc.local.
    – chili555
    Mar 11 at 17:22






  • 3




    One thing I'm working on is "netplan try", so that configuration could be "attempted" live and if you don't answer a prompt, it is automatically reverted to the previous configuration. Would that help in your case?
    – Mathieu Trudel-Lapierre
    Mar 13 at 15:43
















  • Are you trying to restore the default .yaml file and then netplan apply? Can you save the default as default.yaml.bak and then: sudo mv default.yaml.bak 01-netcfg.yaml && netplan apply ?
    – chili555
    Mar 10 at 15:45










  • this is an valid option as long as you have local access to the server, not over network. I only have 1 network card, and can only access the server using ssh. So if i mess something up in the netplan, and load it. then i have to boot the server up in recovery mode and do this you just described. What I want is to be able to apply settings in netplan, that are reversed back to a default setup when i reboot the server, incase i mess up.
    – BD Bear
    Mar 11 at 16:48






  • 1




    What I can try to create a bash script that load on boot, where i use cat to write the defaults to 01-netctf.yaml.
    – BD Bear
    Mar 11 at 16:50






  • 1




    I'd look into /etc/rc.local.
    – chili555
    Mar 11 at 17:22






  • 3




    One thing I'm working on is "netplan try", so that configuration could be "attempted" live and if you don't answer a prompt, it is automatically reverted to the previous configuration. Would that help in your case?
    – Mathieu Trudel-Lapierre
    Mar 13 at 15:43















Are you trying to restore the default .yaml file and then netplan apply? Can you save the default as default.yaml.bak and then: sudo mv default.yaml.bak 01-netcfg.yaml && netplan apply ?
– chili555
Mar 10 at 15:45




Are you trying to restore the default .yaml file and then netplan apply? Can you save the default as default.yaml.bak and then: sudo mv default.yaml.bak 01-netcfg.yaml && netplan apply ?
– chili555
Mar 10 at 15:45












this is an valid option as long as you have local access to the server, not over network. I only have 1 network card, and can only access the server using ssh. So if i mess something up in the netplan, and load it. then i have to boot the server up in recovery mode and do this you just described. What I want is to be able to apply settings in netplan, that are reversed back to a default setup when i reboot the server, incase i mess up.
– BD Bear
Mar 11 at 16:48




this is an valid option as long as you have local access to the server, not over network. I only have 1 network card, and can only access the server using ssh. So if i mess something up in the netplan, and load it. then i have to boot the server up in recovery mode and do this you just described. What I want is to be able to apply settings in netplan, that are reversed back to a default setup when i reboot the server, incase i mess up.
– BD Bear
Mar 11 at 16:48




1




1




What I can try to create a bash script that load on boot, where i use cat to write the defaults to 01-netctf.yaml.
– BD Bear
Mar 11 at 16:50




What I can try to create a bash script that load on boot, where i use cat to write the defaults to 01-netctf.yaml.
– BD Bear
Mar 11 at 16:50




1




1




I'd look into /etc/rc.local.
– chili555
Mar 11 at 17:22




I'd look into /etc/rc.local.
– chili555
Mar 11 at 17:22




3




3




One thing I'm working on is "netplan try", so that configuration could be "attempted" live and if you don't answer a prompt, it is automatically reverted to the previous configuration. Would that help in your case?
– Mathieu Trudel-Lapierre
Mar 13 at 15:43




One thing I'm working on is "netplan try", so that configuration could be "attempted" live and if you don't answer a prompt, it is automatically reverted to the previous configuration. Would that help in your case?
– Mathieu Trudel-Lapierre
Mar 13 at 15:43










2 Answers
2






active

oldest

votes

















up vote
1
down vote













There is a new way to do this in Bionic: netplan try.



In your case, netplan try --config-file foo.yaml should do what you want.



The manpage isn't very helpful as it mostly describes the config file format, but --help gives you a pretty good outline of the tool:



ubuntu@netplan:~$ netplan try --help
usage: /usr/sbin/netplan try [-h] [--debug] [--config-file CONFIG_FILE]
[--timeout TIMEOUT]

Try to apply a new netplan config to running system, with automatic rollback

optional arguments:
-h, --help show this help message and exit
--debug Enable debug messages
--config-file CONFIG_FILE
Apply the config file in argument in addition to
current configuration.
--timeout TIMEOUT Maximum number of seconds to wait for the user's
confirmation





share|improve this answer



























    up vote
    0
    down vote



    accepted










    First I created a sh script, placed it in /etc/netplan/ and named it backup.sh



    #!/bin/sh

    # -q quiet
    # -c nb of pings to perform

    ping -q -c5 aa.bb.cc.dd > /dev/null

    if [ $? -eq 0 ]
    then
    : #do absolutly nothing! server can ping its external IP.
    else
    # restore, working config to netplan.
    cp -f /etc/netplan/02-netcfg.yaml /etc/netplan/01-netcfg.yaml
    # apply network config.
    netplan apply
    fi


    This script revert the changes I have made, to a working configuration setup that I have stored in 02-netcfg.yaml If i cant ping the server IP. I have masked my server IP address whit aa.bb.cc.dd So you have to replace that whit the IP you want to ping, in order to execute the "else" in the if.



    Then i set this script to run everytime the server restart, as well as enable a Cron job for it that runs every 3 minutes when i work on network configurations.






    share|improve this answer






















    • A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
      – BD Bear
      Mar 15 at 10:17










    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',
    convertImagesToLinks: true,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    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%2f1013455%2fis-there-a-way-to-try-out-a-netplan-configuration-without-altering-the-system%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    There is a new way to do this in Bionic: netplan try.



    In your case, netplan try --config-file foo.yaml should do what you want.



    The manpage isn't very helpful as it mostly describes the config file format, but --help gives you a pretty good outline of the tool:



    ubuntu@netplan:~$ netplan try --help
    usage: /usr/sbin/netplan try [-h] [--debug] [--config-file CONFIG_FILE]
    [--timeout TIMEOUT]

    Try to apply a new netplan config to running system, with automatic rollback

    optional arguments:
    -h, --help show this help message and exit
    --debug Enable debug messages
    --config-file CONFIG_FILE
    Apply the config file in argument in addition to
    current configuration.
    --timeout TIMEOUT Maximum number of seconds to wait for the user's
    confirmation





    share|improve this answer
























      up vote
      1
      down vote













      There is a new way to do this in Bionic: netplan try.



      In your case, netplan try --config-file foo.yaml should do what you want.



      The manpage isn't very helpful as it mostly describes the config file format, but --help gives you a pretty good outline of the tool:



      ubuntu@netplan:~$ netplan try --help
      usage: /usr/sbin/netplan try [-h] [--debug] [--config-file CONFIG_FILE]
      [--timeout TIMEOUT]

      Try to apply a new netplan config to running system, with automatic rollback

      optional arguments:
      -h, --help show this help message and exit
      --debug Enable debug messages
      --config-file CONFIG_FILE
      Apply the config file in argument in addition to
      current configuration.
      --timeout TIMEOUT Maximum number of seconds to wait for the user's
      confirmation





      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        There is a new way to do this in Bionic: netplan try.



        In your case, netplan try --config-file foo.yaml should do what you want.



        The manpage isn't very helpful as it mostly describes the config file format, but --help gives you a pretty good outline of the tool:



        ubuntu@netplan:~$ netplan try --help
        usage: /usr/sbin/netplan try [-h] [--debug] [--config-file CONFIG_FILE]
        [--timeout TIMEOUT]

        Try to apply a new netplan config to running system, with automatic rollback

        optional arguments:
        -h, --help show this help message and exit
        --debug Enable debug messages
        --config-file CONFIG_FILE
        Apply the config file in argument in addition to
        current configuration.
        --timeout TIMEOUT Maximum number of seconds to wait for the user's
        confirmation





        share|improve this answer












        There is a new way to do this in Bionic: netplan try.



        In your case, netplan try --config-file foo.yaml should do what you want.



        The manpage isn't very helpful as it mostly describes the config file format, but --help gives you a pretty good outline of the tool:



        ubuntu@netplan:~$ netplan try --help
        usage: /usr/sbin/netplan try [-h] [--debug] [--config-file CONFIG_FILE]
        [--timeout TIMEOUT]

        Try to apply a new netplan config to running system, with automatic rollback

        optional arguments:
        -h, --help show this help message and exit
        --debug Enable debug messages
        --config-file CONFIG_FILE
        Apply the config file in argument in addition to
        current configuration.
        --timeout TIMEOUT Maximum number of seconds to wait for the user's
        confirmation






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 3 at 7:30









        dja

        173119




        173119






















            up vote
            0
            down vote



            accepted










            First I created a sh script, placed it in /etc/netplan/ and named it backup.sh



            #!/bin/sh

            # -q quiet
            # -c nb of pings to perform

            ping -q -c5 aa.bb.cc.dd > /dev/null

            if [ $? -eq 0 ]
            then
            : #do absolutly nothing! server can ping its external IP.
            else
            # restore, working config to netplan.
            cp -f /etc/netplan/02-netcfg.yaml /etc/netplan/01-netcfg.yaml
            # apply network config.
            netplan apply
            fi


            This script revert the changes I have made, to a working configuration setup that I have stored in 02-netcfg.yaml If i cant ping the server IP. I have masked my server IP address whit aa.bb.cc.dd So you have to replace that whit the IP you want to ping, in order to execute the "else" in the if.



            Then i set this script to run everytime the server restart, as well as enable a Cron job for it that runs every 3 minutes when i work on network configurations.






            share|improve this answer






















            • A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
              – BD Bear
              Mar 15 at 10:17














            up vote
            0
            down vote



            accepted










            First I created a sh script, placed it in /etc/netplan/ and named it backup.sh



            #!/bin/sh

            # -q quiet
            # -c nb of pings to perform

            ping -q -c5 aa.bb.cc.dd > /dev/null

            if [ $? -eq 0 ]
            then
            : #do absolutly nothing! server can ping its external IP.
            else
            # restore, working config to netplan.
            cp -f /etc/netplan/02-netcfg.yaml /etc/netplan/01-netcfg.yaml
            # apply network config.
            netplan apply
            fi


            This script revert the changes I have made, to a working configuration setup that I have stored in 02-netcfg.yaml If i cant ping the server IP. I have masked my server IP address whit aa.bb.cc.dd So you have to replace that whit the IP you want to ping, in order to execute the "else" in the if.



            Then i set this script to run everytime the server restart, as well as enable a Cron job for it that runs every 3 minutes when i work on network configurations.






            share|improve this answer






















            • A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
              – BD Bear
              Mar 15 at 10:17












            up vote
            0
            down vote



            accepted







            up vote
            0
            down vote



            accepted






            First I created a sh script, placed it in /etc/netplan/ and named it backup.sh



            #!/bin/sh

            # -q quiet
            # -c nb of pings to perform

            ping -q -c5 aa.bb.cc.dd > /dev/null

            if [ $? -eq 0 ]
            then
            : #do absolutly nothing! server can ping its external IP.
            else
            # restore, working config to netplan.
            cp -f /etc/netplan/02-netcfg.yaml /etc/netplan/01-netcfg.yaml
            # apply network config.
            netplan apply
            fi


            This script revert the changes I have made, to a working configuration setup that I have stored in 02-netcfg.yaml If i cant ping the server IP. I have masked my server IP address whit aa.bb.cc.dd So you have to replace that whit the IP you want to ping, in order to execute the "else" in the if.



            Then i set this script to run everytime the server restart, as well as enable a Cron job for it that runs every 3 minutes when i work on network configurations.






            share|improve this answer














            First I created a sh script, placed it in /etc/netplan/ and named it backup.sh



            #!/bin/sh

            # -q quiet
            # -c nb of pings to perform

            ping -q -c5 aa.bb.cc.dd > /dev/null

            if [ $? -eq 0 ]
            then
            : #do absolutly nothing! server can ping its external IP.
            else
            # restore, working config to netplan.
            cp -f /etc/netplan/02-netcfg.yaml /etc/netplan/01-netcfg.yaml
            # apply network config.
            netplan apply
            fi


            This script revert the changes I have made, to a working configuration setup that I have stored in 02-netcfg.yaml If i cant ping the server IP. I have masked my server IP address whit aa.bb.cc.dd So you have to replace that whit the IP you want to ping, in order to execute the "else" in the if.



            Then i set this script to run everytime the server restart, as well as enable a Cron job for it that runs every 3 minutes when i work on network configurations.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 15 at 10:27

























            answered Mar 15 at 10:14









            BD Bear

            11013




            11013











            • A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
              – BD Bear
              Mar 15 at 10:17
















            • A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
              – BD Bear
              Mar 15 at 10:17















            A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
            – BD Bear
            Mar 15 at 10:17




            A question, to simplyfy the script even more: Can i add a netplan - c /etc/netplan/02-netcfg.yaml apply or something like that?
            – BD Bear
            Mar 15 at 10:17

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1013455%2fis-there-a-way-to-try-out-a-netplan-configuration-without-altering-the-system%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

            GRUB: Fatal! inconsistent data read from (0x84) 0+xxxxxx

            Problem in reading from socket

            Do not install recommended packages of dependencies