How to pass additional environment variables to the imported ansible playbook

Viewed 124

I have main_play.yml Ansible playbook in which i am importing reusable playbook a.yml.

main_play.yml

- import_playbook: "reusable_playbooks/a.yml"

a.yml

---
- name: my_playbook
  hosts: "{{ HOSTS }}"
  force_handlers: true
  gather_facts: false

  environment:
    APP_DEFAULT_PORT: "{{ APP_DEFAULT_PORT }}"
 
  tasks:
    - name: Print Msg
      debug:
        msg: "hello"

my ask is how can i pass an additional environment variable from my a.yml playbook to my re-usable playbook main_playbook.yml (if needed) so that the environment variables become become like

environment:
    APP_DEFAULT_PORT: "{{ APP_DEFAULT_PORT }}"
    SPRING_PROFILE: "{{ SPRING_PROFILE }}"
0 Answers
Related