Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Will "waagent -deprovision[+user]" wipe the cloud-init data? #631

Closed
yuxisun1217 opened this issue Mar 28, 2017 · 13 comments
Closed

Will "waagent -deprovision[+user]" wipe the cloud-init data? #631

yuxisun1217 opened this issue Mar 28, 2017 · 13 comments

Comments

@yuxisun1217
Copy link

Hi there,

It seems that the cloud-init is going to be involved in the RHEL images. Do you think that the "waagent -deprovision[+user]" should wipe the data that generated by cloud-init during provisioning? Because if the cloud-init data is not cleaned, the cloud-init will not provision during the next boot.
Thanks!

Currently we found some cloud-init data like this:

  1. /etc/sudoers.d/90-cloud-init-users
  2. All the files in /var/lib/cloud/
@hglkrijger hglkrijger modified the milestone: v2.2.8 Mar 31, 2017
@hglkrijger
Copy link
Member

@yuxisun1217, I confirmed that cloud-init will still provision, since it uses the VM unique id, which ends up in /var/lib/cloud/instances/*. We should still cleanup old data which may be sensitive though, so I will leave this issue open as a feature request.

@yuxisun1217
Copy link
Author

@hglkrijger, Sorry for the wrong understanding of this feature and thank you for your confirming. :)

@brendandixon brendandixon added this to the v2.2.11 milestone Apr 27, 2017
@brendandixon
Copy link
Contributor

@hglkrijger Are these safe to delete (e.g., shutil.rmtree('/var/lib/cloud'))?

@hglkrijger
Copy link
Member

@brendandixon I don't think we should remove the root directory, but selectively under it, such as:

/var/lib/cloud/instance
/var/lib/cloud/instances/*
/var/lib/cloud/data/*

@brendandixon
Copy link
Contributor

@paulmey Any comment? You know the cloud-init code better than the rest of us.

@paulmey
Copy link
Member

paulmey commented May 3, 2017

from /usr/share/doc/cloud-init/var-lib-cloud.txt:

to clear out the current instance's data as if to force a "new run" on reboot
do:
( cd /var/lib/cloud/instance && sudo rm -Rf * )

but it's safe to delete all of /var/lib/cloud. It's not installed by the deb and stages.py recursively recreates the whole layout if it doesn't exist.

brendandixon added a commit that referenced this issue May 4, 2017
Deprovision cloud-init data (#631)
@brendandixon
Copy link
Contributor

Addressed by #698

@cmelanson
Copy link

@brendandixon We are storing scripts in /var/lib/cloud/scripts/per-instance which are executed on the first boot, as we customize the image for our own purposes. This change breaks this functionality for us, and I believe this is a common use case. Would it be possible to not clear out /var/lib/cloud/scripts during this new cleanup procedure or make it configurable?

@brendandixon
Copy link
Contributor

@cmelanson Happy to adjust it. I'll alter the code to remove the minimum needed.

@brendandixon
Copy link
Contributor

@cmelanson Addressed in #702

hglkrijger pushed a commit that referenced this issue May 8, 2017
Correctly handle cleaning directories that include symlinks
Reduced polling interval #701
Enable selective agent testing
Improved FIPS configuration variable name
Reduced cloud-init files removed on deprovision #631

Signed-off-by: Brendan Dixon <brendandixon@me.com>
@rjschwei
Copy link
Contributor

rjschwei commented Jun 8, 2017

I know this is a really late comment, just reviewing changes before pulling the latest release into SLES.

The idea that one process removes the files left behind by another process is IMHO fundamentally flawed and violates basic principles. In more modern browsers checks have been implemented to ensure one site does not scribble on cookies from other sites for security reasons. Now waagent removes files from cloud-init, sorry but that's just wrong.

First as already confirmed in the thread, cloud-init will recognize when re-provisioning is in order. Second any changes in cloud-init such as additional files in other locations will require work here.

@dsuth1
Copy link

dsuth1 commented Aug 23, 2017

Is there a way to disable this feature? This programmatically breaks how per-instance and per-once runs. With this in-place, you could actually never have per-once work as it blows away the contents of that directory when you "deprovision" a box before snapshot. Honestly waagent should not be touching the cloudinit data directories.

@arno01
Copy link

arno01 commented Jan 24, 2018

Good point, @rjschwei ; Another general point that I would like to highlight is that even if you happen to remove some files which you think might contain sensitive data, then you should not just remove it, but shred it.

Then, depending where the user-data came from, it may and likely still be available there. E.g. $ curl http://169.254.169.254/latest/user-data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants