Skip to content
Latchkey

Ansible "conflicting action statements" in CI

A single task lists more than one action/module. Almost always a misindented key landed inside a task that already has a module, so Ansible sees two competing actions.

What this error means

ansible-playbook fails with "conflicting action statements", naming the two modules. The play is valid YAML but semantically invalid because one task cannot run two modules.

ansible
ERROR! conflicting action statements: copy, template

The error appears to be in '/runner/_work/repo/site.yml': line 10, column 7

  - name: Place config
    copy:
      src: app.conf
    template:        <-- a second module in the same task
      src: app.j2

Common causes

Two modules in one task

A second module key sits at the task level instead of being a separate list item, so the task has two actions.

Indentation slip merged two tasks

Wrong indentation folded what should be two list items into one task.

How to fix it

Split into separate tasks

Give each module its own task list item with correct indentation.

site.yml
- name: Place static config
  copy:
    src: app.conf
    dest: /etc/app.conf
- name: Render templated config
  template:
    src: app.j2
    dest: /etc/app.d/app.conf

How to prevent it

  • Keep one module per task; split actions into separate list items.
  • Use consistent indentation so keys do not merge tasks.
  • Run --syntax-check and ansible-lint in CI.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →