Cleaning up Environments

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

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

  1. Navigate to the Machine policies screen.
  2. Create a new machine policy by selecting Add machine policy:

  1. Name the machine policy “Clean up machines”.
  2. 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:

  1. Save the machine policy.

  2. Assign the machine policy to a machine by selecting a machine and using the Policy drop down to select the machine policy:

  1. 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.

Learn more

Help us continuously improve

Please let us know if you have any feedback about this page.

Send feedback

Page updated on Wednesday, October 4, 2023