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.
Machine deletion happens as part of health checks.
Read more about machine policies
Troubleshooting Automatic Environment Clean Up
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.
Help us continuously improve
Please let us know if you have any feedback about this page.
Last updated Sunday, January 1, 2023