--- - name: Defining variable through command line and using it in playbook below hosts: nodes tasks: - name: Installing packages yum: name: "{{ rpm }}" state: latest ... # We have to define a variable value while executing the playbook. # ansible-playbook cmdline_variable -e rpm=zsh these value will pass here inside playbook { -e is to add variable value }