尝试将 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命令...导致相同的效果..