How to get rid of cloud-init?

58,841

Solution 1

According to the cloud-init docs the way to disable it is:

sudo touch /etc/cloud/cloud-init.disabled

And/or set cloud-init=disabled on the kernel command line if it's enabled that way.

Solution 2

This worked for me in Ubuntu Server 18.04.1 LST

  1. $ echo 'datasource_list: [ None ]' | sudo -s tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg

  2. $ sudo apt-get purge cloud-init

  3. $ sudo rm -rf /etc/cloud/; sudo rm -rf /var/lib/cloud/

  4. $ reboot

Good Luck.

Solution 3

On 14.04 you can use dpkg-reconfigure to disable cloud-init in the following way:

echo 'datasource_list: [ None ]' | sudo -s tee /etc/cloud/cloud.cfg.d/90_dpkg.cfg
sudo dpkg-reconfigure -f noninteractive cloud-init

or just use sudo dpkg-reconfigure cloud-init to do it interactively.

Solution 4

Cloud Init is there to configure networking and it can be stopped at different stages. In recent versions, you can disable Cloud Init at the first stage by making sure the following file exists:

/etc/cloud/cloud-init.disabled

or at a later stage by making sure the file /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg exists with the following content:

network: {config: disabled}

You can use this command for it:

$ sudo echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

This information can be found in the header comments of /etc/netplan/50-cloud-init.yaml, which in part read as follows:

# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

This is from the file in Ubuntu 18.04 LTS and likely to also be valid for later releases.

Share:
58,841

Related videos on Youtube

mnowotka
Author by

mnowotka

Updated on September 18, 2022

Comments

  • mnowotka
    mnowotka over 1 year

    I'm using Ubuntu 14.04 image as my base box for vagrant. Unfortunately this base box contains cloud-init which causes many problems during starting-up the machine: https://github.com/mitchellh/vagrant/issues/3860

    I'm not using my machine in the cloud so I don't really need this. I though typing:

    sudo apt-get remove cloud-init
    

    will solve my problems but the machine still spend about 3 minutes on startup trying to configure something I don't need.

    I can see there a a number of cloud-init related files in /etc/init (for example cloud-init.conf, cloud-final.conf, cloud-config.conf etc). I could delete them but I'm not sure if this is safe.

    I've also installed rcconf to check all starup scripts but I can't find anything related to cloud-init there. Any ideas?

  • Enno Gröper
    Enno Gröper about 5 years
    Really? Changig a file you delete two steps later? Seems like you can skip the first step.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    IMHO, it only disables its network configuration part. Thus it is not enough.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    Note that it does not remove it. It is still there but it will stop trying to configure stuff at a very early stage. See cloudinit.readthedocs.io/en/latest/topics/boot.html
  • code_dredd
    code_dredd about 5 years
    @LudovicKuty Which is precisely what cloud-init is there to do: configure things. Thus, if you get it to stop trying to configure things, you have accomplished your goal and it is enough to make it stay out of your way. If you insist it isn't, then please explain what "enough" would be, exactly.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    It might still tries to configure other stuff than networking. IMHO the OP wanted to disable it completely. Note that this granularity might be interesting in other cases.
  • code_dredd
    code_dredd about 5 years
    @LudovicKuty Your comments are coming across as speculative ("IMHO", "it might ...", etc). Unless you can show that the documentation is wrong and that it does continue to try things after being told not to, I don't think there's much more to this, and in that case, you'd be better off reporting a bug to them. This has been enough every time I've done it in my servers.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    Go check cloudinit.readthedocs.io/en/latest/topics/boot.html vs cloudinit.readthedocs.io/en/latest/topics/network-config.htm‌​l. You're criticizing my "IMHO" and "might" and you're writing "the correct way to disable Cloud Init is with this command" but you should have added "IMHO" since it is not the correct way to do it.
  • code_dredd
    code_dredd about 5 years
    @LudovicKuty And it mentions this: "network configuration can be disabled entirely with config like the following in /etc/cloud/cloud.cfg: network: {config: disabled}." What specific part of my post are you challenging with what specific part of the documentation? Please, be specific, as I'd rather avoid trying to guess what you have in mind, exactly.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    For me "disabling cloud-init" is not the same as "disabling the network configuration part of cloud-init". That's why I posted the comment in the first place but I should have been more specific.
  • Pierz
    Pierz about 5 years
    Sure that's why I said it would disable it.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    Yes you are right. My comment is useless.
  • code_dredd
    code_dredd about 5 years
    @LudovicKuty I've updated the post. I added some info and made some wording more explicit. Given that cloud-init exists to generate network configs, any solution that gets cloud init to stop messing around with network configs should be fine.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    Yes. I don't know cloud-init much but it looks like it can set a default locale, set hostname, generate ssh private keys, set up ephemeral mount points (copied from the docs) but indeed its focus is on the cloud and thus networking. I guess that once networking is disabled, cloud-init doesn't do much but I may be wrong. But that's fine for me, I don't want to argue.
  • code_dredd
    code_dredd about 5 years
    @LudovicKuty I'm discussing to clarify, not arguing. I didn't see any of the other things you mentioned in the docs and it's something that I don't believe I've seen cloud-init try to do. For example, the SSH key pair is generated by the SSH daemon when you install it. The hostname is set by you when you install the OS or with the hostname command, etc. I think you think cloud-init does a lot more than what it really does.
  • Ludovic Kuty
    Ludovic Kuty about 5 years
    Maybe. I looked at cloud-init.io and help.ubuntu.com/community/CloudInit and the introductory text let me think that it can fully configure a server, not just the networking part because it has been invented to automatically run instances in the cloud. That's what it looks like inside /etc/cloud/cloud.cfg.
  • Tim
    Tim about 4 years
    Seems like a mix is the key: touch /etc/cloud/cloud-init.disabled then reboot to stop it. Then step 2-3 from Lion's answer above gets rid of it forever.
  • HelpNeeder
    HelpNeeder almost 4 years
    the "cloud-init=disabled" doesn't work as of may 2020.
  • Andras
    Andras about 3 years
    It has worked on Ubuntu Server 20.04.2 too... Thanks
  • null
    null about 3 years
    @Pierz Are you willing to reword you response so that it answers the question as asked? Perhaps lead with the answer of how to remove, then follow with a work-around of disable ?
  • null
    null about 3 years
    Are you willing to reword you response so that it answers the question as asked? Perhaps lead with the answer of how to remove, then follow with a work-around of disable ?
  • Jeter-work
    Jeter-work about 2 years
    @code_dredd the problem is that you need to remove "Cloud Init is there to configure networking and it can be stopped at different stages." cloud-init can configure any aspect of the host. Network config is just one aspect. OP's question is how to disable cloud-init. The answer is sudo touch /etc/cloud/cloud-init.disabled and that answer should be marked as such. Disable it, reboot, remove it. Disabling the network portion of cloud-init is a valid task and the way presented in this question probably works, but it is irrelevant to the question at hand. "How to disable cloud-init"
  • Jeter-work
    Jeter-work about 2 years
    _On instance boot, cloud-init will identify the cloud it is running on, read any provided metadata from the cloud, and initialize the system accordingly. This may involve setting up the network and storage devices, configuring SSH access keys, and setting up many other aspects of a system. _ ...cloudinit.readthedocs.io/en/latest Your answer states that the sole purpose of cloud-init is setting up network configuration. This is not true.
  • code_dredd
    code_dredd about 2 years
    @Jeter-work: My answer was posted 6+ years ago. I don't recall what its capabilities were back then, but I'm sure they've done more work on it since then.