Mise à jour de 'How to create a new LXC'

Mathieu Broillet 2023-06-21 15:02:13 +00:00
parent 8b4ddd9ba2
commit 10e7fd1eff

@ -109,10 +109,11 @@ creation:
- <name of program> - <name of program>
``` ```
Types of conditions : #### Types of conditions :
<details> <details>
<summary>Programs</summary> <summary>Programs</summary>
*Checks if a program is installed or not*
```yaml ```yaml
program: <name of program> program: <name of program>
``` ```
@ -128,6 +129,7 @@ programs:
<details> <details>
<summary>Files</summary> <summary>Files</summary>
*Checks if a file exist or not*
```yaml ```yaml
file: <name of program> file: <name of program>
``` ```
@ -137,13 +139,13 @@ files:
- <path to file 1> - <path to file 1>
- <path to file 2> - <path to file 2>
``` ```
*You can use either ``file`` or ``files``, they do the same thing* *You can use either ``file`` or ``files``, they do the same thing*
</details> </details>
<details> <details>
<summary>Folders</summary> <summary>Folders</summary>
*Checks if a folder exist or not*
```yaml ```yaml
folder: <name of program> folder: <name of program>
``` ```
@ -153,11 +155,346 @@ folders:
- <path to folder 1> - <path to folder 1>
- <path to folder 2> - <path to folder 2>
``` ```
*You can use either ``folder`` or ``folders``, they do the same thing* *You can use either ``folder`` or ``folders``, they do the same thing*
</details> </details>
<details>
<summary>Commands (TODO) </summary>
*Checks if a command return the expected value*
```yaml
command: [ <command to run>, <value expected> ]
```
```yaml
commands:
- [ <command to run 1>, <value expected 1> ]
- [ <command to run 2>, <value expected 2> ]
```
*You can use either ``command`` or ``commands``, they do the same thing*
</details>
<details>
<summary>Docker containers (TODO) </summary>
*Checks if a docker container exist or not*
```yaml
docker: <name of docker container>
```
```yaml
docker:
- <name of docker container 1>
- <name of docker container 2>
```
</details>
### Steps ### Steps
The steps are the actual commands that will be run during the creation or the deployment process. 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. 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. (`<repo>/`)
If nothing is specified, the script will use the VM/LXC folder (`<repo>/lxc/<id>/`).
#### Types of steps :
<details>
<summary>Scripts</summary>
*Run a script from your repo*
```yaml
- type: script
path: <path to script>
```
*Run a script from an online source*
```yaml
- type: script
url: <url to script>
```
*Run a script from inside the LXC*
```yaml
- type: script
lxc_path: <path to script inside the lxc>
```
</details>
<details>
<summary>Files</summary>
*Create a file*
```yaml
- type: file_create
path: <path to file>
permissions: <permission of the file, default 644>
owner: <owner of the file, default root:root>
```
*Copy a file from your repo to the LXC*
```yaml
- type: file_copy
path: <path to file>
destination: <path to file inside the lxc>
permissions: <permission of the file, default 644>
owner: <owner of the file, default root:root>
```
</details>
<details>
<summary>Folders</summary>
*Create a folder*
```yaml
- type: folder_create
path: <path to folder>
permissions: <permission of the folder, default 755>
owner: <owner of the folder, default root:root>
```
*Copy a folder from your repo to the LXC*
```yaml
- type: folder_copy
path: <path to folder>
destination: <path to folder inside the lxc>
permissions: <permission of the folder, default 755>
owner: <owner of the folder, default root:root>
```
*Note: `folder_copy` creates the folder if it doesn't exist*
</details>
<details>
<summary>Commands</summary>
*Run a command inside the LXC*
```yaml
- type: command
command: <command to run>
```
*Run multiples commands inside the LXC*
```yaml
- type: command
commands:
- <command to run 1>
- <command to run 2>
```
</details>
<details>
<summary>Docker</summary>
*Run a command inside a docker container*
```yaml
- type: docker
container: <name of docker container>
command: <command to run>
```
*Run multiples commands inside a docker container (TODO)*
```yaml
- type: docker
container: <name of docker container>
commands:
- <command to run 1>
- <command to run 2>
```
</details>
<details>
<summary>Docker Compose</summary>
*Run a docker compose command*
```yaml
- type: docker_compose
command: <command to run> # 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.*
</details>
<details>
<summary>Git</summary>
*Clone a git repository (TODO)*
```yaml
- type: git_clone
url: <url of the git repository>
destination: <path to the folder where the repo will be cloned>
```
*Pull a git repository (TODO)*
```yaml
- type: git_pull
path: <path to the git repository>
```
</details>
<details>
<summary>Download</summary>
*Download a file*
```yaml
- type: download
url: <url of the file>
destination: <path to the folder where the file will be downloaded>
```
*Download multiple files*
```yaml
- type: download
url:
- <url of the file 1>
- <url of the file 2>
destination: <path to the folder where the files will be downloaded>
```
</details>
<details>
<summary>Packages</summary>
*Install a package (TOCHECK)*
```yaml
- type: install_package
package: <name of the package>
```
*Install multiple packages (TOCHECK)*
```yaml
- type: install_package
packages:
- <name of the package 1>
- <name of the package 2>
```
*Remove a package (TOCHECK)*
```yaml
- type: remove_package
package: <name of the package>
```
*Remove multiple packages (TOCHECK)*
```yaml
- type: remove_package
packages:
- <name of the package 1>
- <name of the package 2>
```
*Note : all major package manager should be supported*
*Warning : Packages can have different names depending on the Linux distribution.*
</details>
<details>
<summary>Power</summary>
*Reboot the LXC*
```yaml
- type: reboot
```
*Shutdown the LXC*
```yaml
- type: shutdown
```
*Start the LXC (should usually never be used)*
```yaml
- type: start
```
</details>
<details>
<summary>Services (TODO)</summary>
*Start a service*
```yaml
- type: service_start
service: <name of the service>
```
*Stop a service*
```yaml
- type: service_stop
service: <name of the service>
```
*Restart a service*
```yaml
- type: service_restart
service: <name of the service>
```
*Enable a service*
```yaml
- type: service_enable
service: <name of the service>
```
*Disable a service*
```yaml
- type: service_disable
service: <name of the service>
```
*Note: should support systemd and openrc*
</details>
<details>
<summary>Replace in file (TODO)</summary>
*Replace a string in a file*
```yaml
- type: replace_in_file
path: <path to the file>
search: <string to search>
replace: <string to replace>
case_sensitive: <true or false, default true>
```
*Replace a string in multiple files*
```yaml
- type: replace_in_file
path:
- <path to the file 1>
- <path to the file 2>
search: <string to search>
replace: <string to replace>
case_sensitive: <true or false, default true>
```
</details>
<details>
<summary>Unzip</summary>
*Unzip a file*
```yaml
- type: unzip
path: <path to the file>
destination: <path to the folder where the file will be unzipped>
```
*Note: supports zip and tar.gz files*
</details>
<details>
<summary>Wait (TODO)</summary>
*Wait X seconds*
```yaml
- type: wait
seconds: <number of seconds to wait>
```
</details>