从Ansible到DSC,两个Linux的不同主机

时间:2019-01-21 17:49:49

标签: ansible dsc

我要实现的是能够通过win_dsc模块使用ansible调用DSC

我的环境是:

  • 机器1(Ubuntu 18.04.1 LTS和Ansible 2.7.6)
  • 计算机2(无法通过Microsoft DSC和PowerShell 6.1.1升级的Ubuntu 14.04 LTS)
  • 这两个机器都可以互相看到,并且我可以使用证书从机器1切换到机器2

  • 我已在ansible conf中将remote_user参数设置为可以SSH到计算机2的用户

  • 由于互斥锁出现问题,我禁用了额外的ssh参数
  • 我已将ansible配置中的可执行文件更改为bin / bash或bin / sh
  • 我已更改为选择ssh而不是sftp
  • 我已将机器1的ssh conf更改为具有而没有PAM
  • 我更改了ansible配置,以将文件保留在计算机2上
  • 我已从.bashrc中删除了出口0
  • omiserver在正确的端口上正确侦听
  • 可以ssh的用户能够以sudo的身份执行命令
  • DSC在machine2到machine2上都可以正常工作

我的ansible剧本非常简单,主机列表中只有一台主机

- hosts: all
  tasks:
    - name: use win_dsc
      win_dsc:
        async: yes
        resource_name: File
        DestinationPath: /tmp/file_test
        Attributes: 
        - Hidden
        Ensure: Present
        Type: Directory

如果我使用上面的参数,我总是会得到相同的行为。机器1能够连接到机器2并正确地复制文件,但是随后发生了某些事情且未执行 有没有明显没有配置的东西?

...
<x.y.z.k> ESTABLISH SSH CONNECTION FOR USER
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/windows/win_dsc.py
<x.y.z.k> PUT /root/.ansible/tmp/ansible-local-13790fq9EQL/tmpPcljxm TO /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/AnsiballZ_win_dsc.py
<x.y.z.k> SSH: EXEC sftp -b - -v -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=username_that_can_ssh -o ConnectTimeout=10 '[x.y.z.k]'
<x.y.z.k> (0, 'sftp> put /root/.ansible/tmp/ansible-local-13790fq9EQL/tmpPcljxm /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/AnsiballZ_win_dsc.py
', "OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017\r
debug1: Reading configuration data /etc/ssh/ssh_config\r
debug1: /etc/ssh/ssh_config line 19: Applying options for *\r
debug1: Connecting to x.y.z.k [x.y.z.k] port 22.\r
debug1: fd 3 clearing O_NONBLOCK\r
debug1: Connection established.\r
debug1: permanently_set_uid: 0/0\r
debug1: identity file /root/.ssh/id_rsa type 0\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_rsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519 type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519-cert type -1\r
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1\r
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8\r
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000\r
debug1: Authenticating to x.y.z.k:22 as 'username_that_can_ssh'\r
debug1: SSH2_MSG_KEXINIT sent\r
debug1: SSH2_MSG_KEXINIT received\r
debug1: kex: algorithm: curve25519-sha256@libssh.org\r
debug1: kex: host key algorithm: ecdsa-sha2-nistp256\r
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:K2X/2dqXd9uK58FPAS32uGYzGSJADRUsIleDobsDLGU\r
debug1: Host 'x.y.z.k' is known and matches the ECDSA host key.\r
debug1: Found key in /root/.ssh/known_hosts:1\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_NEWKEYS sent\r
debug1: expecting SSH2_MSG_NEWKEYS\r
debug1: SSH2_MSG_NEWKEYS received\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_SERVICE_ACCEPT received\r
debug1: Authentications that can continue: publickey,password\r
debug1: Next authentication method: publickey\r
debug1: Offering public key: RSA SHA256:qrWNCrHhzq2FHUGkr2FDpcUTVpklV7lbNaA1zKczg6Q /root/.ssh/id_rsa\r
debug1: Server accepts key: pkalg ssh-rsa blen 279\r
debug1: Authentication succeeded (publickey).\r
Authenticated to x.y.z.k ([x.y.z.k]:22).\r
debug1: channel 0: new [client-session]\r
debug1: Requesting no-more-sessions@openssh.com\r
debug1: Entering interactive session.\r
debug1: pledge: network\r
debug1: Sending environment.\r
debug1: Sending env LANG = en_US.UTF-8\r
debug1: Sending subsystem: sftp\r
debug1: Couldn't stat remote file: No such file or directory\r
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r
debug1: channel 0: free: client-session, nchannels 1\r
debug1: fd 0 clearing O_NONBLOCK\r
debug1: fd 2 clearing O_NONBLOCK\r
Transferred: sent 8380, received 2880 bytes, in 0.0 seconds\r
Bytes per second: sent 1165702.7, received 400623.4\r
debug1: Exit status 0\r
")
<x.y.z.k> PUT /root/.ansible/tmp/ansible-local-13790fq9EQL/tmpe5jOht TO /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/args
<x.y.z.k> SSH: EXEC sftp -b - -v -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=username_that_can_ssh -o ConnectTimeout=10 '[x.y.z.k]'
<x.y.z.k> (0, 'sftp> put /root/.ansible/tmp/ansible-local-13790fq9EQL/tmpe5jOht /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/args
', "OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017\r
debug1: Reading configuration data /etc/ssh/ssh_config\r
debug1: /etc/ssh/ssh_config line 19: Applying options for *\r
debug1: Connecting to x.y.z.k [x.y.z.k] port 22.\r
debug1: fd 3 clearing O_NONBLOCK\r
debug1: Connection established.\r
debug1: permanently_set_uid: 0/0\r
debug1: identity file /root/.ssh/id_rsa type 0\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_rsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519 type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519-cert type -1\r
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1\r
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8\r
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000\r
debug1: Authenticating to x.y.z.k:22 as 'username_that_can_ssh'\r
debug1: SSH2_MSG_KEXINIT sent\r
debug1: SSH2_MSG_KEXINIT received\r
debug1: kex: algorithm: curve25519-sha256@libssh.org\r
debug1: kex: host key algorithm: ecdsa-sha2-nistp256\r
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:K2X/2dqXd9uK58FPAS32uGYzGSJADRUsIleDobsDLGU\r
debug1: Host 'x.y.z.k' is known and matches the ECDSA host key.\r
debug1: Found key in /root/.ssh/known_hosts:1\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_NEWKEYS sent\r
debug1: expecting SSH2_MSG_NEWKEYS\r
debug1: SSH2_MSG_NEWKEYS received\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_SERVICE_ACCEPT received\r
debug1: Authentications that can continue: publickey,password\r
debug1: Next authentication method: publickey\r
debug1: Offering public key: RSA SHA256:qrWNCrHhzq2FHUGkr2FDpcUTVpklV7lbNaA1zKczg6Q /root/.ssh/id_rsa\r
debug1: Server accepts key: pkalg ssh-rsa blen 279\r
debug1: Authentication succeeded (publickey).\r
Authenticated to x.y.z.k ([x.y.z.k]:22).\r
debug1: channel 0: new [client-session]\r
debug1: Requesting no-more-sessions@openssh.com\r
debug1: Entering interactive session.\r
debug1: pledge: network\r
debug1: Sending environment.\r
debug1: Sending env LANG = en_US.UTF-8\r
debug1: Sending subsystem: sftp\r
debug1: Couldn't stat remote file: No such file or directory\r
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r
debug1: channel 0: free: client-session, nchannels 1\r
debug1: fd 0 clearing O_NONBLOCK\r
debug1: fd 2 clearing O_NONBLOCK\r
Transferred: sent 3716, received 2880 bytes, in 0.0 seconds\r
Bytes per second: sent 522197.7, received 404717.2\r
debug1: Exit status 0\r
")
<x.y.z.k> ESTABLISH SSH CONNECTION FOR USER: username_that_can_ssh
<x.y.z.k> SSH: EXEC ssh -v -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=username_that_can_ssh -o ConnectTimeout=10 x.y.z.k '/bin/sh -c '"'"'chmod u+x /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/ /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/AnsiballZ_win_dsc.py /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/args && sleep 0'"'"''
<x.y.z.k> (0, '', "OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017\r
debug1: Reading configuration data /etc/ssh/ssh_config\r
debug1: /etc/ssh/ssh_config line 19: Applying options for *\r
debug1: Connecting to x.y.z.k [x.y.z.k] port 22.\r
debug1: fd 3 clearing O_NONBLOCK\r
debug1: Connection established.\r
debug1: permanently_set_uid: 0/0\r
debug1: identity file /root/.ssh/id_rsa type 0\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_rsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519 type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519-cert type -1\r
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1\r
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8\r
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000\r
debug1: Authenticating to x.y.z.k:22 as 'username_that_can_ssh'\r
debug1: SSH2_MSG_KEXINIT sent\r
debug1: SSH2_MSG_KEXINIT received\r
debug1: kex: algorithm: curve25519-sha256@libssh.org\r
debug1: kex: host key algorithm: ecdsa-sha2-nistp256\r
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:K2X/2dqXd9uK58FPAS32uGYzGSJADRUsIleDobsDLGU\r
debug1: Host 'x.y.z.k' is known and matches the ECDSA host key.\r
debug1: Found key in /root/.ssh/known_hosts:1\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_NEWKEYS sent\r
debug1: expecting SSH2_MSG_NEWKEYS\r
debug1: SSH2_MSG_NEWKEYS received\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_SERVICE_ACCEPT received\r
debug1: Authentications that can continue: publickey,password\r
debug1: Next authentication method: publickey\r
debug1: Offering public key: RSA SHA256:qrWNCrHhzq2FHUGkr2FDpcUTVpklV7lbNaA1zKczg6Q /root/.ssh/id_rsa\r
debug1: Server accepts key: pkalg ssh-rsa blen 279\r
debug1: Authentication succeeded (publickey).\r
Authenticated to x.y.z.k ([x.y.z.k]:22).\r
debug1: channel 0: new [client-session]\r
debug1: Requesting no-more-sessions@openssh.com\r
debug1: Entering interactive session.\r
debug1: pledge: network\r
debug1: Sending environment.\r
debug1: Sending env LANG = en_US.UTF-8\r
debug1: Sending command: /bin/sh -c 'chmod u+x /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/ /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/AnsiballZ_win_dsc.py /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/args && sleep 0'\r
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0\r
debug1: channel 0: free: client-session, nchannels 1\r
debug1: fd 1 clearing O_NONBLOCK\r
debug1: fd 2 clearing O_NONBLOCK\r
Transferred: sent 2936, received 2492 bytes, in 0.0 seconds\r
Bytes per second: sent 574664.1, received 487759.8\r
debug1: Exit status 0\r
")
<x.y.z.k> ESTABLISH SSH CONNECTION FOR USER: username_that_can_ssh
<x.y.z.k> SSH: EXEC ssh -v -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=username_that_can_ssh -o ConnectTimeout=10 -tt x.y.z.k '/bin/sh -c '"'"'/usr/bin/python /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/AnsiballZ_win_dsc.py /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/args && sleep 0'"'"''
<x.y.z.k> (0, '', "OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017\r
debug1: Reading configuration data /etc/ssh/ssh_config\r
debug1: /etc/ssh/ssh_config line 19: Applying options for *\r
debug1: Connecting to x.y.z.k [x.y.z.k] port 22.\r
debug1: fd 3 clearing O_NONBLOCK\r
debug1: Connection established.\r
debug1: permanently_set_uid: 0/0\r
debug1: identity file /root/.ssh/id_rsa type 0\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_rsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_dsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ecdsa-cert type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519 type -1\r
debug1: key_load_public: No such file or directory\r
debug1: identity file /root/.ssh/id_ed25519-cert type -1\r
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.1\r
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8\r
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000\r
debug1: Authenticating to x.y.z.k:22 as 'username_that_can_ssh'\r
debug1: SSH2_MSG_KEXINIT sent\r
debug1: SSH2_MSG_KEXINIT received\r
debug1: kex: algorithm: curve25519-sha256@libssh.org\r
debug1: kex: host key algorithm: ecdsa-sha2-nistp256\r
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none\r
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY\r
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:K2X/2dqXd9uK58FPAS32uGYzGSJADRUsIleDobsDLGU\r
debug1: Host 'x.y.z.k' is known and matches the ECDSA host key.\r
debug1: Found key in /root/.ssh/known_hosts:1\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_NEWKEYS sent\r
debug1: expecting SSH2_MSG_NEWKEYS\r
debug1: SSH2_MSG_NEWKEYS received\r
debug1: rekey after 134217728 blocks\r
debug1: SSH2_MSG_SERVICE_ACCEPT received\r
debug1: Authentications that can continue: publickey,password\r
debug1: Next authentication method: publickey\r
debug1: Offering public key: RSA SHA256:qrWNCrHhzq2FHUGkr2FDpcUTVpklV7lbNaA1zKczg6Q /root/.ssh/id_rsa\r
debug1: Server accepts key: pkalg ssh-rsa blen 279\r
debug1: Authentication succeeded (publickey).\r
Authenticated to x.y.z.k ([x.y.z.k]:22).\r
debug1: channel 0: new [client-session]\r
debug1: Requesting no-more-sessions@openssh.com\r
debug1: Entering interactive session.\r
debug1: pledge: network\r
debug1: Sending environment.\r
debug1: Sending env LANG = en_US.UTF-8\r
debug1: Sending command: /bin/sh -c '/usr/bin/python /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/AnsiballZ_win_dsc.py /home/username_that_can_ssh/.ansible/tmp/ansible-tmp-1548090872.95-75483031406585/args && sleep 0'\r
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0\r
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0\r
debug1: channel 0: free: client-session, nchannels 1\r
debug1: fd 1 clearing O_NONBLOCK\r
debug1: fd 2 clearing O_NONBLOCK\r
Connection to x.y.z.k closed.\r
Transferred: sent 3212, received 2512 bytes, in 0.0 seconds\r
Bytes per second: sent 209018.9, received 163466.8\r
debug1: Exit status 0\r
")

0 个答案:

没有答案