Playbook to install Multiple options in Ansible

Viewed 34

I wanted to install weblogic and websphere on few servers with Ansible.

But my requirement is, I need to create a Ansible playbook as if i select websphere then it should install websphere and if i select weblogic then it should install weblogic.

Ansible playbook with 2 options and run as per the selection. Please help.

Thank you in advance.

1 Answers

You can use the following

- hosts: all
  become: yes
  vars:
    - weblogic: true
    - websphere: false
  tasks:
    - name: Install weblogic
      yum:
        name: weblogic
        state: present
      when: weblogic

    - name: Install websphere
      yum:
        name: websphere
        state: present
      when: websphere
Related