fix: Resolve 'too many open files' error in pipeline
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

- Remove -v verbose flag from ansible-playbook (was causing file descriptor exhaustion)
- Add recurse: false to find tasks (prevents recursive directory traversal)
- Set ulimit -n 4096 in Woodpecker container to increase FD limit
- Add ANSIBLE_* environment variables for container optimization:
  - ANSIBLE_HOST_KEY_CHECKING=False (skip SSH key verification)
  - ANSIBLE_CALLBACK_WHITELIST=minimal (reduce output verbosity)
  - ANSIBLE_FORCE_COLOR=False (no ANSI color codes)
  - ANSIBLE_RETRY_FILES_ENABLED=False (don't create retry files)

This resolves fsnotify watcher errors in container environments with low FD limits.
This commit is contained in:
dvirlabs 2026-04-22 21:54:00 +03:00
parent f926b7eb0d
commit fc8cb0c40e
3 changed files with 22 additions and 4 deletions

View File

@ -97,8 +97,16 @@ steps:
GITOPS_STATUS_SERVER_URL: http://gitops-status-server.observability-stack.svc.cluster.local:80 GITOPS_STATUS_SERVER_URL: http://gitops-status-server.observability-stack.svc.cluster.local:80
REPO_NAME: rsyslog REPO_NAME: rsyslog
SERVER_NAME: rsyslog-lab SERVER_NAME: rsyslog-lab
# Optimize Ansible for container environment
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_CALLBACK_WHITELIST: "minimal"
ANSIBLE_FORCE_COLOR: "False"
ANSIBLE_RETRY_FILES_ENABLED: "False"
commands: commands:
- | - |
# Increase file descriptor limit for Ansible
ulimit -n 4096
# Install dependencies: curl for HTTP requests, jq for JSON formatting # Install dependencies: curl for HTTP requests, jq for JSON formatting
apk add --no-cache curl jq > /dev/null 2>&1 apk add --no-cache curl jq > /dev/null 2>&1
@ -139,8 +147,16 @@ steps:
GITOPS_STATUS_SERVER_URL: http://gitops-status-server.observability-stack.svc.cluster.local:80 GITOPS_STATUS_SERVER_URL: http://gitops-status-server.observability-stack.svc.cluster.local:80
REPO_NAME: rsyslog REPO_NAME: rsyslog
SERVER_NAME: rsyslog-lab SERVER_NAME: rsyslog-lab
# Optimize Ansible for container environment
ANSIBLE_HOST_KEY_CHECKING: "False"
ANSIBLE_CALLBACK_WHITELIST: "minimal"
ANSIBLE_FORCE_COLOR: "False"
ANSIBLE_RETRY_FILES_ENABLED: "False"
commands: commands:
- | - |
# Increase file descriptor limit for Ansible
ulimit -n 4096
# Install dependencies: curl for HTTP requests, jq for JSON formatting # Install dependencies: curl for HTTP requests, jq for JSON formatting
apk add --no-cache curl jq bash > /dev/null 2>&1 apk add --no-cache curl jq bash > /dev/null 2>&1

View File

@ -42,12 +42,14 @@
ansible.builtin.find: ansible.builtin.find:
paths: "{{ rsyslog_config_dir }}" paths: "{{ rsyslog_config_dir }}"
patterns: "*.conf" patterns: "*.conf"
recurse: false
register: server_configs register: server_configs
- name: Find config files in Git (controller) - name: Find config files in Git (controller)
ansible.builtin.find: ansible.builtin.find:
paths: "{{ playbook_dir }}/../../files/rsyslog.d" paths: "{{ playbook_dir }}/../../files/rsyslog.d"
patterns: "*.conf" patterns: "*.conf"
recurse: false
delegate_to: localhost delegate_to: localhost
register: repo_configs register: repo_configs

View File

@ -66,19 +66,19 @@ echo "Step 1/4: Running drift-check playbook..."
PLAYBOOK_LOG=$(mktemp) PLAYBOOK_LOG=$(mktemp)
trap "rm -f $PLAYBOOK_LOG" EXIT trap "rm -f $PLAYBOOK_LOG" EXIT
# Run playbook with verbose flag to capture detailed output # Run playbook (no -v flag to avoid file descriptor exhaustion in containers)
# Exit code: 0 = synced, non-zero = drift detected (expected) # Exit code: 0 = synced, non-zero = drift detected (expected)
set +e set +e
ansible-playbook \ ansible-playbook \
-i "$INVENTORY_FILE" \ -i "$INVENTORY_FILE" \
"$PLAYBOOK" \ "$PLAYBOOK" \
-v \
> "$PLAYBOOK_LOG" 2>&1 > "$PLAYBOOK_LOG" 2>&1
DRIFT_RC=$? DRIFT_RC=$?
set -e set -e
# Show playbook output for debugging # Show playbook output for debugging (compact)
cat "$PLAYBOOK_LOG" echo "Playbook output:"
cat "$PLAYBOOK_LOG" | tail -20
echo "" echo ""
# ───────────────────────────────────────────────────────────────────────────────── # ─────────────────────────────────────────────────────────────────────────────────