Created
March 16, 2024 08:48
-
-
Save MrModest/51af6967ead45485353fedcec730ef75 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class Playbook( | |
val name: String, | |
val hosts: Host[], | |
val remoteUser: User, | |
val varFiles: File[], | |
val vars: ObjectNode // need valitation so root will be only Map | |
val tasks: Task[] | |
) | |
sealed class ObjectNode { | |
data class String(val value: String) : ObjectNode() | |
data class Number(val value: Number) : ObjectNode() | |
data class Map(val map: Map<String, ObjectNode>) : ObjectNode() | |
data class List(vararg list: List<ObjectNode>) : ObjectNode() | |
} | |
sealed class Node { | |
data class String(val pair: Pair<String, String>) : Node() | |
data class Number(val pair: Pair<String, Number>) : Node() | |
data class List(vararg pair: Pair<String, Node>) | |
} | |
val node1 = Node.String("var1" to "val1") | |
val node2 = Node.List( | |
"name" to "app_name" | |
"version" to "1.2.3" | |
) | |
val node3 = Node.List( | |
"env_vars" | |
) | |
val vars = ObjectNode.Map( | |
"app_name" to ObjectNode.String("dockge"), | |
"app_port" to Variable.Number(5001), | |
"env_vars" to Variable.List( | |
ObjectNode.Map( | |
"key" to Variable.String("APP_DATA_PATH") | |
"value" to Variable.String("/path/to/app-data") | |
) | |
ObjectNode.Map( | |
"key" to Variable.String("STACKS_PATH") | |
"value" to Variable.String("/path/to/stack-path") | |
) | |
), | |
"app_user" to ObjectNode.Map( | |
"user" to ObjectNode.String("apps") | |
"group" to ObjectNode.String("apps") | |
) | |
) | |
data class Task( | |
val name: String, | |
val module: Module, | |
val vars: Variable[] | |
val tags: String[] | |
) | |
interface Module<TModuleParams>( | |
val collectionName: String, // 'Fully Qualified Collection Name (FQCN)' - for example, `ansible.builtin.shell` | |
val params: TModuleParams | |
) | |
// package com.github.MrModest.modules.ansible.builtin; | |
data class FileModule<FileModuleParams>( | |
val params: AnsibleBuiltinFileModuleParams | |
) { | |
override val collectionName: String = "ansible.builtin.file" | |
} | |
data class FileModuleParams( | |
val path: path, | |
val state: FileStateEnum, | |
val owner: User, | |
val group: UserGroup, | |
val mode: Permissions, | |
) | |
// END of package | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment