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.j2Common 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.confHow 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
Ansible "Syntax Error while loading YAML" in CIFix Ansible "Syntax Error while loading YAML" in CI -- malformed playbook YAML: bad indentation, an unquoted…
ansible-lint failures blocking CIFix ansible-lint failures that block CI -- rule violations (FQCN, no-changed-when, risky shell) or a profile/…
Ansible "'X' is undefined" variable error in CIFix Ansible "'X' is undefined" in CI -- a task or template references a variable that was never defined, ofte…