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.
Machine policies are machine related settings that can be applied per-machine. They can be accessed at Infrastructure ➜ 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 versions prior to Octopus 2018.1 a separate scheduled task ran periodically and removed machines from Octopus. As of Octopus 2018.1, machine deletion happens as part of health checks.
Read more about machine policies
Troubleshooting Automatic Environment Clean Up
As of Octopus 2018.1, machine clean up is part of health checks and machine clean up logs are not stored. Machine clean up logging is written to the log of the health check task that performed the deletion. Audit events recording the automatic clean up of machines can be accessed via the Configuration ➜ Diagnostics page by selecting Machine clean up events, which redirects to the audit log of automatic machine removals.
Need support? We're here to help.