본문 바로가기

Automation Tools/Ansible

[Ansible] [WARNING]: win_find failed to check some files, these files were ignored and will not be part of the result output(1)

반응형

환경

AWX Docker Version

  • awx 17.0.1
$ docker ps
CONTAINER ID   IMAGE                          COMMAND                  CREATED        STATUS                  PORTS                                                                         NAMES
513c89b46290   ansible/awx:17.0.1             "/usr/bin/tini -- /u…"   3 months ago   Up 2 months             8052/tcp                                                                      awx_task
2c1410976fb7   ansible/awx:17.0.1             "/usr/bin/tini -- /b…"   3 months ago   Up 2 months             0.0.0.0:80->8052/tcp                                                          awx_web
7c0247ceab04   postgres:12                    "docker-entrypoint.s…"   3 months ago   Up 2 months             5432/tcp                                                                      awx_postgres
0b71825f2ef1   redis                          "docker-entrypoint.s…"   3 months ago   Up 2 months             6379/tcp

 

awx_task ansible version

  • ansible 2.9.17
$ docker exec -it  awx_task /bin/sh
sh-4.4# ansible --version
ansible 2.9.17
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]

 

 

 

증상

win_find module을 사용하여 지나간 디렉토리 검색, 삭제하는 playbook 실행시 아래와 같은 경고가 발생하며 일부 파일을 무시한다.

 

[WARNING]: win_find failed to check some files, these files were ignored and will not be part of the result output

 

$ ansible-playbook -vvvv -i test.ini test.yml
...
ok: [TEST] => (item=E:\TEST\) => {
    "ansible_loop_var": "item",
    "changed": false,
    "examined": 0,
    "files": [],
    "item": "E:\\TEST\\",
    "matched": 0,
    "warnings": [
        "win_find failed to check some files, these files were ignored and will not be part of the result output"
    ]
}
[WARNING]: win_find failed to check some files, these files were ignored and will not be part of the result output

 

playbook

  tasks:
  - name: "Find Old Data"
    win_find:
      paths: "{{ item }}"
      patterns: ['TEST1_*','TEST2_*','TEST3_*','TEST4_*']
      file_type: directory
      recurse: no
      age: 90d
    with_items: "{{ test_path }}"
    register: target_file

 

 

 

 

조치

디렉토리 내 포함된 파일 개수가 많거나 Data Size 가 크면 디렉토리 전체 Data Size가 커져 발생할 수 있는 문제로 win_find.ps1 내용 수정을 통해 해결 가능하다.

 

[int]$specified_size = $matches[1]   ->   [int64]$specified_size = $matches[1]

 

모듈 경로 : python version에 따라 경로가 다를 수 있음.

/usr/lib/python2.7/site-packages/ansible/modules/windows/win_find.ps1

or

/usr/lib/python3.6/site-packages/ansible/modules/windows/win_find.ps1

 

175     if ($null -ne $size) {
176         $bytes_per_unit = @{'b'=1; 'k'=1024; 'm'=1024*1024; 'g'=1024*1024*1024; 't'=1024*1024*1024*1024}
177         $size_pattern = '^(-?\d+)(b|k|m|g|t)?$'
178         $match = $size -match $size_pattern
179         if ($match) {
180             [int64]$specified_size = $matches[1]
181             if ($null -eq $matches[2]) {
182                 $chosen_byte = 'b'
183             } else {
184                 $chosen_byte = $matches[2]
185             }

 

반응형