diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/Containerfile b/Containerfile index 550a199..417485d 100644 --- a/Containerfile +++ b/Containerfile @@ -1,4 +1,4 @@ FROM debian -COPY machine_admin / +COPY machine_admin /machine_admin COPY machine_setup.py / diff --git a/machine_admin/util.py b/machine_admin/util.py index 2fef7c7..7ae006e 100644 --- a/machine_admin/util.py +++ b/machine_admin/util.py @@ -1,4 +1,13 @@ import subprocess +import logging + +_DRY_RUN = False + +def set_is_dry_run(is_dry_run: bool): + _DRY_RUN = is_dry_run def run_op(op: str): - return subprocess.run(op, shell=True) \ No newline at end of file + if _DRY_RUN: + return subprocess.run(op, shell=True) + else: + logging.info(f"Dry Run | {op}") \ No newline at end of file diff --git a/machine_setup.py b/machine_setup.py index 57e2071..50bbbd4 100644 --- a/machine_setup.py +++ b/machine_setup.py @@ -12,6 +12,9 @@ if __name__ == "__main__": parser.add_argument('--username', help="Name of the default non-root user") + parser.add_argument('--dry_run', + help="If set then don't change the system state - used for testing.", + default = False) args = parser.parse_args()