os_policy.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. // Copyright 2021 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.osconfig.agentendpoint.v1;
  16. import "google/api/field_behavior.proto";
  17. option go_package = "google.golang.org/genproto/googleapis/cloud/osconfig/agentendpoint/v1;agentendpoint";
  18. option java_multiple_files = true;
  19. option java_outer_classname = "OSPolicyProto";
  20. option java_package = "com.google.cloud.osconfig.agentendpoint.v1";
  21. // An OS policy defines the desired state configuration for an instance.
  22. message OSPolicy {
  23. // An OS policy resource is used to define the desired state configuration
  24. // and provides a specific functionality like installing/removing packages,
  25. // executing a script etc.
  26. //
  27. // The system ensures that resources are always in their desired state by
  28. // taking necessary actions if they have drifted from their desired state.
  29. message Resource {
  30. // A remote or local file.
  31. message File {
  32. // Specifies a file available via some URI.
  33. message Remote {
  34. // Required. URI from which to fetch the object. It should contain both
  35. // the protocol and path following the format `{protocol}://{location}`.
  36. string uri = 1 [(google.api.field_behavior) = REQUIRED];
  37. // SHA256 checksum of the remote file.
  38. string sha256_checksum = 2;
  39. }
  40. // Specifies a file available as a Cloud Storage Object.
  41. message Gcs {
  42. // Required. Bucket of the Cloud Storage object.
  43. string bucket = 1 [(google.api.field_behavior) = REQUIRED];
  44. // Required. Name of the Cloud Storage object.
  45. string object = 2 [(google.api.field_behavior) = REQUIRED];
  46. // Generation number of the Cloud Storage object.
  47. int64 generation = 3;
  48. }
  49. // A specific type of file.
  50. oneof type {
  51. // A generic remote file.
  52. Remote remote = 1;
  53. // A Cloud Storage object.
  54. Gcs gcs = 2;
  55. // A local path to use.
  56. string local_path = 3;
  57. }
  58. // Defaults to false. When false, files are subject to validations
  59. // based on the file type:
  60. //
  61. // Remote: A checksum must be specified.
  62. // Cloud Storage: An object generation number must be specified.
  63. bool allow_insecure = 4;
  64. }
  65. // A resource that manages a system package.
  66. message PackageResource {
  67. // A deb package file. dpkg packages only support INSTALLED state.
  68. message Deb {
  69. // Required. A deb package.
  70. File source = 1 [(google.api.field_behavior) = REQUIRED];
  71. // Whether dependencies should also be installed.
  72. // install when false: `dpkg -i package`
  73. // install when true: `apt-get update && apt-get -y install
  74. // package.deb`
  75. bool pull_deps = 2;
  76. }
  77. // A package managed by APT.
  78. // install: `apt-get update && apt-get -y install [name]`
  79. // remove: `apt-get -y remove [name]`
  80. message APT {
  81. // Required. Package name.
  82. string name = 1 [(google.api.field_behavior) = REQUIRED];
  83. }
  84. // An RPM package file. RPM packages only support INSTALLED state.
  85. message RPM {
  86. // Required. An rpm package.
  87. File source = 1 [(google.api.field_behavior) = REQUIRED];
  88. // Whether dependencies should also be installed.
  89. // install when false: `rpm --upgrade --replacepkgs package.rpm`
  90. // install when true: `yum -y install package.rpm` or
  91. // `zypper -y install package.rpm`
  92. bool pull_deps = 2;
  93. }
  94. // A package managed by YUM.
  95. // install: `yum -y install package`
  96. // remove: `yum -y remove package`
  97. message YUM {
  98. // Required. Package name.
  99. string name = 1 [(google.api.field_behavior) = REQUIRED];
  100. }
  101. // A package managed by Zypper.
  102. // install: `zypper -y install package`
  103. // remove: `zypper -y rm package`
  104. message Zypper {
  105. // Required. Package name.
  106. string name = 1 [(google.api.field_behavior) = REQUIRED];
  107. }
  108. // A package managed by GooGet.
  109. // install: `googet -noconfirm install package`
  110. // remove: `googet -noconfirm remove package`
  111. message GooGet {
  112. // Required. Package name.
  113. string name = 1 [(google.api.field_behavior) = REQUIRED];
  114. }
  115. // An MSI package. MSI packages only support INSTALLED state.
  116. message MSI {
  117. // Required. The MSI package.
  118. File source = 1 [(google.api.field_behavior) = REQUIRED];
  119. // Additional properties to use during installation.
  120. // This should be in the format of Property=Setting.
  121. // Appended to the defaults of "ACTION=INSTALL
  122. // REBOOT=ReallySuppress".
  123. repeated string properties = 2;
  124. }
  125. // The desired state that the OS Config agent maintains on the VM.
  126. enum DesiredState {
  127. // Unspecified is invalid.
  128. DESIRED_STATE_UNSPECIFIED = 0;
  129. // Ensure that the package is installed.
  130. INSTALLED = 1;
  131. // The agent ensures that the package is not installed and
  132. // uninstalls it if detected.
  133. REMOVED = 2;
  134. }
  135. // Required. The desired state the agent should maintain for this package.
  136. // The default is to ensure the package is installed.
  137. DesiredState desired_state = 1 [(google.api.field_behavior) = REQUIRED];
  138. // A system package.
  139. oneof system_package {
  140. // A package managed by Apt.
  141. APT apt = 2;
  142. // A deb package file.
  143. Deb deb = 3;
  144. // A package managed by YUM.
  145. YUM yum = 4;
  146. // A package managed by Zypper.
  147. Zypper zypper = 5;
  148. // An rpm package file.
  149. RPM rpm = 6;
  150. // A package managed by GooGet.
  151. GooGet googet = 7;
  152. // An MSI package.
  153. MSI msi = 8;
  154. }
  155. }
  156. // A resource that manages a package repository.
  157. message RepositoryResource {
  158. // Represents a single apt package repository. These will be added to
  159. // a repo file that will be managed at
  160. // /etc/apt/sources.list.d/google_osconfig.list.
  161. message AptRepository {
  162. // Type of archive.
  163. enum ArchiveType {
  164. // Unspecified is invalid.
  165. ARCHIVE_TYPE_UNSPECIFIED = 0;
  166. // Deb indicates that the archive contains binary files.
  167. DEB = 1;
  168. // Deb-src indicates that the archive contains source files.
  169. DEB_SRC = 2;
  170. }
  171. // Required. Type of archive files in this repository. The default
  172. // behavior is DEB.
  173. ArchiveType archive_type = 1 [(google.api.field_behavior) = REQUIRED];
  174. // Required. URI for this repository.
  175. string uri = 2 [(google.api.field_behavior) = REQUIRED];
  176. // Required. Distribution of this repository.
  177. string distribution = 3 [(google.api.field_behavior) = REQUIRED];
  178. // Required. List of components for this repository. Must contain at
  179. // least one item.
  180. repeated string components = 4 [(google.api.field_behavior) = REQUIRED];
  181. // URI of the key file for this repository. The agent maintains a
  182. // keyring at /etc/apt/trusted.gpg.d/osconfig_agent_managed.gpg.
  183. string gpg_key = 5;
  184. }
  185. // Represents a single yum package repository. These are added to a
  186. // repo file that is managed at
  187. // `/etc/yum.repos.d/google_osconfig.repo`.
  188. message YumRepository {
  189. // Required. A one word, unique name for this repository. This is the
  190. // `repo id` in the yum config file and also the `display_name` if
  191. // `display_name` is omitted. This id is also used as the unique
  192. // identifier when checking for resource conflicts.
  193. string id = 1 [(google.api.field_behavior) = REQUIRED];
  194. // The display name of the repository.
  195. string display_name = 2;
  196. // Required. The location of the repository directory.
  197. string base_url = 3 [(google.api.field_behavior) = REQUIRED];
  198. // URIs of GPG keys.
  199. repeated string gpg_keys = 4;
  200. }
  201. // Represents a single zypper package repository. These are added to a
  202. // repo file that is managed at
  203. // `/etc/zypp/repos.d/google_osconfig.repo`.
  204. message ZypperRepository {
  205. // Required. A one word, unique name for this repository. This is the
  206. // `repo id` in the zypper config file and also the `display_name` if
  207. // `display_name` is omitted. This id is also used as the unique
  208. // identifier when checking for GuestPolicy conflicts.
  209. string id = 1 [(google.api.field_behavior) = REQUIRED];
  210. // The display name of the repository.
  211. string display_name = 2;
  212. // Required. The location of the repository directory.
  213. string base_url = 3 [(google.api.field_behavior) = REQUIRED];
  214. // URIs of GPG keys.
  215. repeated string gpg_keys = 4;
  216. }
  217. // Represents a Goo package repository. These are added to a repo file
  218. // that is managed at
  219. // `C:/ProgramData/GooGet/repos/google_osconfig.repo`.
  220. message GooRepository {
  221. // Required. The name of the repository.
  222. string name = 1 [(google.api.field_behavior) = REQUIRED];
  223. // Required. The url of the repository.
  224. string url = 2 [(google.api.field_behavior) = REQUIRED];
  225. }
  226. // A specific type of repository.
  227. oneof repository {
  228. // An Apt Repository.
  229. AptRepository apt = 1;
  230. // A Yum Repository.
  231. YumRepository yum = 2;
  232. // A Zypper Repository.
  233. ZypperRepository zypper = 3;
  234. // A Goo Repository.
  235. GooRepository goo = 4;
  236. }
  237. }
  238. // A resource that contains custom validation and enforcement steps.
  239. message ExecResource {
  240. // A file or script to execute.
  241. message Exec {
  242. // The interpreter to use.
  243. enum Interpreter {
  244. // Defaults to NONE.
  245. INTERPRETER_UNSPECIFIED = 0;
  246. // If no interpreter is specified the
  247. // source will be executed directly, which will likely only
  248. // succeed for executables and scripts with shebang lines.
  249. // [Wikipedia
  250. // shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)).
  251. NONE = 1;
  252. // Indicates that the script will be run with /bin/sh on Linux and
  253. // cmd.exe on windows.
  254. SHELL = 2;
  255. // Indicates that the script will be run with powershell.
  256. POWERSHELL = 3;
  257. }
  258. // What to execute.
  259. oneof source {
  260. // A remote or local file.
  261. File file = 1;
  262. // An inline script.
  263. string script = 2;
  264. }
  265. // Optional arguments to pass to the source during execution.
  266. repeated string args = 3;
  267. // Required. The script interpreter to use.
  268. Interpreter interpreter = 4 [(google.api.field_behavior) = REQUIRED];
  269. // Only recorded for enforce Exec.
  270. // Path to an output file (that is created by this Exec) whose
  271. // content will be recorded in OSPolicyResourceCompliance after a
  272. // successful run. Absence or failure to read this file will result in
  273. // this ExecResource being non-compliant. Output file size is limited to
  274. // 100K bytes.
  275. string output_file_path = 5;
  276. }
  277. // Required. What to run to validate this resource is in the desired
  278. // state. An exit code of 100 indicates "in desired state", and exit code
  279. // of 101 indicates "not in desired state". Any other exit code indicates
  280. // a failure running validate.
  281. Exec validate = 1 [(google.api.field_behavior) = REQUIRED];
  282. // What to run to bring this resource into the desired state.
  283. // A exit code of 100 indicates "success", any other exit code idicates a
  284. // failure running enforce.
  285. Exec enforce = 2;
  286. }
  287. // A resource that manages the state of a file.
  288. message FileResource {
  289. // Desired state of the file.
  290. enum DesiredState {
  291. // Unspecified is invalid.
  292. DESIRED_STATE_UNSPECIFIED = 0;
  293. // Ensure file at path is present.
  294. PRESENT = 1;
  295. // Ensure file at path is absent.
  296. ABSENT = 2;
  297. // Ensure the contents of the file at path matches. If the file does
  298. // not exist it will be created.
  299. CONTENTS_MATCH = 3;
  300. }
  301. // The source for the contents of the file.
  302. oneof source {
  303. // A remote or local source.
  304. File file = 1;
  305. // A a file with this content.
  306. string content = 2;
  307. }
  308. // Required. The absolute path of the file.
  309. string path = 3 [(google.api.field_behavior) = REQUIRED];
  310. // Required. Desired state of the file.
  311. DesiredState state = 4 [(google.api.field_behavior) = REQUIRED];
  312. // Consists of three octal digits which represent, in
  313. // order, the permissions of the owner, group, and other users for the
  314. // file (similarly to the numeric mode used in the linux chmod
  315. // utility). Each digit represents a three bit number with the 4 bit
  316. // corresponding to the read permissions, the 2 bit corresponds to the
  317. // write bit, and the one bit corresponds to the execute permission.
  318. // Default behavior is 755.
  319. //
  320. // Below are some examples of permissions and their associated values:
  321. // read, write, and execute: 7
  322. // read and execute: 5
  323. // read and write: 6
  324. // read only: 4
  325. string permissions = 5;
  326. }
  327. // Required. The id of the resource with the following restrictions:
  328. //
  329. // * Must contain only lowercase letters, numbers, and hyphens.
  330. // * Must start with a letter.
  331. // * Must be between 1-63 characters.
  332. // * Must end with a number or a letter.
  333. // * Must be unique within the OS policy.
  334. string id = 1 [(google.api.field_behavior) = REQUIRED];
  335. // Resource type.
  336. oneof resource_type {
  337. // Package resource
  338. PackageResource pkg = 2;
  339. // Package repository resource
  340. RepositoryResource repository = 3;
  341. // Exec resource
  342. ExecResource exec = 4;
  343. // File resource
  344. FileResource file = 5;
  345. }
  346. }
  347. // Policy mode
  348. enum Mode {
  349. // Invalid mode
  350. MODE_UNSPECIFIED = 0;
  351. // This mode checks if the configuration resources in the policy are in
  352. // their desired state. No actions are performed if they are not in the
  353. // desired state. This mode is used for reporting purposes.
  354. VALIDATION = 1;
  355. // This mode checks if the configuration resources in the policy are in
  356. // their desired state, and if not, enforces the desired state.
  357. ENFORCEMENT = 2;
  358. }
  359. }