2014-01-24 16:59:46 +00:00
|
|
|
#!/usr/bin/python -tt
|
|
|
|
import os
|
|
|
|
import os.path
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
rootpath = "/srv/web/infra/ansible/playbooks"
|
|
|
|
|
|
|
|
#
|
|
|
|
# Find all the .yml files under playbooks/groups and hosts and run ansible-playbook on them
|
|
|
|
# With --check and --diff for now. We don't run the 'manual' subdir ones.
|
|
|
|
|
|
|
|
for dir in ("hosts", "groups"):
|
|
|
|
hostsplaybookspath = os.path.join(rootpath, dir)
|
|
|
|
for path, dirs, files in os.walk(hostsplaybookspath):
|
|
|
|
for file in files:
|
|
|
|
if not file.endswith(".yml"):
|
|
|
|
continue
|
|
|
|
playbookpath = os.path.join(path, file)
|
|
|
|
cmd = ("ansible-playbook", playbookpath, "--check", "--diff")
|
|
|
|
ansibleprocess = subprocess.Popen(cmd)
|
2014-02-03 05:04:01 +00:00
|
|
|
ansibleprocess.communicate()
|