Hello Team ,
I am having 3 vendors Ex :HP ,DELL ,Lenovo
i have 3 separate playbooks
Now i want to execute those based on vendor .If it is HP it should call Hp Playbook Likewise…Can some one please help.
Hello Team ,
I am having 3 vendors Ex :HP ,DELL ,Lenovo
i have 3 separate playbooks
Now i want to execute those based on vendor .If it is HP it should call Hp Playbook Likewise…Can some one please help.
Use conditionals as in when
You can see the vendor when gather facts and set condition when vendor = hp
Hello Team ,
I am having 3 vendors Ex :HP ,DELL ,Lenovo
i have 3 separate playbooks
Now i want to execute those based on vendor .If it is HP it should call
Hp Playbook Likewise..Can some one please help.
It's not possible to conditionally run a playbook from another
playbook. Instead, rewrite the playbooks to roles for a
particular HW. For example
cat roles/role2/tasks/main.yml
- debug:
msg: Runing on Dell
The playbook
- hosts: localhost
gather_facts: true
vars:
my_hw: "{{ ansible_system_vendor.split().0 }}"
my_roles:
HP: role1
Dell: role2
Lenovo: role3
tasks:
- debug:
msg: "{{ my_hw }} is in in my_roles: {{ my_hw in my_roles }}"
- include_role:
name: "{{ my_roles[my_hw] }}"
when: my_hw in my_roles
gives
msg: 'Dell is in in my_roles: True'
msg: Runing on Dell