Add simple script that runs --check --diff playbook runs on all hosts/groups.
This commit is contained in:
parent
083b631c29
commit
0494a018a6
1 changed files with 25 additions and 0 deletions
25
scripts/ansible-playbook-check-diff
Executable file
25
scripts/ansible-playbook-check-diff
Executable file
|
@ -0,0 +1,25 @@
|
|||
#!/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)
|
||||
|
||||
#
|
||||
# Add this if you want to run them one at a time instead of all forked off in a bunch.
|
||||
# ansibleprocess.communicate()
|
||||
#
|
Loading…
Add table
Add a link
Reference in a new issue