On Wed, Jan 22, 2020 at 3:47 PM Xinhuan Zheng <[email protected]> wrote:
>
> 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
>
      Take a look again at the example in
https://docs.ansible.com/ansible/latest/modules/import_playbook_module.html.
To me it does not know where


  roles:
    - role: testrole1
      tags: testrole1

belongs. Should it be

- hosts: mywebservers
  gather_facts: yes

  roles:
    - role: testrole1
      tags: testrole1

#- import_playbook: another.yml

i.e. those roles are related to mywebservers? Or are they related to
all hosts as defined in another.yml?

> --
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/ansible-project/d725708b-622c-4f93-b25c-89cddc114d38%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAHEKYV7EWfi38dbxpk%2BS2DFjYEQm-r60at%2Bb_OjX0u7pKa-ByA%40mail.gmail.com.

Reply via email to