# unmanaged files

на примере syslog-ng. сначала получаем список файлов в папке, потом удалем те, которые нами не поддерживаются.

{% tabs %}
{% tab title="YAML" %}

```yaml
- name: get files in syslog conf.d dir
  shell: ls -1 /etc/syslog-ng/conf.d
  register: syslog_existing_files
  changed_when: false
```

```yaml
- name: remove unmanaged syslog configs
  file:
    path: "/etc/syslog-ng/conf.d/{{ item }}"
    state: absent
  with_items: "{{ syslog_existing_files.stdout_lines }}"
  when: item not in configs
```

{% endtab %}
{% endtabs %}

Список поддерживаемых файлов находится в переменной configs, которая или задается заранее или формируется в момент раскатки конфигов на хост, если имена и количество конечных файлов на конечном хосте отлично от списка шаблонов подаваемых модулю


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://agrat.gitbook.io/admin/ansiblya/unmanaged-files.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
