I am currently trying to play a couple of playbooks within another playbook. I use ansible version 2.9.6.
I made a playbook for this that calls out several roles. The reference works. But within the playbook I want to play, I get the following error:
error conflicting action statements hosts tasks
I have multiple files as described above. For convenience, only two will be shown: the main.yml file for apache2 and my playbook to automate the tasks. I've shortened those to only show the conflict statements and added those right below.
serverdeploy code (shortened):
---
# webservers
- hosts: webservers
become: yes
roles:
- apache2
...
main.yml code (shortened):
# task file for apache2
- hosts: webservers
become: yes
tasks:
- name: Installing apache
...
Could anyone help me with this issue? I'd love to know what i'm doing wrong!
Task files in roles can be done with no indentation at all:
E.G.: (BAD)
# This is Playbook (style) which is not right for task file.
# task file for apache2
- hosts: webservers
become: yes
tasks:
- name: Installing apache
apt:
name: apache2
state: latest
...
E.G.: (GOOD)
# This is task file (style) which is how it should be.
# You can ident or leave like this and import/include_file
# task file for apache2
- name: Installing apache
apt:
name: apache2
state: latest
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With