From: louxnix Date: Wed, 10 Feb 2016 07:37:57 +0000 (+0100) Subject: Limit vagrant fields if more than 4 X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=f463f323f7f0a65703fb7bba12b7561904254dd5;p=ansiblebook.git Limit vagrant fields if more than 4 Vagrant metadata contains 5 fields: 1455035554,vagrant1,metadata,provider,virtualbox vagrant --version Vagrant 1.8.1 --- diff --git a/ch03/inventory/vagrant.py b/ch03/inventory/vagrant.py index 5a2b69a..767a6f0 100755 --- a/ch03/inventory/vagrant.py +++ b/ch03/inventory/vagrant.py @@ -21,7 +21,7 @@ def list_running_hosts(): status = subprocess.check_output(cmd.split()).rstrip() hosts = [] for line in status.split('\n'): - (_, host, key, value) = line.split(',') + (_, host, key, value) = line.split(',')[:4] if key == 'state' and value == 'running': hosts.append(host) return hosts