Updating agents
Update an agent configuration in the currently selected Schematics region to work directly in your cloud infrastructure. Updating an agent does not validate or deploy your agent. Select the right agent version to update. You can analyze the activity logs and recover the update.
Following are the scenarios you must use agent upgrade.
- To incorporate the issues, features, or vulnerable images that are released by Schematics. For example, you are using agent version is
1.0.0
. If Schematics releases1.0.x
version, you can use agent update to upgradev1.0.0
-v1.1.1
. - To update an agent metadata such as
name
,description
,tags
,resource group
,version
, andagent_metadata
attributes. - You can use
agent update
to revoke the updated version to its existing version.
Agent update cannot be done on a deployed agent when performing terraform init
, terraform plan
and terraform apply
on the workspace that are used with the deployed agent.
Before you begin
Review and select your agent version to update.
Updating an agent definition
Update your agent configuration by choosing the cluster and IBM Cloud Object Storage of your choice.
- Log in to IBM Cloud.
- Access Schematics > Agents.
- Select your agent:
- Select Actions > Edit Agent
- You can edit the Description, Cluster, COS instance name, COS bucket name, COS bucket region, or Agent version as in the requirement.
- Select your agent:
- Click Update and validate to validate the cluster and IBM Cloud Object Storage configuration.
- Click Deploy to redeploy an agent.
Creating an agent definition by using the CLI
Select the IBM Cloud region where you want to update and manage your agent. Set the CLI region command by running ibmcloud target -r <region>
. Select the same
region as the location
specified on the agent create
command. The IBM Cloud Object Storage bucket location must be of the form eu-gb
or us-south
and not a city name. For more information,
see agent update command.
Example
ibmcloud schematics agent update --id AGENT_ID --location <us-south> --agent-location <us-south> --version <1.0.0> --infra-type <ibm_kubernetes> --cluster-id <cg3fgvad0dak571xxx> --cluster-resource-group <Default> --cos-instance-name <agent-cos-instance> --cos-bucket <agent-cos-bucket> --cos-location <us-east> --resource-group <Default>
Verifying agent update
ibmcloud schematics agent get --id agent-ga-prod-cli-jan-10.soA.cd1c
Updating an agent by using the Schematics API
Follow the steps to update an IAM access token and authenticate with Schematics through the API. For more information, see Update an agent.
You can use the refresh_token
to get a new IAM access token if you IAM token is expired.
Example
curl -X PUT https://schematics.cloud.ibm.com/v2/agents/{agent_id} \-H 'Authorization: Bearer <Auth Key>' -H 'X-Feature-Agents: true' -H 'refresh_token: <refresh_token> ' -d '{
"name": "AgentName",
"description": "New Description",
"resource_group": "Default",
"tags": [
"tag1",
"tag2"
],
"version": "v1.0.0",
"schematics_location": "us-south",
"agent_location": "us-south",
"agent_infrastructure": {
"infra_type": "ibm_kubernetes",
"cluster_id": "cluster_id",
"cluster_resource_group": "Default",
"cos_instance_name": "blueprint_basic",
"cos_bucket_name": "sample_bucket_name",
"cos_bucket_region": "us-east"
},
"agent_inputs": [
{
"name": "ibmcloud_api_key",
"value": "<api_key of the account where cluster and cos are present>",
"metadata": {
"secure": true
}
},
{
"name": "ansible_pull_ibmcloud_api_key",
"value": "jenkins api_key for pulling agents images",
"metadata": {
"secure": true
}
},
{
"name": "devops_api_key",
"value": "api_key where you want to create agent and run fvts",
"metadata": {
"secure": true
}
}
],
"user_state": {
"state": "enable"
}
}'
Verify that the agent definition is created successfully as shown in the output. Record the agent ID for use in subsequent commands. For example, agentb1-gsmforvpc.soA.115c
.
Now, run the agent deploy
API with the agent ID
to update the Schematics workspace that deploys the agent. The agent deploy
operation starts both the agent validate
, and agent deploy
operations to setup the agent.
Syntax
PUT /v2/agents/<enter your agentID>/deploy HTTP/1.1
Host: schematics.cloud.ibm.com
Content-Type: application/json
Authorization: Bearer