-1

Trying to use ansible in combination with a wago controller host-file is set up correctly. Before getting in the custome coding i want to check if everything works as expected. Therefore i did create a small simple test playbook which just creates a text file ...

 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

on the controller python 3 is installed /tmp folder has the following access rights

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

executing the script

sudo ansible-playbook test.yml

brings the following outputs

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  

if i log into the controller and check for the file ...no file is present... Before this does not work ..it does not make sense to dive deeper into the configuration

Advice...did also check with the shell command...which leads to the same effect..

tlo
  • 1,571
  • 1
  • 25
  • 38
mmm
  • 51
  • 8
  • If all you want to do is to create an empty file to test, you could use the [file module](https://docs.ansible.com/ansible/latest/modules/file_module.html) with `state: touch` option. – seshadri_c Aug 30 '20 at 16:57
  • i guess it is no the command...it is the fact that it runs through and does give me no idea why it is not working....the touch file command was for demonstration if i can access the controller and if i can issue a command... – mmm Aug 30 '20 at 17:15
  • I'd guess you have some setup that maps `/tmp` per session and then cleans it on logout; since you're running as root, try touching a file that is in a more durable location, such as `/root` or `/etc` or even `/` – mdaniel Aug 30 '20 at 18:53
  • same shit...sorry ..just thought that would make sense...this drives me nuts... – mmm Aug 30 '20 at 18:55

1 Answers1

0

Silly me...

connection local

..what was i thinking...besides that a new error did show up now... i guess the controller is missing the library zlib.. see below

 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

new error

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}
mmm
  • 51
  • 8