Using groupvars in the Ansible inventory

In inventory:

[centos]
centos1 ansible_port=2222
centos[2:3] 

[centos:vars]
ansible_user=root

[ubuntu]
ubuntu[1:3]

[ubuntu:vars]
ansible_become=true
ansible_become_password=password

Within [centos:vars] and [ubuntu:vars] we've added the specific variables where each of the groups [centos] and [ubuntu] will receive.