Ansible: Upgrading Debian with Ad-Hoc commands

Profile picture for user Phil Frilling
By Phil Frilling, 20 June, 2017
Upgrading an inventory of three servers using ansible, I can use the following command to make this happen:

ansible -i Inventory -m apt -a "upgrade=yes update_cache=yes cache_valid_time=86400" -b -B 3600 all
This command does the following: 1. Use the inventory file named "Inventory" 2. Run the Ansible module "apt" 3. Run the ad-hoc command for the apt module "upgrade=yes update_cache=yes cache_valid_time=86400" 4. The -b makes the user become sudo. 5. -B 3600 runs the command in the background, asynchronously, on all servers in the grouping, with a timeout of 3600 seconds. 6. "all" runs the command on the group named "all"