Странная проблема с отметкой времени файла при использовании Ansible rsync - PullRequest
0 голосов
/ 11 октября 2019

Я хочу отправить несколько файлов со старыми временными метками с локального сервера linux centos 7 на удаленный хост-сервер aix в папках 1. / fin / cust / scripts / & 2. / fin / cust / scripts / BACKUP / 99770 / такчто файлы копируются с разрешением 755 и текущей отметкой времени.

Я использую приведенный ниже код ansible-playbook и проверяюсь как с модулем оболочки, так и с командным модулем:

   - name: "New Started Deployment is in Progress...."
     local_action: shell rsync --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" "--out-format=<<CHANGED>>%i %n%L" {{ item }} "{{ USER }}@{{ inventory_hostname }}":"{{ BASEPATH }}/{{ vars[item.split('.')[1]] }}/"
     with_fileglob:
       - "{{ playbook_dir }}/tmpfiles/*"


   - name: "New Backup of files on Destination Server `{{ inventory_hostname }}`"
     local_action: shell rsync --delay-updates -F --compress --chmod=755 "--rsh=/usr/bin/ssh -S none -i /app/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" "--out-format=<<CHANGED>>%i %n%L" {{ item }} "{{ USER }}@{{ inventory_hostname }}":"{{ BASEPATH }}/{{ vars[item.split('.')[1]] }}/BACKUP/{{ Number }}/"
     with_fileglob:
       - "{{ playbook_dir }}/tmpfiles/*"
     register: dfroot

Наборфайлы были скопированы на целевой хост с обновленными отметками времени в папке: / fin / cust / scripts /

Однако файлы, которые были скопированы в папку: / fin / cust / scripts / BACKUP / 99770 нацелевой хост не получил обновленную временную метку и все еще имеет временную метку исходного локального сервера.

Абсолютно тот же код, но я не знаю, почему текущая временная метка скопированных файлов не обновлялась в этой конкретной папке -> / fin / cust / scripts / BACKUP / 99770

Примечание. Эта папка (/ fin / cust / scripts / BACKUP / 99770) была создана с использованием файлового модуля ansible вта же самая книга воспроизведения до кода rsync.

Я также вижу, что первый работающий вывод rsync показывает сообщение «CHANGED myfile.txt» в выводе в хвостовой части, которым я делюсь ниже. Второй rsync, однако, не печатает это сообщение. Остальное все выглядит более или менее похожим на меня.

Вывод прогона Playbook ниже:

changed: [remotehost -> localhost] => (item=/app/deployment/tmpfiles/myile.scr) => {"ansible_loop_var": "item", "changed": true, "cmd": "rsync --delay-updates -F --compress --chmod=755 \"--rsh=/usr/bin/ssh -S none -i /app/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" \"--out-format=<<CHANGED>>%i %n%L\" \"/app/deployment/tmpfiles/myile.scr\" \"user2@remotehost\":\"/fin/cust/scripts/\"", "delta": "0:00:00.332529", "end": "2019-10-11 23:05:58.954401", "item": "/app/deployment/tmpfiles/myile.scr", "rc": 0, "start": "2019-10-11 23:05:58.621872", "stderr": "Warning: Permanently added 'remotehost' (RSA) to the list of known hosts.\r\nThis system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials", "stderr_lines": ["Warning: Permanently added 'remotehost' (RSA) to the list of known hosts.", "This system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials"], "stdout": "<<CHANGED>><f..T...... myile.scr", "stdout_lines": ["<<CHANGED>><f..T...... myile.scr"]}

против

changed: [remotehost -> localhost] => (item=/app/deployment/tmpfiles/myile.scr) => {"ansible_loop_var": "item", "changed": true, "cmd": "rsync --delay-updates -F --compress --chmod=755 \"--rsh=/usr/bin/ssh -S none -i /app/id_rsa -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null\" \"--out-format=<<CHANGED>>%i %n%L\" \"/app/deployment/tmpfiles/myile.scr\" \"user2@remotehost\":\"/fin/cust/scripts/BACKUP/99770/\"", "delta": "0:00:00.313416", "end": "2019-10-11 23:05:56.343704", "item": "/app/deployment/tmpfiles/myile.scr", "rc": 0, "start": "2019-10-11 23:05:56.030288", "stderr": "Warning: Permanently added 'remotehost' (RSA) to the list of known hosts.\r\nThis system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials", "stderr_lines": ["Warning: Permanently added 'remotehost' (RSA) to the list of known hosts.", "This system is for the use of authorized users only. Individuals using this computer system without authority, or in excess of their authority, are subject to having all of their activities on this system monitored and recorded by system personnel. In the course of monitoring individuals improperly using this system, or in the course of system maintenance, the activities of authorized users may also be monitored. Anyone using this system expressly consents to such monitoring and is advised that if such such monitoring reveals possible evidence of criminal activity, system personnel may provide the evidence of such monitoring to the law enforcement officials"], "stdout": "", "stdout_lines": []} 

Разница во времени для файлов на удаленном хосте в папке "/ fin / cust / scripts /" & "/ fin / cust / scripts / BACKUP / 99770 "можно увидеть в выводе ниже:

user2@remotehost:/fin/cust/scripts> l myfile.scr
-rwxr-xr-x    1 user2   dba               8 Oct 12 00:01 myfile.scr

user2@remotehost:/fin/cust/scripts/BACKUP/99770> cd BACKUP/99770

user2@remotehost:/fin/cust/scripts/BACKUP/99770> l myfile.scr
-rwxr-xr-x    1 user2   dba               8 Oct 11 18:30 myfile.scr

Отметим, что:

  1. Отметка времени удаленно(aix) скопированный файл user2 @ remotehost: /fin/cust/scripts/BACKUP/99770/myfile.scr совпадает с отметкой времени файла на исходном локальном сервере Linux вместо текущей отметки времени !!

  2. Если я вручную запускаю команду rsync из вывода ansible для любого файла, то папка сервера назначения файла / fin / cust / scripts / BACKUP / 99770 получает текущую временную метку, которая является той, которую я хотел.

Я потратил много времени на отладку этого, прежде чем публиковать здесь решения. Пожалуйста, предложите.

...