Schedule
The cron entries that osapi deploys. osapi dsl behavior get --name schedule
and osapi dsl behavior method get show the same.
Its chain shows each call that its
examples make.
Behavior
| Name | schedule |
| Description | The cron entries that osapi deploys |
| Placement | node |
| Area | config |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | debian |
| Sudo | none |
| Runs | none |
| Writes | /etc/cron.d/*, /etc/cron.hourly/*, /etc/cron.daily/*, /etc/cron.weekly/*, /etc/cron.monthly/* |
| Keeps state | no |
| Uses | object, managedfile |
| Used by | none |
Methods (5)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|---|---|---|---|---|
| list | read | GET | /api/node/{hostname}/schedule | schedule:read | List the cron entries that osapi deployed |
| get | read | GET | /api/node/{hostname}/schedule/{name} | schedule:read | Get one cron entry that osapi deployed |
| create | write | POST | /api/node/{hostname}/schedule | schedule:write | Deploy a cron entry |
| update | write | PUT | /api/node/{hostname}/schedule/{name} | schedule:write | Deploy a cron entry that osapi deployed again |
| delete | write | DELETE | /api/node/{hostname}/schedule/{name} | schedule:write | Remove a cron entry that osapi deployed |
Types (5)
| NAME | INPUT | OUTPUT |
|---|---|---|
| list | ListInput | []Entry { name, object, schedule, interval, user, source } |
| get | GetInput { name* } | Entry { name, object, schedule, interval, user, source } |
| create | CreateInput { name*, object*, schedule, interval, user, content_type, vars } | Result { name, changed } |
| update | UpdateInput { name*, object, schedule, user, content_type, vars } | Result { name, changed } |
| delete | DeleteInput { name* } | Result { name, changed } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| Span | behavior.schedule.<method> |
| Child spans | behavior.object.<method>, behavior.managedfile.<method>, exec chown, exec stat, file.write, file.remove, file.chmod, kv.get, kv.put |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | name (get, create, update, delete) |
Method list
| Name | list |
| Verb | read |
| Description | List the cron entries that osapi deployed |
| Detail | Lists each file in /etc/cron.d and in /etc/cron.hourly, daily, weekly and monthly that osapi deployed, with its object, its cron expression or interval, and its user. A cron file that osapi did not deploy is not listed. |
| HTTP | GET |
| Route | /api/node/{hostname}/schedule |
| Permission | schedule:read |
| Command | osapi client node schedule list |
| Input type | ListInput |
| Output type | []Entry |
Input (0)
None. The method takes no input; its command needs only --target.
Output (6)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The entry |
| object | string | The object it was deployed from |
| schedule | string | Its cron expression, for an entry in /etc/cron.d |
| interval | string | Its interval, for a script in /etc/cron.daily and the like |
| user | string | The user it runs as |
| source | string | Where its file is: cron.d, or the interval |
Examples (3)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| An entry that osapi deployed | (none) | [name=osapitest, object=osapitest.cron, schedule=0 2 * * *, source=cron.d, user=root] |
| A daily script that osapi deployed | (none) | [interval=daily, name=osapitest, object=osapitest.sh, source=daily] |
| A host where osapi deployed none | (none) |
Method get
| Name | get |
| Verb | read |
| Description | Get one cron entry that osapi deployed |
| Detail | Reads the entry from /etc/cron.d, then from each interval directory. An entry that osapi did not deploy is not found. |
| HTTP | GET |
| Route | /api/node/{hostname}/schedule/{name} |
| Permission | schedule:read |
| Command | osapi client node schedule get |
| Input type | GetInput |
| Output type | Entry |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$, max length 64 | The entry, such as backup |
Output (6)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The entry |
| object | string | The object it was deployed from |
| schedule | string | Its cron expression, for an entry in /etc/cron.d |
| interval | string | Its interval, for a script in /etc/cron.daily and the like |
| user | string | The user it runs as |
| source | string | Where its file is: cron.d, or the interval |
Examples (1)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| An entry that osapi deployed | name=osapitest | name=osapitest, object=osapitest.cron, schedule=0 2 * * *, user=root, source=cron.d |
Method create
| Name | create |
| Verb | write |
| Description | Deploy a cron entry |
| Detail | Gets the object from the object store and writes it as /etc/cron.d/backup for backup, mode 0644, for a cron expression, or as /etc/cron.daily/backup, mode 0755, for a daily interval. An object of content type template, or content_type template, is rendered with the agent's facts and the vars. A file that has the content does not change. An entry of the name in a different directory does not change: move it with delete and create. A file at the path that osapi did not deploy is refused. An entry runs as its user, root included, so only admin can deploy one. |
| HTTP | POST |
| Route | /api/node/{hostname}/schedule |
| Permission | schedule:write |
| Command | osapi client node schedule create |
| Input type | CreateInput |
| Output type | Result |
Input (7)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$, max length 64 | The entry, and its file name, such as backup |
| object | string | yes | min length 1, max length 255 | The object that holds the entry, from osapi client file upload |
| schedule | string | no | A cron expression, such as */5 * * * *; give it or interval | |
| interval | string | no | one of hourly daily weekly monthly | The interval of a script in /etc/cron.daily and the like; give it or schedule |
| user | string | no | pattern ^[a-z_][a-z0-9_-]*$?$ | The user the entry runs as |
| content_type | string | no | one of raw template | The content type: raw, or template to render the object with the agent's facts and vars; the object's own when empty |
| vars | object | no | The vars of a template, as key=value |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The entry |
| changed | boolean | Whether the host changed |
Examples (5)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| An entry with a cron expression | name=osapitest, object=osapitest.cron, schedule=0 2 * * *, user=root | name=osapitest, changed=true |
| A script that runs daily | name=osapitest, object=osapitest.sh, interval=daily | name=osapitest, changed=true |
| A template, rendered with its vars | name=osapitest, object=osapitest.tmpl, schedule=0 2 * * *, content_type=template, vars=map[target:/srv] | name=osapitest, changed=true |
| An entry that has the content | name=osapitest, object=osapitest.cron, schedule=0 2 * * *, user=root | name=osapitest, changed=false |
| An entry of the name in a different directory | name=osapitest, object=osapitest.sh, interval=daily | name=osapitest, changed=false |
Method update
| Name | update |
| Verb | write |
| Description | Deploy a cron entry that osapi deployed again |
| Detail | Writes a new object, or the entry's own, at the entry's path, with the fields that the request gives and the entry's own for the rest. A file that has the content does not change. An entry that osapi did not deploy is not found. The entry stays in its directory: an interval does not change with update. |
| HTTP | PUT |
| Route | /api/node/{hostname}/schedule/{name} |
| Permission | schedule:write |
| Command | osapi client node schedule update |
| Input type | UpdateInput |
| Output type | Result |
Input (6)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$, max length 64 | The entry, such as backup |
| object | string | no | min length 1, max length 255 | The object to deploy; the entry's own when empty |
| schedule | string | no | A new cron expression; the entry's own when empty | |
| user | string | no | pattern ^[a-z_][a-z0-9_-]*$?$ | The user the entry runs as; the entry's own when empty |
| content_type | string | no | one of raw template | The content type, raw or template; the object's own when empty |
| vars | object | no | The vars of a template, as key=value |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The entry |
| changed | boolean | Whether the host changed |
Examples (4)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| A new object | name=osapitest, object=osapitest-v2.cron | name=osapitest, changed=true |
| A new cron expression, with the same object | name=osapitest, schedule=30 2 * * * | name=osapitest, changed=true |
| A new object, cron expression and user | name=osapitest, object=osapitest-v2.cron, schedule=30 2 * * *, user=nobody | name=osapitest, changed=true |
| A daily script with a new object | name=osapitest, object=osapitest-v2.sh | name=osapitest, changed=true |
Method delete
| Name | delete |
| Verb | write |
| Description | Remove a cron entry that osapi deployed |
| Detail | Removes the entry's file and its record. An entry that osapi did not deploy does not change, and a cron file that osapi did not deploy stays. |
| HTTP | DELETE |
| Route | /api/node/{hostname}/schedule/{name} |
| Permission | schedule:write |
| Command | osapi client node schedule delete |
| Input type | DeleteInput |
| Output type | Result |
Input (1)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| name | string | yes | pattern ^[a-zA-Z0-9_-]+$, max length 64 | The entry, such as backup |
Output (2)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| name | string | The entry |
| changed | boolean | Whether the host changed |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| Remove an entry | name=osapitest | name=osapitest, changed=true |
| An entry that osapi did not deploy | name=osapitest | name=osapitest, changed=false |