Conflicting action statement in ansible

robert williams picture robert williams · Jun 26, 2016 · Viewed 33.2k times · Source

I am getting the following error : Conflicting action statement in ansible.

I tried to understand, my code seems to be correct. I declared the name correctly though it gives an error in the task name.

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

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

ERROR! conflicting action statements

The error appears to have been in '/home/test/playbooks/debug.yml': line 7, column 7, but may be present elsewhere in the file depending on the exact syntax problem.

The offending line appears to be here:

   tasks:
    - name: debuging module
      ^ here

Answer

Arbab Nazar picture Arbab Nazar · Jun 26, 2016

Here is the problem, you have mixed up two tasks into one:

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

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

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

And out put of the playbook will be like this:

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

Hope that help you