Say you want to upgrade all the servers. Straight yum upgrade or apt update.
ansible \ --inventory/-i [inventory] \ [pattern] \ --module-name/-m [command] \ --args/-a "[module arguments]" \ --become/-b
For example, in my inventory, I have servers grouped by OS. If I wanted to patch all the CentOS boxes sequentially, I’d run:
ansible -i inventory centos -m yum -a "name=* state=latest" -b
For a Debian server:
ansible -i inventory debian -m apt -a "upgrade=yes update_cache=yes" -b
This then upgrades all servers with that pattern sequentially. One after another. Once done, you can then reboot the servers.
ansible -i inventory centos --args "reboot" -b