How to execute a playbook before a role?

50 views
Skip to first unread message

John Harmon

unread,
Apr 4, 2019, 12:50:55 PM4/4/19
to Ansible Project
This doesn't work of course, but shows what I am trying to do.  I wish to call a playbook before a couple of roles.  How might I do this?

Doesn't work, but is an explanatory example:
---
- hosts: "{{ host }}"

  pre_tasks
:
 
- name: Import gitlab playbook
    import_playbook
:  /etc/ansible/playbooks/one-offs/update_gitlab_scripts.yml

  roles
:
   
- ansible_dependencies
   
- cpu_utilization


Brian Coca

unread,
Apr 4, 2019, 1:04:09 PM4/4/19
to Ansible Project
you cannot have a play inside a play, - import_playbook cannot be in a
task section, but easy enough to do what you want:

- import_playbook: /etc/ansible/playbooks/one-offs/update_gitlab_scripts.yml

- hosts: "{{ host}}"
roles: ....


--
----------
Brian Coca

John Harmon

unread,
Apr 4, 2019, 1:12:57 PM4/4/19
to Ansible Project

Thanks Brian!
Reply all
Reply to author
Forward
0 new messages