Commit graph

18 commits

Author SHA1 Message Date
f24aec8da8
fix(config): change config path to current directory
Relative path for the configuration file was adjusted to refer to the current directory, simplifying file location and enhancing script portability. This change prevents issues when running the script from different directories.
2024-07-18 19:10:22 +02:00
bc9c9aeb75
refactor: simplify executable path handling
Removed unnecessary os.path.realpath usage for sys.executable in
both manage_hetzner_servers.py and update_local_config.py. This
reduces complexity and potential for errors when resolving paths.

No significant changes to functionality. This change will make
scripts easier to maintain and execute.
2024-07-18 19:09:11 +02:00
5a64f31a1c
refactor: update script execution with sys.executable
Updated the script execution commands to use `sys.executable` instead
of a hard-coded "python" to ensure compatibility with different Python
environments. Additionally, refactored code for better readability
and consistency in formatting, particularly around argument parsing
and error handling in both manage_hetzner_servers.py and
update_local_config.py.

Improves deployment flexibility and code maintainability.
2024-07-18 19:07:02 +02:00
776e3e00ea
refactor: hardcode provider to Hetzner in script
Removed the --provider argument from the command-line parser and set the provider variable directly to "hetzner". Simplifies the script by removing an unnecessary user input field. Relevant for deployments exclusively using Hetzner.
2024-07-18 19:02:51 +02:00
aebc5adaf3
feat: add script to manage Hetzner servers
Introduce a new script to manage Hetzner servers which includes capabilities to list, update, and delete servers. The script integrates with the local Wireguard VPN configuration tool, running an update script and subsequently removing old servers. This automates the process, ensuring efficient server management and updated local configurations.
2024-07-18 18:58:17 +02:00
f075cc668b
fix(config): resolve tempfile mode error in config update
Removed `delete=False, mode='w'` from `TemporaryDirectory` to fix incorrect usage that caused potential errors. Ensures temporary directory is properly cleaned up and simplifies the tempfile creation process. This update improves file handling and stability.
2024-07-18 18:50:58 +02:00
c3c5f36ffc
refactor(config): replace temp file usage with temp dir
Updated the saving mechanism for temporary configuration files by utilizing a temporary directory instead of a named temporary file. This change streamlines file handling and avoids potential issues related to file name collisions.

Improves reliability of configuration updates by ensuring a cleaner and more isolated temporary workspace, which enhances process safety and consistency.
2024-07-18 18:46:05 +02:00
b60efb3f96
feat: add optional config path argument to script
Introduced a `--config_path` parameter to allow specifying a custom path for the Wireguard configuration file. Defaults to `/etc/wireguard/{interface}.conf` if not provided. This enhances flexibility for different deployment environments and use cases.
2024-07-18 18:37:56 +02:00
5bfd82aa6b
feat: automate Wireguard config updates with new script
Introduce a new script to streamline the process of updating local
Wireguard configuration by automating the replacement of the [Peer]
section. This script executes a remote setup script, reads the existing
config file, replaces the [Peer] section, and applies the updated
configuration seamlessly.

Addresses the need for a more efficient and error-free method to keep
local Wireguard settings in sync with remote server setups, enhancing
reliability and maintainability.
2024-07-18 18:26:00 +02:00
6fd8d7cc1a
refactor: lazy-load provider libraries
Defer the import of cloud provider libraries (boto3, hcloud,
digitalocean, azure) until they are needed within the respective
server creation functions. This prevents unnecessary imports
when only a subset of providers is used, reducing resource
consumption and avoiding import errors for unused libraries.
2024-07-18 18:09:18 +02:00
844d420439
feat(worker): add endpoint-only option for server config
Introduced a new `--endpoint-only` argument to the `run` function and CLI, which prints only the Wireguard endpoint (host:port) instead of the full peer configuration. This can be useful for quick access to the endpoint without needing the rest of the configuration details.
2024-07-18 18:05:42 +02:00
959db57391
fix(config): Ensure no exception when keys are missing
Added fallback parameters to config retrieval to prevent exceptions when WireGuard private and preshared keys are missing. This ensures that keys are generated when not provided, improving robustness and preventing potential runtime errors.
2024-07-18 18:02:09 +02:00
b7656a46be
fix(config): handle missing wireguard keys gracefully
Switch to `config.get` for retrieving Wireguard keys to safely handle cases where keys might not be present in the configuration. This change prevents potential crashes due to missing keys and ensures that defaults are generated as needed.
2024-07-18 18:00:20 +02:00
eb575e8f49
refactor: improve configuration handling in server setup
Refactored the code to pass configuration sections as parameters to server creation functions instead of accessing them globally. This enhances modularity and clarity by making function dependencies explicit. Additionally, consolidated configuration reading and argument parsing in the main function, and added a validation step to check for required configuration sections.

This change makes the codebase more maintainable and prepares it for potential future extensions.
2024-07-18 17:59:33 +02:00
1aa3932555
refactor: rename and clarify peer config print statement
Renamed the 'chimpman_config' variable to 'peer_config' for clarity, and updated the print statement to more accurately reflect the content being displayed. This improves code readability and eliminates the use of ambiguous terminology.

No changes to functionality.
2024-07-18 17:50:36 +02:00
2d2ec33a9c
feat(worker): allow manual config of Wireguard keys
Added optional manual configuration for Wireguard private and preshared keys in the configuration file. If these keys are not provided, they will be automatically generated as previously.

This flexibility allows users to specify their own keys, thus integrating custom security needs and syncing with existing setups more seamlessly.
2024-07-18 17:48:22 +02:00
b47e81791d
feat: add IPv4 support for WireGuard configuration
Updated configuration script to include IPv4 rules alongside existing IPv6 rules for iptables. This ensures that both protocols are properly handled, enhancing network versatility and compatibility. Enabled IPv4 forwarding in sysctl to support the new rules.
2024-07-18 17:26:12 +02:00
e192076414
feat: setup WireGuard VPN server automation across providers
Introduce a new feature to automate the creation and configuration of WireGuard VPN servers across multiple cloud providers (Hetzner, AWS, DigitalOcean, Azure). Changes include:

- Added a `.gitignore` file to exclude `config.ini` and `venv/`.
- Provided `config.dist.ini` with configuration templates for supported providers.
- Created a `requirements.txt` listing all necessary dependencies.
- Developed `worker.py` to handle server creation, WireGuard setup, and configuration management.

This enhancement simplifies and standardizes VPN server deployment, improving operational efficiency and consistency.
2024-07-18 17:24:24 +02:00