Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Group = endpoint.Define( "file", "Files of the object store, deployed to the host", endpoint.Area(area.Config), endpoint.Prefix("node/{hostname}"), endpoint.Uses[dispatch.Deps](), endpoint.Tag("file_operations", "File", "Files of the object store, deployed to the host"), endpoint.CommandNotes("The [file behavior](../../../../../reference/behaviors/config/file/file.md) page tells where the behavior runs, what it is built on and its settings."), endpoint.Doc[types.RowStatus](dispatch.RowStatusDoc), endpoint.Get[GetRequest, FileGetResponse]("get"). Handle(HandleGet). ID("GetNodeFile"). Describe("Show whether a deployed file holds what osapi wrote"). Permission("file:read"). Returns("Each target host's result."). Explain("Compares 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."). Example("--target web-01 --path /etc/osapi/file-example.conf", "A deployed file"). Example("--target web-01 --path /etc/osapi/file-example.conf", "A path that osapi did not deploy"). Example("--target web-01 --path /etc/osapi/file-example.conf", "A file that osapi undeployed"). Result("A deployed file, on one host:\n\n```ansi\n$ osapi client node file get --target web-01 --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSTATE \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf in-sync 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n\n 1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file get --target _all --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSTATE \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf in-sync 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf in-sync 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n\n 3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"sha256\": \"0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\",\n \"state\": \"in-sync\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nA path that osapi did not deploy, on one host:\n\n```ansi\n$ osapi client node file get --target web-01 --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSTATE \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf unmanaged \n\n 1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file get --target _all --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSTATE \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf unmanaged \n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf unmanaged \n\n 3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"state\": \"unmanaged\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nA file that osapi undeployed, on one host:\n\n```ansi\n$ osapi client node file get --target web-01 --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSTATE \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf unmanaged \n\n 1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file get --target _all --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSTATE \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf unmanaged \n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf unmanaged \n\n 3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"state\": \"unmanaged\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A relative path | `--path etc/example.conf` | startswith |\n| A directory | `--path /tmp` | a directory, not a file |"). Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")), endpoint.Put[UpdateRequest, FileUpdateResponse]("update"). Handle(HandleUpdate). ID("PutNodeFile"). Describe("Deploy an object of the object store to a path"). Permission("file:write"). Returns("Each target host's result, with whether it changed."). Explain("Writes 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."). Example("--target web-01 --object-name example.conf --path /etc/osapi/file-example.conf", "Deploy a file"). Example("--target web-01 --object-name example.conf.tmpl --path /etc/osapi/file-example.conf --vars port=8080", "Render a template"). Example("--target web-01 --object-name example.conf --path /etc/osapi/file-example.conf", "A file that holds the object"). Result("Deploy a file, on one host:\n\n```ansi\n$ osapi client node file update --target web-01 --object-name example.conf --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n\n 1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file update --target _all --object-name example.conf --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n\n 3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"changed\": true,\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"sha256\": \"0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nRender a template, on one host:\n\n```ansi\n$ osapi client node file update --target web-01 --object-name example.conf.tmpl --path /etc/osapi/file-example.conf --vars port=8080\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf 28ef41e1ff26302a25da25eaa7b2762f2d55d0fdc0631a4f6a8c380d2b8640d4\n\n 1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file update --target _all --object-name example.conf.tmpl --path /etc/osapi/file-example.conf --vars port=8080\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf 28ef41e1ff26302a25da25eaa7b2762f2d55d0fdc0631a4f6a8c380d2b8640d4\n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf 28ef41e1ff26302a25da25eaa7b2762f2d55d0fdc0631a4f6a8c380d2b8640d4\n\n 3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"changed\": true,\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"sha256\": \"28ef41e1ff26302a25da25eaa7b2762f2d55d0fdc0631a4f6a8c380d2b8640d4\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nA file that holds the object, on one host:\n\n```ansi\n$ osapi client node file update --target web-01 --object-name example.conf --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n\n 1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file update --target _all --object-name example.conf --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH \x1b[0m\x1b[38;2;10;143;176mSHA256\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf 0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\n\n 3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"changed\": false,\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"sha256\": \"0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nWith the default settings, each example does this on the host:\n\n| Example | On the host |\n| --- | --- |\n| Deploy a file | writes `/etc/osapi/file-example.conf`: `listen 8080` |\n| Render a template | writes `/etc/osapi/file-example.conf`: `host test-host port 8080` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A relative path | `--object-name example.conf --path etc/x` | startswith |\n| No object | `--path /etc/osapi/file-example.conf` | required |\n| A mode that is not octal | `--object-name example.conf --path /etc/osapi/file-example.conf --mode rw-r--r--` | file_mode |\n| An object name longer than 255 characters | `--object-name aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa --path /etc/osapi/file-example.conf` | max |\n| A group that is an option | `--object-name example.conf --path /etc/osapi/file-example.conf --group -r` | account_name |\n| An owner that is an option | `--object-name example.conf --path /etc/osapi/file-example.conf --owner -r` | account_name |\n| A content type that is neither | `--object-name example.conf --path /etc/osapi/file-example.conf --content-type zip` | enum |"). Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")), endpoint.Delete[DeleteRequest, FileDeleteResponse]("delete"). Handle(HandleDelete). ID("DeleteNodeFile"). Describe("Remove a file that osapi deployed"). Permission("file:write"). Returns("Each target host's result, with whether it changed."). Explain("Removes 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."). Example("--target web-01 --path /etc/osapi/file-example.conf", "Remove a deployed file"). Example("--target web-01 --path /etc/osapi/file-example.conf", "A path that osapi did not deploy"). Result("Remove a deployed file, on one host:\n\n```ansi\n$ osapi client node file delete --target web-01 --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf\n\n 1 host: \x1b[38;2;103;234;147m1 changed\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file delete --target _all --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf\n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mchanged\x1b[0m /etc/osapi/file-example.conf\n\n 3 hosts: \x1b[38;2;103;234;147m2 changed\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"changed\": true,\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nA path that osapi did not deploy, on one host:\n\n```ansi\n$ osapi client node file delete --target web-01 --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf\n\n 1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node file delete --target _all --path /etc/osapi/file-example.conf\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n \x1b[38;2;10;143;176mHOSTNAME \x1b[0m\x1b[38;2;10;143;176mSTATUS \x1b[0m\x1b[38;2;10;143;176mPATH\x1b[0m\n \x1b[1mweb-01\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf\n \x1b[1mweb-02\x1b[0m \x1b[38;2;103;234;147mok\x1b[0m /etc/osapi/file-example.conf\n\n 3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n \x1b[1mmac-01\x1b[0m \x1b[38;5;222mskipped\x1b[0m operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"results\": [\n {\n \"changed\": false,\n \"hostname\": \"web-01\",\n \"path\": \"/etc/osapi/file-example.conf\",\n \"status\": \"ok\"\n }\n ]\n}\n```\n\nWith the default settings, each example does this on the host:\n\n| Example | On the host |\n| --- | --- |\n| Remove a deployed file | removes `/etc/osapi/file-example.conf` |\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| A relative path | `--path etc/x` | startswith |"). Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")), )
Group is file as an endpoint group, which its spec comes from.
Functions ¶
Types ¶
type DeleteRequest ¶
type DeleteRequest struct {
Hostname string `` /* 182-byte string literal not displayed */
Body FileDeleteRequest `in:"body" validate:"required"`
}
DeleteRequest is the request of file delete: its target and its input.
type FileDeleteRequest ¶
type FileDeleteRequest struct {
Path string `doc:"Absolute path of the file on the host" json:"path" validate:"required,startswith=/"`
}
FileDeleteRequest is the body of file delete.
type FileDeleteResponse ¶
type FileDeleteResponse struct {
JobID string `` /* 133-byte string literal not displayed */
Results []FileDeleteResult `json:"results"`
}
FileDeleteResponse is each target host's result.
func HandleDelete ¶
func HandleDelete( ctx context.Context, d dispatch.Deps, in DeleteRequest, ) (FileDeleteResponse, error)
HandleDelete runs file delete on the target, for the endpoint server.
type FileDeleteResult ¶
type FileDeleteResult struct {
Hostname string `doc:"Hostname of the agent that produced this result." json:"hostname"`
Status types.RowStatus `doc:"The status of the operation for this host." json:"status"`
Path *string `doc:"Absolute path of the file" json:"path,omitempty"`
Changed *bool `doc:"Whether the host changed" json:"changed,omitempty"`
Error *string `doc:"Error message if the agent failed." json:"error,omitempty"`
}
FileDeleteResult is the result of file on one host.
type FileGetResponse ¶
type FileGetResponse struct {
JobID string `` /* 133-byte string literal not displayed */
Results []FileStatus `json:"results"`
}
FileGetResponse is each target host's result.
func HandleGet ¶
func HandleGet( ctx context.Context, d dispatch.Deps, in GetRequest, ) (FileGetResponse, error)
HandleGet runs file get on the target, for the endpoint server.
type FileStatus ¶
type FileStatus struct {
Hostname string `doc:"Hostname of the agent that produced this result." json:"hostname"`
Status types.RowStatus `doc:"The status of the operation for this host." json:"status"`
Path *string `doc:"Absolute path of the file" json:"path,omitempty"`
State *string `doc:"in-sync, drifted, missing or unmanaged" json:"state,omitempty"`
SHA256 *string `doc:"SHA-256 of the file on the host, when it is there" json:"sha256,omitempty"`
Error *string `doc:"Error message if the agent failed." json:"error,omitempty"`
}
FileStatus is the result of file on one host.
type FileUpdateRequest ¶
type FileUpdateRequest struct {
ObjectName string `doc:"The object of the object store, from osapi client file list" json:"object_name" validate:"required,min=1,max=255"`
Path string `doc:"Absolute path of the file on the host" json:"path" validate:"required,startswith=/"`
Mode string `` /* 153-byte string literal not displayed */
Owner string `doc:"User that owns the file; left as written when empty" json:"owner,omitempty" validate:"omitempty,account_name"`
Group string `doc:"Group that owns the file; left as written when empty" json:"group,omitempty" validate:"omitempty,account_name"`
ContentType types.ContentType `` /* 185-byte string literal not displayed */
Vars map[string]string `doc:"Variables of a template, as .Vars, each as key=value" json:"vars,omitempty" validate:"omitempty"`
}
FileUpdateRequest is the body of file update.
type FileUpdateResponse ¶
type FileUpdateResponse struct {
JobID string `` /* 133-byte string literal not displayed */
Results []FileUpdateResult `json:"results"`
}
FileUpdateResponse is each target host's result.
func HandleUpdate ¶
func HandleUpdate( ctx context.Context, d dispatch.Deps, in UpdateRequest, ) (FileUpdateResponse, error)
HandleUpdate runs file update on the target, for the endpoint server.
type FileUpdateResult ¶
type FileUpdateResult struct {
Hostname string `doc:"Hostname of the agent that produced this result." json:"hostname"`
Status types.RowStatus `doc:"The status of the operation for this host." json:"status"`
Path *string `doc:"Absolute path of the file" json:"path,omitempty"`
SHA256 *string `doc:"SHA-256 of the content that the file holds" json:"sha256,omitempty"`
Changed *bool `doc:"Whether the host changed" json:"changed,omitempty"`
Error *string `doc:"Error message if the agent failed." json:"error,omitempty"`
}
FileUpdateResult is the result of file on one host.
type GetRequest ¶
type GetRequest struct {
Hostname string `` /* 182-byte string literal not displayed */
Path string `doc:"Absolute path of the file on the host" in:"query" json:"path" validate:"required,startswith=/"`
}
GetRequest is the request of file get: its target and its input.
type UpdateRequest ¶
type UpdateRequest struct {
Hostname string `` /* 182-byte string literal not displayed */
Body FileUpdateRequest `in:"body" validate:"required"`
}
UpdateRequest is the request of file update: its target and its input.