ansible剧本不会执行,也不会显示任何错误,但不会对主机产生任何影响

问题描述

尝试将ansible与wago控制器结合使用 主机文件设置正确。在进入客户编码之前,我想检查是否一切都按预期进行。因此,我确实创建了一个小的简单测试剧本,仅创建了一个文本文件...

 1 ---                                                                                                     
 2 - name: configure wago-controller pfc200
 3   hosts: pfc200
 4   connection: local
 5   become: true
 6   become_user: root
 7   gather_facts: no
 8   vars:
 9    ansible_python_interpreter: /usr/bin/python3
 10  
 11   tasks:
 12  
 13    - name: "information"
 14      command: touch /tmp/hello.txt
 15      register: command_output
 16  
 17    - debug: var=command_output

在控制器python 3上已安装 / tmp文件夹具有以下访问权限

 0 drwxrwxrwt    2 root     root         160 Aug 30 18:16 tmp

执行脚本

sudo ansible-playbook test.yml

带来以下输出

PLAY [configure wago-controller pfc200]      
********************************************************************
TASK [information]   
*****************************************************************************************
[WARNING]: Consider using the file module with state=touch rather than running 'touch'.  If 
you need to use command because file is insufficient you can add 'warn: false' to this
command task or set
'command_warnings=False' in ansible.cfg to get rid of this message.
changed: [pfc200]

TASK [debug]   
************************************************************************************
ok: [pfc200] => {
    "command_output": {
        "changed": true,"cmd": [
        "touch","/tmp/hello.txt"
    ],"delta": "0:00:00.002519","end": "2020-08-30 18:12:48.129959","Failed": false,"rc": 0,"start": "2020-08-30 18:12:48.127440","stderr": "","stderr_lines": [],"stdout": "","stdout_lines": [],"warnings": [
        "Consider using the file module with state=touch rather than running 'touch'.  If you need to use command because file is insufficient you can add 'warn: false' to this command  task or set 'command_warnings=False' in ansible.cfg to get rid of this message."
           ]
       }
    }

     PLAY RECAP ******************************************************************
     pfc200             : ok=2    changed=1    unreachable=0    Failed=0   
     skipped=0    rescued=0    ignored=0  

如果我登录到控制器并检查文件...不存在文件... 在此之前行不通..没有必要进一步深入配置

建议...也请使用shell命令...这会产生相同的效果

解决方法

愚蠢的我...

本地连接

..我在想什么...现在确实出现了一个新错误...我想控制器缺少库zlib ..见下文

 1 ---                                                                                                     
 2 - name: configure wago-controller pfc200
 3   hosts: pfc200
 4#   connection: local
 5   become: true
 6   become_user: root
 7   gather_facts: no
 8   vars:
 9    ansible_python_interpreter: /usr/bin/python3
10  
11   tasks:
12  
13    - name: "information"
14      command: touch /tmp/hello.txt
15      register: command_output
16  
17    - debug: var=command_output

新错误

TASK [information]   
******************************************************************************
An exception occurred during task execution. To see the full traceback,use   
-vvv. The error was: zipimport.ZipImportError: can't decompress data; zlib not 
available
fatal: [pfc200]: FAILED! => {"changed": false,"module_stderr": "Shared
connection to 192.168.4.112 closed.\r\n","module_stdout": "Traceback (most 
recent call last):\r\n  File \"/root/.ansible/tmp/ansible-
tmp-1598822914.27-13741-65296373053829/AnsiballZ_command.py\",line 102,in
<module>\r\n    _ansiballz_main()\r\n  File \"/root/.ansible/tmp/ansible-
tmp-1598822914.27-13741-65296373053829/AnsiballZ_command.py\",line 94,in 
_ansiballz_main\r\n    invoke_module(zipped_mod,temp_path,ANSIBALLZ_PARAMS)\r\n  File \"/root/.ansible/tmp/ansible-
tmp-1598822914.27-13741-65296373053829/AnsiballZ_command.py\",line 37,in 
invoke_module\r\n    from ansible.module_utils import basic\r
\nzipimport.ZipImportError: can't decompress data; zlib not available\r\n","msg": "MODULE FAILURE\nSee stdout/stderr for the exact error","rc": 1}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...