From 10e7fd1eff0bff2a0b0d854f060ece7d156d6fee Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Wed, 21 Jun 2023 15:02:13 +0000 Subject: [PATCH] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'How=20to=20create?= =?UTF-8?q?=20a=20new=20LXC'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- How-to-create-a-new-LXC.md | 343 ++++++++++++++++++++++++++++++++++++- 1 file changed, 340 insertions(+), 3 deletions(-) diff --git a/How-to-create-a-new-LXC.md b/How-to-create-a-new-LXC.md index d85ea8f..c0d7a6a 100644 --- a/How-to-create-a-new-LXC.md +++ b/How-to-create-a-new-LXC.md @@ -109,10 +109,11 @@ creation: - ``` -Types of conditions : +#### Types of conditions :
Programs +*Checks if a program is installed or not* ```yaml program: ``` @@ -128,6 +129,7 @@ programs:
Files +*Checks if a file exist or not* ```yaml file: ``` @@ -137,13 +139,13 @@ files: - - ``` - *You can use either ``file`` or ``files``, they do the same thing*
Folders +*Checks if a folder exist or not* ```yaml folder: ``` @@ -153,11 +155,346 @@ folders: - - ``` - *You can use either ``folder`` or ``folders``, they do the same thing*
+
+ Commands (TODO) + +*Checks if a command return the expected value* +```yaml +command: [ , ] +``` + +```yaml +commands: + - [ , ] + - [ , ] +``` +*You can use either ``command`` or ``commands``, they do the same thing* +
+ +
+ Docker containers (TODO) + +*Checks if a docker container exist or not* +```yaml +docker: +``` + +```yaml +docker: + - + - +``` +
+ ### Steps The steps are the actual commands that will be run during the creation or the deployment process. The steps are used in both the creation and the deploy process. + +#### A note about the different paths +When you have to specify a path, you can use the prefix ``/global/`` to use the root folder or your repo. (`/`) +If nothing is specified, the script will use the VM/LXC folder (`/lxc//`). + +#### Types of steps : + +
+ Scripts + +*Run a script from your repo* +```yaml +- type: script + path: +``` + +*Run a script from an online source* +```yaml +- type: script + url: +``` + +*Run a script from inside the LXC* +```yaml +- type: script + lxc_path: +``` +
+ +
+ Files + +*Create a file* +```yaml +- type: file_create + path: + permissions: + owner: +``` + +*Copy a file from your repo to the LXC* +```yaml +- type: file_copy + path: + destination: + permissions: + owner: +``` + +
+ +
+ Folders + +*Create a folder* +```yaml +- type: folder_create + path: + permissions: + owner: +``` + +*Copy a folder from your repo to the LXC* +```yaml +- type: folder_copy + path: + destination: + permissions: + owner: +``` +*Note: `folder_copy` creates the folder if it doesn't exist* +
+ +
+ Commands + +*Run a command inside the LXC* +```yaml +- type: command + command: +``` + +*Run multiples commands inside the LXC* +```yaml +- type: command + commands: + - + - +``` + +
+ +
+ Docker + +*Run a command inside a docker container* +```yaml +- type: docker + container: + command: +``` + +*Run multiples commands inside a docker container (TODO)* +```yaml +- type: docker + container: + commands: + - + - +``` +
+ +
+ Docker Compose + +*Run a docker compose command* +```yaml +- type: docker_compose + command: # ex: up -d +``` +*Note : Here, why not use the `command` step? Docker Compose can sometimes be executed with `docker-compose` or `docker compose`, the script will take care of choosing the correct one using this method.* + +
+ +
+ Git + +*Clone a git repository (TODO)* +```yaml +- type: git_clone + url: + destination: +``` + +*Pull a git repository (TODO)* +```yaml +- type: git_pull + path: +``` + +
+ +
+ Download + +*Download a file* +```yaml +- type: download + url: + destination: +``` + +*Download multiple files* +```yaml +- type: download + url: + - + - + destination: +``` + +
+ +
+ Packages + +*Install a package (TOCHECK)* +```yaml +- type: install_package + package: +``` + +*Install multiple packages (TOCHECK)* +```yaml +- type: install_package + packages: + - + - +``` + +*Remove a package (TOCHECK)* +```yaml +- type: remove_package + package: +``` + +*Remove multiple packages (TOCHECK)* +```yaml +- type: remove_package + packages: + - + - +``` + +*Note : all major package manager should be supported* +*Warning : Packages can have different names depending on the Linux distribution.* + +
+ +
+ Power + +*Reboot the LXC* +```yaml +- type: reboot +``` + +*Shutdown the LXC* +```yaml +- type: shutdown +``` + +*Start the LXC (should usually never be used)* +```yaml +- type: start +``` +
+ +
+ Services (TODO) + +*Start a service* +```yaml +- type: service_start + service: +``` + +*Stop a service* +```yaml +- type: service_stop + service: +``` + +*Restart a service* +```yaml +- type: service_restart + service: +``` + +*Enable a service* +```yaml +- type: service_enable + service: +``` + +*Disable a service* +```yaml +- type: service_disable + service: +``` + +*Note: should support systemd and openrc* + +
+ +
+ Replace in file (TODO) + +*Replace a string in a file* +```yaml +- type: replace_in_file + path: + search: + replace: + case_sensitive: +``` + +*Replace a string in multiple files* +```yaml +- type: replace_in_file + path: + - + - + search: + replace: + case_sensitive: +``` + +
+ +
+ Unzip + +*Unzip a file* +```yaml +- type: unzip + path: + destination: +``` +*Note: supports zip and tar.gz files* + +
+ +
+ Wait (TODO) + +*Wait X seconds* +```yaml +- type: wait + seconds: +``` + +
+ +