Skip to main content

File

Files of the object store, deployed to the host. osapi dsl behavior get --name file and osapi dsl behavior method get show the same. Its chain shows each call that its examples make.

Behavior​

Namefile
DescriptionFiles of the object store, deployed to the host
Placementnode
Areaconfig
Internalno
APIyes
CLIyes
Nextno
Platformslinux, darwin
Sudonone
Runsnone
Writes*
Keeps stateno
Usesobject, managedfile
Used bynone

Methods (3)​

NAMEVERBHTTPROUTEPERMISSIONDESCRIPTION
getreadGET/api/node/{hostname}/filefile:readShow whether a deployed file holds what osapi wrote
updatewritePUT/api/node/{hostname}/filefile:writeDeploy an object of the object store to a path
deletewriteDELETE/api/node/{hostname}/filefile:writeRemove a file that osapi deployed

Types (3)​

NAMEINPUTOUTPUT
getStatusInput { path* }Status { path, state, sha256 }
updateUpdateInput { object_name*, path*, mode, owner, group, content_type, vars }UpdateResult { path, sha256, changed }
deleteDeleteInput { path* }DeleteResult { path, changed }

Settings (0)​

None. Declare them with behavior.Config.

Telemetry​

Spanbehavior.file.<method>
Child spansbehavior.object.<method>, behavior.managedfile.<method>, exec chown, exec stat, file.write, file.remove, file.chmod, kv.get, kv.put
Metricsosapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total
Attributesosapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed
Recorded inputspath (update, delete)

Method get​

Nameget
Verbread
DescriptionShow whether a deployed file holds what osapi wrote
DetailCompares the file on the host with the record that osapi keeps of what it deployed: in-sync when they agree, drifted when something changed the file, missing when osapi deployed the file and it is gone, and unmanaged when osapi did not deploy the path or undeployed it. A path that is a directory is refused.
HTTPGET
Route/api/node/{hostname}/file
Permissionfile:read
Commandosapi client node file get
Input typeStatusInput
Output typeStatus

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
pathstringyespattern ^/Absolute path of the file on the host

Output (3)​

FIELDTYPEDESCRIPTION
pathstringAbsolute path of the file
statestringin-sync, drifted, missing or unmanaged
sha256stringSHA-256 of the file on the host, when it is there

Examples (3)​

EXAMPLEINPUTOUTPUT
A deployed filepath=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, state=in-sync, sha256=0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60
A path that osapi did not deploypath=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, state=unmanaged
A file that osapi undeployedpath=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, state=unmanaged

Method update​

Nameupdate
Verbwrite
DescriptionDeploy an object of the object store to a path
DetailWrites the object at the path with its mode and ownership, and keeps a record of it. A template object, or content_type template, is rendered first with .Facts, .Vars and .Hostname. The record keeps the SHA-256 of the object as it was read. A file that holds the content, mode and owner already, from the same object, does not change and reports changed: false. osapi client file stale list compares the object now with that SHA-256, so it shows the deployments whose object changed since.
HTTPPUT
Route/api/node/{hostname}/file
Permissionfile:write
Commandosapi client node file update
Input typeUpdateInput
Output typeUpdateResult

Input (7)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
object_namestringyesmin length 1, max length 255The object of the object store, from osapi client file list
pathstringyespattern ^/Absolute path of the file on the host
modestringnopattern ^[0-7]{3,4}$Permissions in octal, such as 0644; when empty, a file keeps its mode and a new file gets 0644
ownerstringnopattern ^[a-z_][a-z0-9_-]*$?$User that owns the file; left as written when empty
groupstringnopattern ^[a-z_][a-z0-9_-]*$?$Group that owns the file; left as written when empty
content_typestringnoone of raw templateHow the object is written: raw as it is, or template rendered with .Facts, .Vars and .Hostname; the object's own when empty
varsobjectnoVariables of a template, as .Vars, each as key=value

Output (3)​

FIELDTYPEDESCRIPTION
pathstringAbsolute path of the file
sha256stringSHA-256 of the content that the file holds
changedbooleanWhether the host changed

Examples (3)​

EXAMPLEINPUTOUTPUT
Deploy a fileobject_name=example.conf, path=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, sha256=0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60, changed=true
Render a templateobject_name=example.conf.tmpl, path=/etc/osapi/file-example.conf, vars=map[port:8080]path=/etc/osapi/file-example.conf, sha256=28ef41e1ff26302a25da25eaa7b2762f2d55d0fdc0631a4f6a8c380d2b8640d4, changed=true
A file that holds the objectobject_name=example.conf, path=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, sha256=0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60, changed=false

Method delete​

Namedelete
Verbwrite
DescriptionRemove a file that osapi deployed
DetailRemoves the file and keeps its record, marked undeployed, so status reports unmanaged. A path that osapi did not deploy, or deleted already, does not change and reports changed: false. The object stays in the object store.
HTTPDELETE
Route/api/node/{hostname}/file
Permissionfile:write
Commandosapi client node file delete
Input typeDeleteInput
Output typeDeleteResult

Input (1)​

FIELDTYPEREQUIREDCONSTRAINTSDESCRIPTION
pathstringyespattern ^/Absolute path of the file on the host

Output (2)​

FIELDTYPEDESCRIPTION
pathstringAbsolute path of the file
changedbooleanWhether the host changed

Examples (2)​

EXAMPLEINPUTOUTPUT
Remove a deployed filepath=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, changed=true
A path that osapi did not deploypath=/etc/osapi/file-example.confpath=/etc/osapi/file-example.conf, changed=false