Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ansible AWX从远程Windows获取文件到本地linux_Linux_Windows_Ansible_File Transfer_Ansible Awx - Fatal编程技术网

Ansible AWX从远程Windows获取文件到本地linux

Ansible AWX从远程Windows获取文件到本地linux,linux,windows,ansible,file-transfer,ansible-awx,Linux,Windows,Ansible,File Transfer,Ansible Awx,大家好,堆栈溢出社区。 我正在寻求您的帮助,因为我一直在尝试使用Ansible AWX完成从远程Windows到本地linux的文件获取任务,但我无法让它工作。贝娄:我分享了剧本和我做过的大多数测试,但都没有成功 我正在获取windows目录中的最新文件,并尝试将该文件传输到docker内部或运行AWX的linux服务器中的本地AWX 测试1:说文件被复制了,但当我进入docker时,什么都没有。我找不到答案,在谷歌上也找不到答案 测试2:不起作用。它说无法对linux服务器进行身份验证 测试3

大家好,堆栈溢出社区。 我正在寻求您的帮助,因为我一直在尝试使用Ansible AWX完成从远程Windows到本地linux的文件获取任务,但我无法让它工作。贝娄:我分享了剧本和我做过的大多数测试,但都没有成功

我正在获取windows目录中的最新文件,并尝试将该文件传输到docker内部或运行AWX的linux服务器中的本地AWX

测试1:说文件被复制了,但当我进入docker时,什么都没有。我找不到答案,在谷歌上也找不到答案

测试2:不起作用。它说无法对linux服务器进行身份验证

测试3:任务变为空闲,我必须重新启动docker才能停止它。这太疯狂了。不知道为什么

测试4:它表示连接意外关闭

我不想提供输出以减少噪音,因为我无法共享信息。我也从剧本中删除了名字和IP

我正在使用AD连接到Windows服务器

拜托,我不知道还能做什么。提前谢谢你的帮助

---
- name: Get file from Windows to Linux
  hosts: all # remote windows server ip
  gather_facts: true
  become: true

  vars:
    local_dest_path_test1: \var\lib\awx\public\ # Inside AWX docker
    local_dest_path_test2: \\<linux_ip>\home\user_name\temp\  # Outside AWX docker in the linux server
    local_dest_path_test3: /var/lib/awx/public/ # Inside AWX docker
    # Source file in remote windows server
    src_file: C:\temp\

  tasks:
    # Getting file information to be copied
    - name: Get files in a folder
      win_find:
        paths: "{{ src_file }}"
      register: found_files

    - name: Get latest file
      set_fact:
        latest_file: "{{ found_files.files | sort(attribute='creationtime',reverse=true) | first }}"

    # Test 1
    - name: copy files from Windows to Linux
      win_copy:
        src: "{{ latest_file.path }}"
        dest: "{{ local_dest_path_test1 }}"
        remote_src: yes

    # Test 2
    - name: copy files from Windows to Linux
      win_copy:
        src: "{{ latest_file.path }}"
        dest: "{{ local_dest_path_test2 }}"
        remote_src: yes
      become: yes
      become_method: su
      become_flags: logon_type=new_credentials logon_flags=netcredentials_only
      vars:
        ansible_become_user: <linux_user_name>
        ansible_become_pass: <linux_user_password>
        ansible_remote_tmp: <linux_remote_path>

    # Test 3
    - name: Fetch latest file to linux
      fetch:
        src: "{{ latest_file.path }}"
        dest: "{{ local_dest_path_test3 }}"
        flat: yes
        fail_on_missing: yes
      delegate_to: 127.0.0.1

    # Test 4
    - name: Transfer file from Windows to Linux
      synchronize:
        src: "{{ latest_file.path }}"
        dest: "{{ local_dest_path_test3 }}"
        mode: pull
      delegate_to: 127.0.0.1

---
-名称:从Windows到Linux获取文件
主机:所有远程windows服务器ip
收集事实:真实
变成:真的
变量:
本地地址路径测试1:\var\lib\awx\public\\在awx docker内部
本地\u dest\u path\u test2:\\\home\user\u name\temp\\在linux服务器的AWX docker外部
本地地址路径测试3:/var/lib/awx/public/#在awx docker内部
#远程windows服务器中的源文件
src_文件:C:\temp\
任务:
#获取要复制的文件信息
-名称:获取文件夹中的文件
win_find:
路径:“{src_文件}}”
注册:找到\u文件
-名称:获取最新文件
设定事实:
最新的_文件:{{found_files.files | sort(attribute='creationtime',reverse=true)| first}
#测试1
-名称:将文件从Windows复制到Linux
赢取副本:
src:{{latest_file.path}}”
目标:{{local_dest_path_test1}}”
遥控器:是的
#测试2
-名称:将文件从Windows复制到Linux
赢取副本:
src:{{latest_file.path}}”
目标:{{local_dest_path_test2}}”
遥控器:是的
变成:是的
方法:su
成为\u标志:登录\u类型=新\u凭证登录\u标志=仅网络凭证\u
变量:
ansible_成为_用户:
ansible_成为_通行证:
ansible_remote_tmp:
#测试3
-名称:将最新文件提取到linux
获取:
src:{{latest_file.path}}”
dest:{{local_dest_path_test3}}”
公寓:是的
不合格,不合格:是
代表:127.0.0.1
#测试4
-名称:将文件从Windows传输到Linux
使同步:
src:{{latest_file.path}}”
dest:{{local_dest_path_test3}}”
模式:拉
代表:127.0.0.1