安塞的冲突行动声明

时间:2016-06-26 02:43:00

标签: ansible ansible-playbook ansible-2.x

我收到以下错误:Conflicting action statement in ansible

我试着理解,我的代码似乎是正确的。虽然它在任务名称中给出了错误,但我正确地声明了名称。

---
 - hosts: webhost
   sudo: yes
   connection: ssh

   tasks:
    - name: debuging module
      shell: ps aux
      register: output
      debug: var=output

ERROR! conflicting action statements

错误似乎出现在&#39; /home/test/playbooks/debug.yml' ;:第7行第7列,但可能会出现在文件的其他位置,具体取决于确切的语法问题。< / p>

违规行似乎在这里:

   tasks:
    - name: debuging module
      ^ here

1 个答案:

答案 0 :(得分:5)

问题在于,您将两个任务混合为一个:

---
- hosts: webhost
  sudo: yes
  connection: ssh

  tasks:
    - name: debuging module
      shell: ps aux
      register: output

    - name: show the value of output
      debug: var=output

剧本的出局将是这样的:

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
ok: [192.168.33.100]

TASK [debuging module] *********************************************************
changed: [192.168.33.100]

TASK [show the value of output] ************************************************
ok: [192.168.33.100] => {
    "output": {
        "changed": true,
        "cmd": "ps aux",
        "delta": "0:00:00.004981",
        "end": "2016-06-26 06:25:22.975876",
        "rc": 0,
        "start": "2016-06-26 06:25:22.970895",
        "stderr": "",
        "stdout": "USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND\nroot         1  0.8  0.2  24432  2380 ?        Ss   06:23   0:00 /sbin/init\nroot         2  0.0  0.0

希望能帮到你