Octopus can automatically remove unwanted machines from environments based on their health status. This is useful when an environment is scaled down and orphaned deployment targets remain in Octopus. Automatic environment clean up can be configured through machine policies.
In this example we will create a machine policy to automatically delete machines when they become unavailable.
Creating a Machine Policy for Environment Cleanup
- Navigate to the Machine policies screen
- Create a new machine policy by selecting Add machine policy:
- Name the machine policy "Clean up machines"
- Change the setting "Clean up unavailable machines" to "Automatically delete unavailable machines". By selecting this option and setting the time to 0, any machines that fail a health check and become unavailable will be deleted:
Save the machine policy
Assign the machine policy to a machine by selecting a machine and using the Policy drop down to select the machine policy:
- Turn the machine off and run a health check.
In Octopus versions prior to 2018.1 a separate scheduled task ran periodically and removed machines from Octopus. As of Octopus version 2018.1, machine deletion happens as part of health checks.
Read more about machine policies