我需要通过ansible将.py文件从/ tmp / dags文件夹复制到/ home / ec2-user / airflow / dags。
- name: "DAG | Source | Copy Source"
synchronize:
src: /tmp/dags/
dest: /home/ec2-user/airflow/dags
recursive: yes
通过Jenkins执行时的错误日志:-
[ssh-agent] Stopped.
fatal: [10.123.23.123]: FAILED! => {"changed": false, "cmd": "/usr/bin/rsync --delay-updates -F --compress --archive --rsh=/usr/bin/ssh -S none -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null --rsync-path=sudo rsync --out-format=<<CHANGED>>%i %n%L /tmp/dags/ ec2-user@10.123.23.123:/home/ec2-user/airflow/dags", "msg": "Warning: Permanently added '10.123.12.123' (ECDSA) to the list of known hosts.\r\nrsync: change_dir \"/tmp/dags\" failed: No such file or directory (2)\nrsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1052) [sender=3.0.9]\n", "rc": 23}
to retry, use: --limit @/data/jenkins/workspace/cng-airflow-build/acm/plays/airflow/pullDags.retry
我也尝试过复制资源:-
copy:
src: /tmp/dags/
dest: /home/ec2-user/airflow/dags
remote_src: yes
shell / command资源也无法使用
- name: "DAG | Source | Copy Source"
command/shell: cp -pur /tmp/dags/* /home/ec2-user/airflow/dags
复制命令的错误日志
TASK [../../roles/dags : DAG | Source | Copy Source] ***************************
fatal: [10.123.12.123]: FAILED! => {"changed": true, "cmd": ["cp", "-pur", "/tmp/dags/*", "/home/ec2-user/airflow/dags"], "delta": "0:00:00.002929", "end": "2019-01-02 18:17:39.218406", "msg": "non-zero return code", "rc": 1, "start": "2019-01-02 18:17:39.215477", "stderr": "cp: cannot stat ‘/tmp/dags/*’: No such file or directory", "stderr_lines": ["cp: cannot stat ‘/tmp/dags/*’: No such file or directory"], "stdout": "", "stdout_lines": []}
to retry, use: --limit @/data/jenkins/workspace/cng-airflow-build/acm/plays/airflow/pullDags.retry
答案 0 :(得分:0)
- name: "DAG | Source | Copy Source"
shell: cp -pur /tmp/dags/* /home/ec2-user/airflow/dags