### Copying Diun Example Configuration (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/diun/README.md Copies the example configuration file 'example.yml' to '.yml' in the current directory. This serves as the starting point for creating a custom Diun configuration. ```sh $ cp example.yml .yml ``` -------------------------------- ### Copying Nginx Example Configuration File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/nginx/README.md Copies the example nginx configuration file to a new file for customization. This is a prerequisite step before editing the configuration. ```sh cp config/example.conf config/.conf ``` -------------------------------- ### Copying Mosquitto Configuration File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/mosquitto/README.md Copies the provided `example.conf` file to a new file named `.conf` in the current directory. This new file serves as the base for custom Mosquitto configuration. Users should then edit the `.conf` file to meet their specific requirements. ```sh cp example.conf .conf ``` -------------------------------- ### Create Traefik Basic Auth User (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Installs the `apache2-utils` package which provides `htpasswd`. It then uses `htpasswd` to generate a basic auth entry for a specified user and password, and saves it to a `users.txt` file located in the Traefik data path defined in the `.env` file. ```Shell sudo apt install apache2-utils $ htpasswd -nb | sudo tee "$(cat .env | grep "HOST_TRAEFIK_PATH" | cut -d'=' -f2)/users.txt" ``` -------------------------------- ### Execute Traefik Data Setup Script (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Grants execute permission to the Traefik data setup script and runs it with sudo. This script initializes the necessary data directory for Traefik configuration files. ```Shell chmod +x ./create_traefik_data.sh $ sudo ./create_traefik_data.sh ``` -------------------------------- ### Execute Alertmanager Data Setup Script (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Grants execute permission to the Alertmanager data setup script and runs it with sudo. This script initializes the necessary data directory and copies basic configuration files for Alertmanager. ```Shell chmod +x ./create_alertmanager_data.sh $ sudo ./create_alertmanager_data.sh ``` -------------------------------- ### Execute Prometheus Data Setup Script (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Grants execute permission to the Prometheus data setup script and runs it with sudo. This script initializes the necessary data directory and copies basic configuration files for Prometheus. ```Shell chmod +x ./create_prometheus_data.sh $ sudo ./create_prometheus_data.sh ``` -------------------------------- ### Prepare Environment File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Copies an example environment file (`example.env`) to a standard `.env` file within a specific directory (`folder-of-interest/`). This is a prerequisite step before configuring the environment variables for a stack deployment. ```sh cd folder-of-interest/ cp example.env .env ``` -------------------------------- ### Install Deploy Helper Script (Bash) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Installs the `deploy-stack.sh` helper script by copying it to `/usr/bin/` and making it executable. This allows the script to be run from any directory in the system's PATH. ```bash sudo cp deploy-stack.sh /usr/bin/deploy-stack sudo chmod +x /usr/bin/deploy-stack ``` -------------------------------- ### Creating Host Directories from View File Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Reads the stack's view file (`.my-project.view.json`), extracts values for keys starting with `host_` using `jq`, and creates the corresponding directories on the host system using `mkdir -p`. Requires `jq` and potentially `sudo`. ```sh cd folder-of-interest/ cat .my-project.view.json | jq -r '. | to_entries[] | select(.key | startswith("host_")) | .value' | xargs sudo mkdir -p ``` -------------------------------- ### Copying Environment File for Stack Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Copies an example environment file to a new file specific to the chosen stack name, prefixed with a dot (e.g., `.my-project.env`). This file will contain environment variables used by the stack services. ```sh cd folder-of-interest/ cp example.env .my-project.env ``` -------------------------------- ### Copy GitLab Configuration File (sh) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/gitlab-ce/README.md Copies the example GitLab configuration file (`example.rb`) to a new file named `.rb` in the current directory. This new file should then be edited to customize the GitLab instance settings before deployment. Requires a shell environment. ```sh $ cp example.rb .rb ``` -------------------------------- ### Copying View File for Stack Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Copies an example JSON view file (`.view.json`) to a new file specific to the chosen stack name (e.g., `.my-project.view.json`). This file holds the data injected into the Mustache template. ```sh cd folder-of-interest/ cp example.view.json .my-project.view.json ``` -------------------------------- ### Creating Redis Overlay Network (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/redis/README.md This command creates an attachable overlay network named 'redis_network'. This network is intended for applications within the Swarm cluster to connect to the Redis service. ```sh $ docker network create --attachable -d overlay redis_network ``` -------------------------------- ### Copy Traefik Configuration File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Copies the default `traefik.yml` file to a new file named `override.traefik.yml`. This is recommended for creating custom configurations without modifying the original file. ```Shell cp traefik.yml override.traefik.yml ``` -------------------------------- ### Create Docker Overlay Networks (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Creates two Docker overlay networks: `metrics_network` for monitoring services and `proxy_network` for services proxied by Traefik. These networks are required for inter-service communication in a Docker Swarm. ```Shell docker network create -d overlay metrics_network $ docker network create -d overlay proxy_network ``` -------------------------------- ### Copying SSP Configuration File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/openldap/README.md Copies the example Self-Service-Password (SSP) configuration file to a new file with a leading dot, making it a hidden file. This is the first step before editing the configuration for specific needs. ```sh $ cp example.ssp.conf.php .ssp.conf.php ``` -------------------------------- ### Creating Docker Overlay Network for Elasticsearch Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/elasticsearch/README.md Creates a Docker overlay network named 'elastic_network'. This network is attachable, allowing services to connect to it, and uses the overlay driver for multi-host communication. It is intended for applications to connect to the Elasticsearch database. ```sh $ docker network create --attachable -d overlay elastic_network ``` -------------------------------- ### Configure Docker Service Logging to Graylog (YAML) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/graylog/README.md Example configuration snippet for a Docker service to send logs to Graylog using the GELF driver. It specifies the 'gelf' logging driver and the UDP address where the Graylog input is listening. ```yaml service-name: ... logging: driver: "gelf" options: gelf-address: "udp://172.17.0.1:12201" ... ``` -------------------------------- ### Setting Permissions for Host Directories Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Reads the stack's view file (`.my-project.view.json`), extracts values for keys starting with `host_` using `jq`, and sets the owner and group of the corresponding directories to `:docker` using `chown -R`. Requires `jq` and potentially `sudo`. ```sh cd folder-of-interest/ cat .my-project.view.json | jq -r '. | to_entries[] | select(.key | startswith("host_")) | .value' | xargs sudo chown -R :docker ``` -------------------------------- ### Create Docker Overlay Network for MariaDB (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/mariadb/README.md This command creates a Docker overlay network named 'mariadb_network'. The '--attachable' flag allows standalone containers to connect, and '-d overlay' specifies the overlay driver for Swarm communication. This network is intended for applications to connect to the MariaDB service. ```sh $ docker network create --attachable -d overlay mariadb_network ``` -------------------------------- ### Applying Traefik Forward Auth Middleware to Entrypoint (CLI) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/traeik-forward-auth/README.md Applies the `oauth@swarm` middleware to a specific Traefik entrypoint defined by ``. This is typically used as a command-line argument when starting Traefik or in its static configuration to protect all services routed through that entrypoint. ```sh --entryPoints..http.middlewares=oauth@swarm ``` -------------------------------- ### Configure Service Labels for Traefik Proxying (YAML) Source: https://github.com/tony-defa/swarm-cluster/blob/master/system/README.md Defines Docker service labels within a compose file (`deploy.labels`) to configure Traefik routing for a specific service. It enables Traefik, sets the entrypoint, defines the host rule, specifies the target service and port, and includes optional configurations for sticky sessions and basic authentication middleware. ```YAML service-name: ... deploy: labels: traefik.enable: "true" # Use websecure instead of web for https configuration traefik.http.routers..entrypoints: web traefik.http.routers..rule: Host(``) traefik.http.routers..service: traefik.http.services..loadbalancer.server.port: # The following is only for sticky sessions traefik.http.services..loadBalancer.sticky.cookie: "true" traefik.http.services..loadBalancer.sticky.cookie.name: "" # Optional basic auth traefik.http.routers..middlewares: basic-auth@file ... ``` -------------------------------- ### Block Graylog UDP Port with iptables (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/graylog/README.md Example shell command using iptables to block incoming UDP traffic on port 12201 for the DOCKER-USER chain. This is a security measure to prevent external access to the Graylog GELF input if the port is exposed. ```sh sudo iptables -I DOCKER-USER -i eth0 -p udp --dport 12201 -j DROP ``` -------------------------------- ### Retrieving Initial Jenkins Admin Password (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/jenkins/README.md This command displays the logs of the Jenkins service container, which typically include the initial administrator password required for the first login. Alternatively, the password can be found in the 'secrets/initialAdminPassword' file within the configured Jenkins volume. ```Shell $ docker service logs _jenkins ``` -------------------------------- ### Create Docker Overlay Network for MQTT (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/homeassistant/README.md Creates a Docker overlay network named `mqtt_network` using the `docker network create` command. The `--attachable` flag allows standalone containers to connect, and the `-d overlay` specifies the driver. This network is necessary for the optional Zigbee2MQTT service. ```sh $ docker network create --attachable -d overlay mqtt_network ``` -------------------------------- ### Deploying Stack Directly with Environment File Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Renders the `app.mustache` template using `.my-project.view.json`, pipes the output to `docker stack deploy`, and injects environment variables from `.my-project.env` using `env -i` and `xargs`. Deploys the stack directly without creating an intermediate file. ```sh cd folder-of-interest/ mustache .my-project.view.json app.mustache | env -i $(cat .my-project.env | grep "^[A-Z]" | xargs) docker stack deploy -c - stack-name ``` -------------------------------- ### Deploying Stack Directly Without Environment File Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Renders the `app.mustache` template using `.my-project.view.json`, pipes the output to `docker stack deploy`, and deploys the stack directly without creating an intermediate file or injecting environment variables from a file. ```sh cd folder-of-interest/ mustache .my-project.view.json app.mustache | docker stack deploy -c - stack-name ``` -------------------------------- ### Applying Traefik Error Pages Middleware to Entrypoint (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/error-pages/README.md This snippet shows how to apply the 'errorPages@swarm' middleware to a specific Traefik entrypoint using command-line arguments or configuration syntax. This ensures all services routed through this entrypoint will use the specified error pages. ```sh --entryPoints..http.middlewares=errorPages@swarm ``` -------------------------------- ### Generating Stack File from Template Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/README.md Uses the `mustache` command to render the `app.mustache` template using data from `.my-project.view.json` and redirects the output to a new Docker Compose file (`.my-project.app.yml`). ```sh cd folder-of-interest/ mustache .my-project.view.json app.mustache > .my-project.app.yml ``` -------------------------------- ### Copy Home Assistant Configuration File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/homeassistant/README.md Copies the default Home Assistant configuration file (`config/configuration.yaml`) to the host volume path specified in the `.view.json` file. It uses `jq` to parse the JSON and extract the correct destination path, preparing the configuration file for user customization. ```sh $ cp config/configuration.yaml "$(cat .view.json | jq -r '.host_ha_data')/configuration.yaml" ``` -------------------------------- ### Configure Home Assistant HTTP for Traefik (YAML) Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/homeassistant/README.md Adds configuration under the `http:` key in the Home Assistant `configuration.yaml` file. It sets `use_x_forwarded_for` to `true` and defines a list of `trusted_proxies`, including localhost and the Traefik proxy subnet, to correctly handle requests coming through the reverse proxy. ```yaml http: use_x_forwarded_for: true trusted_proxies: - 127.0.0.1 - 10.0.0.0/16 # traefik proxy subnet ``` -------------------------------- ### Create Docker Macvlan Config-Only Networks (sh) Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/homeassistant/README.md These commands create configuration-only macvlan networks on each node of the swarm. They define the subnet, gateway, parent interface, and a specific IP range for each node's configuration. Remember to replace the placeholder values with your actual network settings. ```sh # create a macvlan network for each node # start with the first node docker network create --config-only --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=eth0 --ip-range 192.168.0.232/29 macvlan_local # create the network on the second node docker network create --config-only --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=eth0 --ip-range 192.168.0.240/29 macvlan_local # create the network on the third node docker network create --config-only --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=eth0 --ip-range 192.168.0.248/29 macvlan_local ``` -------------------------------- ### Run Deploy Helper Script (Bash) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Executes the `deploy-stack` helper script to deploy a Docker Swarm stack. It takes the compose file path (``) and an optional stack name (`[stack-name]`) as arguments. The script handles environment files and host path creation automatically. ```bash deploy-stack [stack-name] ``` -------------------------------- ### Manually Create and Configure HOST Paths (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Identifies `HOST_` variables in the `.env` file, creates the corresponding directories using `mkdir -p`, and sets their group ownership to `docker` using `chown -R`. This prepares host directories required by services before manual deployment. ```sh cd folder-of-interest/ cat .env | grep "^HOST_[A-Z]" | cut -d'=' -f2 | xargs sudo mkdir -p cat .env | grep "^HOST_[A-Z]" | cut -d'=' -f2 | xargs sudo chown -R :docker ``` -------------------------------- ### Create Docker Swarm Macvlan Network (sh) Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/homeassistant/README.md This command creates the actual macvlan network that is scoped to the entire Docker Swarm. It uses the configuration previously created on the individual nodes via the `macvlan_local` config-only network. ```sh # create the macvlan network on the swarm docker network create -d macvlan --scope swarm --config-from macvlan_local macvlan_swarm ``` -------------------------------- ### Applying Traefik Error Pages Middleware to Router (YAML) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/error-pages/README.md This YAML snippet demonstrates how to attach the 'errorPages@swarm' middleware to a specific Traefik router using a Docker service label. This configures the individual service to use the specified error pages when handling requests. ```yaml traefik.http.routers..middlewares: errorPages@swarm ``` -------------------------------- ### Creating Docker Overlay Network for MongoDB (sh) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/mongodb/README.md Creates a Docker overlay network named `mongo_network` for services to connect to the MongoDB database. The `--attachable` flag allows external services to join this network. ```sh docker network create --attachable -d overlay mongo_network ``` -------------------------------- ### Enable Bluetooth in Home Assistant Container (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/mustache/homeassistant/README.md Runs the `bluetoothctl power on` command inside the Home Assistant Docker container. This command interacts with the Bluetooth daemon to enable the Bluetooth adapter, providing Bluetooth functionality within the Home Assistant instance. ```sh bluetoothctl power on ``` -------------------------------- ### Creating MariaDB HA Overlay Network (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/mariadb-ha/README.md This command creates a public overlay network in Docker Swarm. This network is intended for applications to connect to the MariaDB HA services. ```sh $ docker network create -d overlay mariadb_ha_network ``` -------------------------------- ### Restoring OpenLDAP Backup (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/openldap/README.md Executes the `slapd-restore` command from within the backup container to restore OpenLDAP data and configuration from compressed backup files. The first command restores data (type 1), and the second restores configuration (type 0). ```sh $ slapd-restore 1 -data.gz $ slapd-restore 0 -config.gz ``` -------------------------------- ### Copying Traefik Forward Auth Compose File (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/traeik-forward-auth/README.md Copies the default `forward-auth.yml` Docker Compose file to a new file named `override.forward-auth.yml`. This allows for customization without modifying the original file. This is a standard shell command. ```sh cp forward-auth.yml override.forward-auth.yml ``` -------------------------------- ### Manually Deploy Stack with .env (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Deploys a Docker Swarm stack manually using `docker stack deploy`. It reads environment variables from the `.env` file and passes them to the command using `env -i` before deploying the stack defined by `stack-file.yml` with the specified `stack-name`. ```sh cd folder-of-interest/ env -i $(cat .env | grep "^[A-Z]" | xargs) docker stack deploy -c stack-file.yml stack-name ``` -------------------------------- ### Create Docker Secret (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Creates a Docker Swarm secret from standard input. The secret data (`someSecret`) is piped to the `docker secret create` command, which names the secret ``. ```sh printf "someSecret" | docker secret create - ``` -------------------------------- ### Applying Traefik Forward Auth Middleware to Router (YAML) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/traeik-forward-auth/README.md Adds the `oauth@swarm` middleware to a specific Traefik router defined by ``. This label is typically added to a service definition in a Docker Compose file to protect the service with the forward authentication. ```yml traefik.http.routers..middlewares: oauth@swarm ``` -------------------------------- ### Configuring Prometheus Scrape Job for MongoDB Exporter (yml) Source: https://github.com/tony-defa/swarm-cluster/blob/master/apps/mongodb/README.md Defines a Prometheus scrape configuration job named 'mongodb' to collect metrics from the MongoDB exporter. It specifies the metrics path, scrape interval, and the target address for the exporter. ```yml scrape_configs: ... - job_name: 'mongodb' metrics_path: '/metrics' scrape_interval: 30s static_configs: - targets: ['exporter:9216'] ``` -------------------------------- ### Manually Deploy Stack without .env (Shell) Source: https://github.com/tony-defa/swarm-cluster/blob/master/README.md Deploys a Docker Swarm stack manually using `docker stack deploy`. This command is used when the stack does not require environment variables from a `.env` file. It deploys the stack defined by `stack-file.yml` with the specified `stack-name`. ```sh cd folder-of-interest/ docker stack deploy -c stack-file.yml stack-name ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.