Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pass variable to included playbook?

I would like to have a master playbook, which include's other playbooks. Is it possible to pass a variable to that included playbook?

The normal syntax which is used for passing variables to included tasks doesn't work (see below)

- include: someplaybook.yml variable=value

and

- include: someplaybook.yml
  vars:
    variable: value

I'm running v2.0.2.0.

like image 404
CamHart Avatar asked May 12 '16 21:05

CamHart


2 Answers

Tested on ansible 2.4

- import_playbook: any_playbook.yml variable='value'
like image 104
Shah Zobair Avatar answered Sep 28 '22 00:09

Shah Zobair


The only thing i see missing is quotes.

- include: someplaybook.yml variable='value'

It works for me and should work for you too. If not share the error you face.

Make sure you have this variable "variable" defined in the task of the role as well and from here you are just passing the value to that variable.

like image 41
Deepali Mittal Avatar answered Sep 28 '22 00:09

Deepali Mittal