Hostname: {{ get_hostname() }}
Username: {{ get_username() }}
Home Directory: {{ get_home_dir() }}
Temp Directory: {{ get_temp_dir() }}
Local IP: {{ get_ip_address() }}
DNS Resolution:
localhost -> {{ resolve_dns(hostname="localhost") }}
google.com -> {{ resolve_dns(hostname="google.com") }}
Common Ports:
{% set ports = [80, 443, 3000, 8080, 8443, 9000] %}
{% for port in ports %}
Port {{ port | string | pad_left(5) }}: {% if is_port_available(port=port) %}Available ✓{% else %}In Use ✗{% endif %}
{% endfor %}
```yaml
application:
instance_id: {{ uuid() }}
hostname: {{ get_hostname() }}
user: {{ get_username() }}
paths:
home: {{ get_home_dir() }}
temp: {{ get_temp_dir() }}
logs: {{ get_home_dir() }}/logs/app.log
network:
bind_ip: {{ get_ip_address() }}
{% if is_port_available(port=8080) %}
port: 8080
{% else %}
port: 8081 {% endif %}
```
```yaml
version: '3.8'
services:
web:
image: myapp:latest
hostname: {{ get_hostname() }}-web
environment:
- HOST_IP={{ get_ip_address() }}
- USER={{ get_username() }}
{% if is_port_available(port=80) %}
ports:
- "80:8080"
{% else %}
ports:
- "8080:8080" {% endif %}
```
```nginx
upstream backend {
server 127.0.0.1:8080;
}
server {
listen {{ get_ip_address() }}:80;
server_name {{ get_hostname() }};
access_log {{ get_home_dir() }}/logs/nginx/access.log;
error_log {{ get_home_dir() }}/logs/nginx/error.log;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
```
```bash
export APP_HOST={{ get_ip_address() }}
export APP_USER={{ get_username() }}
export APP_HOME={{ get_home_dir() }}
export APP_TMP={{ get_temp_dir() }}
{% if is_port_available(port=3000) %}
export APP_PORT=3000
{% elif is_port_available(port=3001) %}
export APP_PORT=3001
{% else %}
export APP_PORT=8080
{% endif %}
export DATABASE_HOST={{ resolve_dns(hostname="localhost") }}
export CACHE_HOST={{ resolve_dns(hostname="localhost") }}
echo "Environment configured for {{ get_username() }} on {{ get_hostname() }}"
echo " Local IP: $APP_HOST"
echo " App Port: $APP_PORT"
```
```yaml
global:
scrape_interval: 15s
external_labels:
hostname: {{ get_hostname() }}
instance_ip: {{ get_ip_address() }}
user: {{ get_username() }}
scrape_configs:
- job_name: 'node-exporter'
static_configs:
- targets: ['{{ get_ip_address() }}:9100']
labels:
hostname: {{ get_hostname() }}
```
```yaml
database:
host: {{ resolve_dns(hostname="localhost") }} port: 5432
user: {{ get_username() }}
connection_pool:
max_size: 100
redis:
host: {{ resolve_dns(hostname="localhost") }} port: 6379
app_port: {% if is_port_available(port=8000) %}8000{% else %}8001{% endif %}
```