// Module included in the following assemblies:
//
// * machine_management/cluster_api_machine_management/cluster-api-managing-machines.adoc

:_mod-docs-content-type: PROCEDURE
[id="capi-modifying-machine-template_{context}"]
= Modifying a Cluster API machine template

[role="_abstract"]
You can update the machine template resource for your cluster by modifying the YAML manifest file and applying it with the {oc-first}.

.Prerequisites

* You have deployed an {product-title} cluster that uses the Cluster API.

* You have access to the cluster using an account with `cluster-admin` permissions.

* You have installed the {oc-first}.

.Procedure

. List the machine template resource for your cluster by running the following command:
+
[source,terminal]
----
$ oc get <machine_template_kind>
----
+
Replace `<machine_template_kind>` with the value that corresponds to your platform.
The following values are valid:
+
|====
|Cluster infrastructure provider |Value

|{aws-full}
|`AWSMachineTemplate`

|{gcp-full}
|`GCPMachineTemplate`

|{azure-first}
|`AzureMachineTemplate`

|{rh-openstack}
|`OpenStackMachineTemplate`

|{vmw-full}
|`VSphereMachineTemplate`

|Bare metal
|`Metal3MachineTemplate`

|====
+
.Example output
[source,text]
----
NAME              AGE
<template_name>   77m
----

. Write the machine template resource for your cluster to a file that you can edit by running the following command:
+
[source,terminal]
----
$ oc get <machine_template_kind> <template_name> -o yaml > <template_name>.yaml
----
+
Replace `<template_name>` with the name of the machine template resource for your cluster.

. Make a copy of the `<template_name>.yaml` file with a different name. This procedure uses `<modified_template_name>.yaml` as an example file name.

. Use a text editor to make changes to the `<modified_template_name>.yaml` file that defines the updated machine template resource for your cluster.
When editing the machine template resource, observe the following:

** The parameters in the `spec` stanza are provider specific.
For more information, see the sample Cluster API machine template YAML for your provider.

** You must use a value for the `metadata.name` parameter that differs from any existing values.
+
[IMPORTANT]
====
For any Cluster API compute machine sets that reference this template, you must update the `spec.template.spec.infrastructureRef.name` parameter to match the `metadata.name` value in the new machine template resource.
====

. Apply the machine template CR by running the following command:
+
[source,terminal]
----
$ oc apply -f <modified_template_name>.yaml
----
For `<modified_template_name>`, use the edited YAML file with a new name.

.Next steps

* For any Cluster API compute machine sets that reference this template, update the `spec.template.spec.infrastructureRef.name` parameter to match the `metadata.name` value in the new machine template resource.
For more information, see "Modifying a compute machine set by using the CLI."
