how can I override the ansible.cfg with command line argument

I have servers with different ssh ports, the default port is configured in ansible.cfg, how can I override the remote_port setting with command line argument? thanks

Hi,

try ansible_ssh_port: http://www.ansibleworks.com/docs/faq.html#id2

My inventory file is big, I want to keep it clean, changing every line is not so good.

Add it to a group then.

you can also use extra vars: -e ‘ansible_ssh_port=2343’

to Michael,
I known add it to the group, but it is not best practice.

to Brian,
do you mean add -e in command line? I got an error that:

ansible -i xcloud all -a ‘w’ -e ‘ansible_ssh_port=22’
Usage: ansible [options]

ansible: error: no such option: -e

-e is for ansible-playbook, sorry, i didn’t realize you were using the oneliner