Skip to main content

Get

Show whether a deployed file holds what osapi wrote.

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.

osapi client node file get [flags]

Examples​

# A deployed file
osapi client node file get --target web-01 --path /etc/osapi/file-example.conf

# A path that osapi did not deploy
osapi client node file get --target web-01 --path /etc/osapi/file-example.conf

# A file that osapi undeployed
osapi client node file get --target web-01 --path /etc/osapi/file-example.conf

Result​

A deployed file, on one host:

$ osapi client node file get --target web-01 --path /etc/osapi/file-example.conf
Results:
  HOSTNAME  STATUS  PATH                          STATE    SHA256
  web-01    ok      /etc/osapi/file-example.conf  in-sync  0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60

  1 host: 1 ok   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node file get --target _all --path /etc/osapi/file-example.conf
Results:
  HOSTNAME  STATUS  PATH                          STATE    SHA256
  web-01    ok      /etc/osapi/file-example.conf  in-sync  0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60
  web-02    ok      /etc/osapi/file-example.conf  in-sync  0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60

  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": [
{
"hostname": "web-01",
"path": "/etc/osapi/file-example.conf",
"sha256": "0083dacc561dfd01081d8554269e201f4b60fe597ab9892977bfde81da46ef60",
"state": "in-sync",
"status": "ok"
}
]
}

A path that osapi did not deploy, on one host:

$ osapi client node file get --target web-01 --path /etc/osapi/file-example.conf
Results:
  HOSTNAME  STATUS  PATH                          STATE      SHA256
  web-01    ok      /etc/osapi/file-example.conf  unmanaged

  1 host: 1 ok   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node file get --target _all --path /etc/osapi/file-example.conf
Results:
  HOSTNAME  STATUS  PATH                          STATE      SHA256
  web-01    ok      /etc/osapi/file-example.conf  unmanaged
  web-02    ok      /etc/osapi/file-example.conf  unmanaged

  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": [
{
"hostname": "web-01",
"path": "/etc/osapi/file-example.conf",
"state": "unmanaged",
"status": "ok"
}
]
}

A file that osapi undeployed, on one host:

$ osapi client node file get --target web-01 --path /etc/osapi/file-example.conf
Results:
  HOSTNAME  STATUS  PATH                          STATE      SHA256
  web-01    ok      /etc/osapi/file-example.conf  unmanaged

  1 host: 1 ok   job 550e8400-e29b-41d4-a716-446655440000   trace 26e448c9dbe1c4a8d216a98c675079c9

On each host, where one cannot run it:

$ osapi client node file get --target _all --path /etc/osapi/file-example.conf
Results:
  HOSTNAME  STATUS  PATH                          STATE      SHA256
  web-01    ok      /etc/osapi/file-example.conf  unmanaged
  web-02    ok      /etc/osapi/file-example.conf  unmanaged

  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": [
{
"hostname": "web-01",
"path": "/etc/osapi/file-example.conf",
"state": "unmanaged",
"status": "ok"
}
]
}

The command fails in these cases:

CallFlagsFails with
A relative path--path etc/example.confstartswith
A directory--path /tmpa directory, not a file

Permission​

It needs the file:read permission. osapi controller role get --name <role> shows what a role grants.

Flags​

FlagDescriptionDefault
--pathAbsolute path of the file on the host (required)
-T, --targetTarget: _all, _any, hostname, or label (group:web.dev)_all

Global flags​

FlagDescriptionDefault
-d, --debugEnable or disable debug mode
-j, --jsonEnable JSON output
-f, --osapi-filePath to config file; without one at the default path, osapi runs on the defaults/etc/osapi/osapi.yaml
--urlBase URL the CLI client connects to (controller.client.url)https://localhost:8080

Output tells how the result is printed, and what --json gives.