Delete
Drop a route that osapi wrote.
Drops the route from the interface's netplan file and applies what is left; the last route removes the file. A route osapi does not have does not change.
osapi client node interface route delete [flags]
Examples
# One of two routes
osapi client node interface route delete --target web-01 --name osapi0 --destination 198.51.100.0/24
# The last route
osapi client node interface route delete --target web-01 --name osapi0 --destination 198.51.100.0/24
# A route osapi does not have
osapi client node interface route delete --target web-01 --name osapi0 --destination 198.51.100.0/24
Result
One of two routes, on one host:
$ osapi client node interface route delete --target web-01 --name osapi0 --destination 198.51.100.0/24 Results: HOSTNAME STATUS DESTINATION web-01 changed 198.51.100.0/24 1 host: 1 changed job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node interface route delete --target _all --name osapi0 --destination 198.51.100.0/24 Results: HOSTNAME STATUS DESTINATION web-01 changed 198.51.100.0/24 web-02 changed 198.51.100.0/24 3 hosts: 2 changed, 1 skipped job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9 Details: mac-01 skipped operation not supported on this OS family
With --json, the API's response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"changed": true,
"destination": "198.51.100.0/24",
"hostname": "web-01",
"status": "ok"
}
]
}
The last route, on one host:
$ osapi client node interface route delete --target web-01 --name osapi0 --destination 198.51.100.0/24 Results: HOSTNAME STATUS DESTINATION web-01 changed 198.51.100.0/24 1 host: 1 changed job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node interface route delete --target _all --name osapi0 --destination 198.51.100.0/24 Results: HOSTNAME STATUS DESTINATION web-01 changed 198.51.100.0/24 web-02 changed 198.51.100.0/24 3 hosts: 2 changed, 1 skipped job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9 Details: mac-01 skipped operation not supported on this OS family
With --json, the API's response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"changed": true,
"destination": "198.51.100.0/24",
"hostname": "web-01",
"status": "ok"
}
]
}
A route osapi does not have, on one host:
$ osapi client node interface route delete --target web-01 --name osapi0 --destination 198.51.100.0/24 Results: HOSTNAME STATUS DESTINATION web-01 ok 198.51.100.0/24 1 host: 1 ok job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9
On each host, where one cannot run it:
$ osapi client node interface route delete --target _all --name osapi0 --destination 198.51.100.0/24 Results: HOSTNAME STATUS DESTINATION web-01 ok 198.51.100.0/24 web-02 ok 198.51.100.0/24 3 hosts: 2 ok, 1 skipped job 550e8400-e29b-41d4-a716-446655440000 trace 26e448c9dbe1c4a8d216a98c675079c9 Details: mac-01 skipped operation not supported on this OS family
With --json, the API's response:
{
"job_id": "550e8400-e29b-41d4-a716-446655440000",
"results": [
{
"changed": false,
"destination": "198.51.100.0/24",
"hostname": "web-01",
"status": "ok"
}
]
}
With the default settings, each example does this on the host:
| Example | On the host |
|---|---|
| One of two routes | runs netplan generate; runs netplan apply; writes /etc/netplan/osapi-osapi0-routes.yaml: network:\n version: 2\n ethernets:\n osapi0:\n routes:\n - to: 2001:db8:1::/48\n via: 2001:db8::1\n metric: 200 |
| The last route | removes /etc/netplan/osapi-osapi0-routes.yaml; runs netplan apply |
The command fails in these cases:
| Call | Flags | Fails with |
|---|---|---|
| A destination that is not CIDR | --name osapi0 --destination 10.0.0.0 | Destination |
| A name that is not an interface name | --name "eth0;reboot" --destination 198.51.100.0/24 | Name |
Permission
It needs the interface:write permission.
osapi controller role get --name <role> shows what a role grants.
Flags
| Flag | Description | Default |
|---|---|---|
--destination | The destination of the route, in CIDR notation, such as 10.0.0.0/8 (required) | |
--name | The interface, such as eth0, or a fact such as @fact.interface.primary (required) | |
-T, --target | Target: _all, _any, hostname, or label (group:web.dev) | _all |
Global flags
| Flag | Description | Default |
|---|---|---|
-d, --debug | Enable or disable debug mode | |
-j, --json | Enable JSON output | |
-f, --osapi-file | Path to config file; without one at the default path, osapi runs on the defaults | /etc/osapi/osapi.yaml |
--url | Base URL the CLI client connects to (controller.client.url) | https://localhost:8080 |
Output tells how the result is printed, and what
--json gives.