So, my playbook works fine when using this syntax:
---
- hosts: all
become: true
become_user: root
gather_facts: false
connection: local
vars_files:
- roles/docker_setup/vars/docker_vars.yml
- roles/docker_setup/vars/aws_cred.yml
vars:
instance_ids:
- "i-xxxxxxxxxxx"
tasks:
- include_role:
name: docker_setup
tasks_from: docker_tasks.yml
But I read that you can use this syntax which looks much easier to handle once I want to add new roles to the playbook:
---
- hosts: all
become: true
become_user: root
gather_facts: false
connection: local
vars_files:
- roles/docker_setup/vars/docker_vars.yml
- roles/docker_setup/vars/aws_cred.yml
vars:
instance_ids:
- "i-xxxxxxxxxxx"
roles:
- docker_setup
The difference is:
roles:
- docker_setup
instead of
tasks:
- include_role:
name: docker_setup
tasks_from: docker_tasks.yml
But once I try to run the playbook nothing happens:
sudo ansible-playbook docker_setup.yml --ask-vault-pass -i hosts --user devops --key-file /home/devops/.ssh/id_rsa
Vault password:
PLAY [all] *************************************************************************************************************************************************
PLAY RECAP *************************************************************************************************************************************************
Why is it that? Here is my tree of roles:
.
├── docker_setup
│ ├── handlers
│ │ └── main.yml
│ ├── tasks
│ │ └── docker_tasks.yml
│ └── vars
│ ├── aws_cred.yml
│ └── docker_vars.yml
└── user_host_create
├── handlers
│ └── user_handlers.yml
├── tasks
│ └── user_tasks.yml
└── vars
├── user_password_vault.txt
├── user_password.yml
└── user_vars.yml
and hosts file:
[webservers]
172.31.31.223
Thank you!