Ansible nested playbooks with variables I have an ansible playbook add_dns_record.yml that register the A record and relative PTR of an host to our MS DNS server.

- hosts: my_ad_dns
  remote_user: "{{ lookup('env', 'USER') }}@MYDOMAIN.COM"
  gather_facts: false
  tasks:
  - name: Create A record
    win_dns_record:
      computer_name: "{{ inventory_hostname }}"
      name: "{{ dns_a_name }}"
      type: "A"
      value: "{{ dns_ip_address }}"
      zone: "MYDOMAIN.COM"
      state: present

  - name: Create PTR
    ...


I have another playbook debian_base.yml used to prepare debian servers:

- hosts: debian
  tasks:

    - name: install python
      raw: test -e /usr/bin/python || (apt -y update &amp;&amp; apt install -y python-minimal)

    - name: Set hostname
      hostname:
        name: "{{ inventory_hostname }}"


    - name: Update repositories cache and install pre-requirements
      apt:
        name: "{{ packages}}"
        update_cache: yes
      vars:
        packages:
        - sudo
        - apt-transport-https
        - cloud-guest-utils
        - open-vm-tools
        - screen
        - dirmngr
        - openjdk-8-jdk-headless
        - dos2unix
        ....


I want that every debian server deployed using the playbook debian_base.yml get registered on the MS DNS.

I had a look to import_playbook but it doesn't accept variables.

What are the best practices to achieve that?
the best way I think is to create a var  yml file and include it in your ansible-books:

    - name: Include vars of stuff.yaml into the 'stuff' variable (2.2).
      include_vars:
        file: stuff.yaml
        name: stuff


see include_vars_module