Compare commits

...

2 Commits

Author SHA1 Message Date
655ecf21f4
update readme doc
All checks were successful
continuous-integration/drone/push Build is passing
2023-06-12 10:13:31 +02:00
8dca2e6eb6
remove .idea 2023-06-12 10:12:28 +02:00
9 changed files with 141 additions and 682 deletions

364
.idea/.gitignore vendored
View File

@ -1,364 +0,0 @@
# Created by https://www.toptal.com/developers/gitignore/api/python,intellij,jetbrains
# Edit at https://www.toptal.com/developers/gitignore?templates=python,intellij,jetbrains
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
# AWS User-specific
.idea/**/aws.xml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# SonarLint plugin
.idea/sonarlint/
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
.idea/**/sonarlint/
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
.idea/codestream.xml
# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
.idea/**/azureSettings.xml
### JetBrains ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
# AWS User-specific
# Generated files
# Sensitive or high-churn files
# Gradle
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr
# CMake
# Mongo Explorer plugin
# File-based project format
# IntelliJ
# mpeltonen/sbt-idea plugin
# JIRA plugin
# Cursive Clojure plugin
# SonarLint plugin
# Crashlytics plugin (for Android Studio and IntelliJ)
# Editor-based Rest Client
# Android studio 3.1+ serialized cache file
### JetBrains Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
# *.iml
# modules.xml
# .idea/misc.xml
# *.ipr
# Sonarlint plugin
# https://plugins.jetbrains.com/plugin/7973-sonarlint
# SonarQube Plugin
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
# Markdown Navigator plugin
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
# CodeStream plugin
# https://plugins.jetbrains.com/plugin/12206-codestream
# Azure Toolkit for IntelliJ plugin
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
.pybuilder/
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# Cython debug symbols
cython_debug/
# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml
# ruff
.ruff_cache/
# LSP config files
pyrightconfig.json
# End of https://www.toptal.com/developers/gitignore/api/python,intellij,jetbrains

View File

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11 (ProxmoxDeploy)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -1,12 +0,0 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPep8NamingInspection" enabled="true" level="WEAK WARNING" enabled_by_default="true">
<option name="ignoredErrors">
<list>
<option value="N802" />
</list>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (ProxmoxDeploy)" project-jdk-type="Python SDK" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/ProxmoxDeploy.iml" filepath="$PROJECT_DIR$/.idea/ProxmoxDeploy.iml" />
</modules>
</component>
</project>

View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

View File

@ -1,220 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="ef90a940-975e-45ac-b0cb-e18c5b09ff29" name="Changes" comment="update readme">
<change afterPath="$PROJECT_DIR$/resources/scripts/install-docker.sh" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/utils/creation_utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/ProxmoxDeploy.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/ProxmoxDeploy.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/resources/config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/lxc/0000/config.json" beforeDir="false" afterPath="$PROJECT_DIR$/resources/lxc/100/config.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/run.py" beforeDir="false" afterPath="$PROJECT_DIR$/run.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/lxc_utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/lxc_utils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/proxmox_utils.py" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/proxmox_utils.py" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="MarkdownSettingsMigration">
<option name="stateVersion" value="1" />
</component>
<component name="ProjectId" id="2QxREeVLT4IlTxqXEpzPYhB1R0E" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/mathieu/Documents/Local/Developpement/PycharmProjects/ProxmoxDeploy&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;vcs.Git&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="C:\Users\lmbbrm3\PycharmProjects\ProxmoxDeploy\resources\lxc" />
</key>
</component>
<component name="RunManager">
<configuration name="run" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
<module name="ProxmoxDeploy" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/run.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.run" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="ef90a940-975e-45ac-b0cb-e18c5b09ff29" name="Changes" comment="" />
<created>1686293135999</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1686293135999</updated>
<workItem from="1686293144782" duration="176000" />
<workItem from="1686293341823" duration="6751000" />
<workItem from="1686342148216" duration="3872000" />
<workItem from="1686406521171" duration="618000" />
<workItem from="1686498465624" duration="11804000" />
</task>
<task id="LOCAL-00001" summary="base">
<created>1686293500295</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1686293500295</updated>
</task>
<task id="LOCAL-00002" summary="update drone">
<created>1686342404046</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1686342404046</updated>
</task>
<task id="LOCAL-00003" summary="update drone">
<created>1686342511585</created>
<option name="number" value="00003" />
<option name="presentableId" value="LOCAL-00003" />
<option name="project" value="LOCAL" />
<updated>1686342511585</updated>
</task>
<task id="LOCAL-00004" summary="update drone">
<created>1686342681849</created>
<option name="number" value="00004" />
<option name="presentableId" value="LOCAL-00004" />
<option name="project" value="LOCAL" />
<updated>1686342681849</updated>
</task>
<task id="LOCAL-00005" summary="update drone">
<created>1686342794207</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1686342794207</updated>
</task>
<task id="LOCAL-00006" summary="update drone">
<created>1686342966430</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1686342966430</updated>
</task>
<task id="LOCAL-00007" summary="update drone">
<created>1686344421245</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1686344421245</updated>
</task>
<task id="LOCAL-00008" summary="update drone">
<created>1686345032503</created>
<option name="number" value="00008" />
<option name="presentableId" value="LOCAL-00008" />
<option name="project" value="LOCAL" />
<updated>1686345032503</updated>
</task>
<task id="LOCAL-00009" summary="update drone to debian">
<created>1686346024833</created>
<option name="number" value="00009" />
<option name="presentableId" value="LOCAL-00009" />
<option name="project" value="LOCAL" />
<updated>1686346024833</updated>
</task>
<task id="LOCAL-00010" summary="update drone to debian">
<created>1686406538341</created>
<option name="number" value="00010" />
<option name="presentableId" value="LOCAL-00010" />
<option name="project" value="LOCAL" />
<updated>1686406538341</updated>
</task>
<task id="LOCAL-00011" summary="ssh/local for commands and lxc creation">
<created>1686503708967</created>
<option name="number" value="00011" />
<option name="presentableId" value="LOCAL-00011" />
<option name="project" value="LOCAL" />
<updated>1686503708967</updated>
</task>
<task id="LOCAL-00012" summary="update readme">
<created>1686504338382</created>
<option name="number" value="00012" />
<option name="presentableId" value="LOCAL-00012" />
<option name="project" value="LOCAL" />
<updated>1686504338382</updated>
</task>
<option name="localTasksCounter" value="13" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="base" />
<MESSAGE value="update drone" />
<MESSAGE value="update drone to debian" />
<MESSAGE value="ssh/local for commands and lxc creation" />
<MESSAGE value="update readme" />
<option name="LAST_COMMIT_MESSAGE" value="update readme" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/ProxmoxDeploy$run.coverage" NAME="run Coverage Results" MODIFIED="1686510225291" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/ProxmoxDeploy$main.coverage" NAME="main Coverage Results" MODIFIED="1686295586466" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

189
README.md
View File

@ -14,6 +14,67 @@ Have a look at the resources folder to see how to use it.
# Documentation # Documentation
## Configuration
### Proxmox VE
The Proxmox VE configuration is located in the `config.json` file.
```json5
{
"pve":{
"host": "<pve host ip/hostname>",
"user": "<user to connect via ssh>", // usually root
"port": 22, // ssh port
"local": false // set to true if this program is running directly on the PVE without needing ssh
}
}
```
### LXC
To create a LXC, you need to create a JSON file in the `resources/lxc/<id of lxc>` folder.
You can look at the example with ID 100 in the `resources/lxc/100` folder.
Here is an example config with all available parameters :
*Note : this is not valid JSON, it's just for documentation purposes, if you want to copy the file, use the one in the resources folder*
```json5
{
"lxc_hostname": "traefik", //hostname of the lxc
// the os block contains the os type
// alpine | archlinux | centos | debian | devuan | fedora | gentoo | nixos | opensuse | ubuntu | unmanaged
"os": {
"name": "alpine",
"release": "3.17"
},
// the resources block contains the resources given to the lxc
"resources": {
"cpu": "2", // number of cpu cores
"memory": "1024", // memory (ram) in MB
"swap": "256", // swap in MB
"disk": "8", // disk size in GB
"storage": "local-lvm" // the proxmox storage to use
},
// the network block contains the network configuration
"network": {
"bridge": "vmbr0", // the proxmox bridge to use, vmbr0 is the default one
"ipv4": "dhcp", // ipv4 address, dhcp for dhcp, auto for auto, or an ip address
"ipv6": "auto", // ipv6 address, dhcp for dhcp, auto for auto, or an ip address
"mac": "92:A6:71:77:8E:D8", // mac address, leave empty for random
"gateway4": "", // ipv4 gateway, leave empty for auto/dhcp
"gateway6": "", // ipv6 gateway, leave empty for auto/dhcp
"vlan": "" // vlan id, leave empty for no vlan
},
// the options block contains various options for the lxc
"options": {
"privileged": "false", // set to true to run the lxc in privileged mode
"start_on_boot": "false", // set to true to start the lxc on boot
"startup_order": 2, // the startup order of the lxc
"password": "qwertz1234", // the password of the root user, leave empty for none
"tags": "2-proxy+auth" // tags for the lxc to display in the proxmox web ui
},
```
## Creation ## Creation
In the creation section, you have the option to define conditions for checking whether your LXC/VM has been previously configured. In the creation section, you have the option to define conditions for checking whether your LXC/VM has been previously configured.
If all of these conditions are met, the script will proceed directly to the deploy section and execute the necessary steps to update it. *(This indicates that your LXC/VM has already been configured, and we want to avoid erasing any existing settings/config.)* If all of these conditions are met, the script will proceed directly to the deploy section and execute the necessary steps to update it. *(This indicates that your LXC/VM has already been configured, and we want to avoid erasing any existing settings/config.)*
@ -22,10 +83,11 @@ However, if **any** of the conditions fail to match, the script will process to
## Conditions ## Conditions
### File ### File
The file condition will check if a file exists or not inside the LXC/VM. The file condition will check if a file exists or not inside the LXC/VM.
```json ```json5
"conditions": { "conditions": {
// use a single file
"file": "/var/data/traefikv2/traefik.toml" "file": "/var/data/traefikv2/traefik.toml"
or // or use a list, but only use one
"files": ["/var/data/traefikv2/traefik.toml", "/var/data/config/traefikv2/docker-compose.yml"] "files": ["/var/data/traefikv2/traefik.toml", "/var/data/config/traefikv2/docker-compose.yml"]
} }
``` ```
@ -33,10 +95,11 @@ It can be an array of file using ``["file1", "file2"]`` or just one file in doub
### Folder ### Folder
The folder condition will check if a folder exists or not inside the LXC/VM. The folder condition will check if a folder exists or not inside the LXC/VM.
```json ```json5
"conditions": { "conditions": {
// use a single folder
"folder": "/var/data/traefikv2" "folder": "/var/data/traefikv2"
or // or use a list, but only use one
"folders": ["/var/data/traefikv2", "/var/data/config/traefikv2"] "folders": ["/var/data/traefikv2", "/var/data/config/traefikv2"]
} }
``` ```
@ -44,17 +107,39 @@ It can be an array of folders using ``["folder1", "folder2"]`` or just one folde
### Programs ### Programs
The programs condition will check if a program is installed or not in the LXC/VM. The programs condition will check if a program is installed or not in the LXC/VM.
```json ```json5
"conditions": { "conditions": {
// use a single program
"program": "docker" "program": "docker"
or // or use a list, but only use one
"programs": ["docker", "docker-compose"] "programs": ["docker", "docker-compose"]
} }
``` ```
It can be an array of programs using ``["program1", "program2"]`` or just one program in double quote ``"program"``. It can be an array of programs using ``["program1", "program2"]`` or just one program in double quote ``"program"``.
*Note:This uses `which` to check if the program matches to anything* *Note:This uses `which` to check if the program matches to anything*
### Command
The command condition will check if a command returns a specific value.
```json
"conditions": {
"command": "whoami",
"value": "root"
}
```
*Note: This uses `bash -c` to execute the command*
*Note: If value is an integer, it will look for the return code, if it's a string it's check the output.*
### Docker
The docker condition will check if a docker (or podman) container is running or not.
```json5
"conditions": {
// use a single container
"container": "traefikv2"
// or use a list, but only use one
"container": ["traefikv2", "portainer"]
}
```
## Steps ## Steps
**Note: Paths** **Note: Paths**
@ -64,71 +149,71 @@ If nothing is specified, the script will use the VM/LXC folder (`resources/lxc/<
*The comments in the JSON below are only for documentation purposes and are not valid JSON, remove them before running.* *The comments in the JSON below are only for documentation purposes and are not valid JSON, remove them before running.*
### Script ### Script
The script step will execute a script. The script step will execute a script.
```json ```json5
"steps": [ "steps": [
{ {
"type": "script", "type": "script",
"path": "/global/install-docker.sh" # local path (here: resources/scripts/install-docker.sh) "path": "/global/install-docker.sh" // local path (here: resources/scripts/install-docker.sh)
} }
] ]
``` ```
### File ### File
The file step will copy a file to the VM/LXC. The file step will copy a file to the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "file", "type": "file",
"path": "traefik.toml", # local path (here: resources/lxc/<id>/traefik.toml) "path": "traefik.toml", // local path (here: resources/lxc/<id>/traefik.toml)
"destination": "/var/data/traefikv2/traefik.toml" # lxc/vm path "destination": "/var/data/traefikv2/traefik.toml" // lxc/vm path
} }
] ]
``` ```
### Folder ### Folder
The folder step will copy a folder to the VM/LXC. The folder step will copy a folder to the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "folder", "type": "folder",
"path": "/data/", # local path (here: resources/lxc/<id>/data/) "path": "/data/", // local path (here: resources/lxc/<id>/data/)
"destination": "/var/data/traefikv2" # lxc/vm path "destination": "/var/data/traefikv2" // lxc/vm path
} }
] ]
``` ```
### Command ### Command
The command step will execute a command on the VM/LXC. The command step will execute a command on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "command", "type": "command",
"command": "whoami", # command to execute "command": "whoami", // command to execute
"working_directory": "/var/data/config/traefikv2" # lxc/vm path "working_directory": "/var/data/config/traefikv2" // lxc/vm path
} }
] ]
``` ```
### Docker ### Docker
The docker step will execute a docker command on the VM/LXC. The docker step will execute a docker command on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "docker", "type": "docker",
"command": "run -d --name=traefikv2 --restart=always -p 80:80 -p 443:443 -p 8080:8080 -v /var/data/traefikv2:/etc/traefik -v /var/data/config/traefikv2:/config -v /var/run/docker.sock:/var/run/docker.sock traefik:latest", # docker command to execute "command": "run -d --name=traefikv2 --restart=always -p 80:80 -p 443:443 -p 8080:8080 -v /var/data/traefikv2:/etc/traefik -v /var/data/config/traefikv2:/config -v /var/run/docker.sock:/var/run/docker.sock traefik:latest", // docker command to execute
"working_directory": "/var/data/config/traefikv2" # lxc/vm path "working_directory": "/var/data/config/traefikv2" // lxc/vm path
} }
] ]
``` ```
### Docker-compose ### Docker-compose
The docker-compose step will execute a docker-compose command on the VM/LXC. The docker-compose step will execute a docker-compose command on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "docker-compose", "type": "docker-compose",
"command": "up -d", # docker-compose command to execute "command": "up -d", // docker-compose command to execute
"working_directory": "/var/data/config/traefikv2" # lxc/vm path "working_directory": "/var/data/config/traefikv2" // lxc/vm path
} }
] ]
``` ```
@ -136,12 +221,12 @@ The docker-compose step will execute a docker-compose command on the VM/LXC.
### Git ### Git
The git step will clone a git repo on the VM/LXC. The git step will clone a git repo on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "git", "type": "git",
"url": "https://git.abc.xyz/abc/abc.git", # git url "url": "https://git.abc.xyz/abc/abc.git", // git url to clone
"destination": "/root/" # lxc/vm path "destination": "/root/" // lxc/vm path
} }
] ]
``` ```
@ -149,26 +234,27 @@ The git step will clone a git repo on the VM/LXC.
### Download ### Download
The download step will download a file on the VM/LXC. The download step will download a file on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "download", "type": "download",
"url": "https://git.abc.xyz/file.tar.gz", # download url // download a single file
or "url": "https://git.abc.xyz/file.tar.gz", // download url
"urls": ["https://git.abc.xyz/file1.tar.gz", "https://git.abc.xyz/file2.tar.gz"] # download urls // or use a list of urls, but only use one
"destination": "/tmp/" # lxc/vm path "urls": ["https://git.abc.xyz/file1.tar.gz", "https://git.abc.xyz/file2.tar.gz"] // download urls
"destination": "/tmp/" // lxc/vm path
} }
] ]
``` ```
### Extract archive (tar/zip) ### Extract archive (tar/zip)
The unzip step will unzip a file in the VM/LXC. The unzip step will unzip a file in the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "unzip", "type": "unzip",
"path": "/tmp/file.tar.gz", # lxc/vm path to the archive "path": "/tmp/file.tar.gz", // lxc/vm path to the archive
"destination": "/var/data/config/traefikv2" # (optional) lxc/vm path to extract the archive, will use archive parent directory if blank "destination": "/var/data/config/traefikv2" // (optional) lxc/vm path to extract the archive, will use archive parent directory if blank
} }
] ]
``` ```
@ -176,13 +262,14 @@ The unzip step will unzip a file in the VM/LXC.
### Install package ### Install package
The install-package step will install a package on the VM/LXC. The install-package step will install a package on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "install-package", "type": "install-package",
"package": "git" # package to install // install a single package
or "package": "git",
"packages": ["git", "docker"] # packages to install // or use a list of packages, but only use one
"packages": ["git", "docker"]
} }
] ]
``` ```
@ -191,13 +278,14 @@ The install-package step will install a package on the VM/LXC.
### Remove package ### Remove package
The remove-package step will remove a package on the VM/LXC. The remove-package step will remove a package on the VM/LXC.
```json ```json5
"steps": [ "steps": [
{ {
"type": "remove-package", "type": "remove-package",
"package": "git" # package to remove // remove a single package
or "package": "git"
"packages": ["git", "docker"] # packages to remove // or use a list of packages, but only use one
"packages": ["git", "docker"]
} }
] ]
``` ```
@ -216,16 +304,17 @@ The reboot step will reboot the VM/LXC.
### Replace in file ### Replace in file
The replace-in-file step will replace a string in a file. The replace-in-file step will replace a string in a file.
```json ```json5
"steps": [ "steps": [
{ {
"type": "replace-in-file", "type": "replace-in-file",
"path": "/var/data/config/traefikv2/traefik.toml", # lxc/vm path to the file // replace in a single file
or "path": "/var/data/config/traefikv2/traefik.toml", // inside lxc/vm
"paths": ["/var/data/config/traefikv2/traefik.toml", "/var/data/config/traefikv2/traefik2.toml"] # lxc/vm paths to the files // or use a list of files, but only use one
"search": "abc", # string to search "paths": ["/var/data/config/traefikv2/traefik.toml", "/var/data/config/traefikv2/traefik2.toml"] // inside lxc/vm
"replace": "xyz" # string to replace "search": "abc", // string to search
"replace": "xyz", // string to replace
"case_sensitive": true, // (optional) case sensitive? default: true
} }
] ]
``` ```