Hello,
I created a playbook which needs to call another playbook. This is my current playbook:
---
# file: current_playbook.yml
- hosts: mywebservers
gather_facts: yes
#- import_playbook: another.yml
roles:
- role: testrole1
tags: testrole1
post_tasks:
- name: Install configuration file
template:
src: myconf.j2
dest: /remote-path/myconf
tags: testrole1
- name: Install cron
cron:
name: 'run every day'
minute: '0'
hour: '0'
job: "/remote-path/job"
tags: testrole1
I want to run playbook like: ansible-playbook -i myinventory -l mywebservers current_playbook.yml --tags testrole1. But another.yml playbook needs to run first. Here is another.yml playbook:
---
# file: another.yml
- hosts: all
gather_facts: yes
roles:
- role: myrole1
- role: myrole2
When I comment back in `#- import_playbook: another.yml' line in current_playbook.yml file, I got below error:
ERROR! 'roles' is not a valid attribute for a PlaybookInclude
- import_playbook: another.yml
^ here
How do I call another.yml playbook in my current_playbook.yml file?
Thank you,
- Xinhuan Zheng