Scott Baker | 2290b05 | 2014-05-08 10:28:22 -0700 | [diff] [blame] | 1 | import ansible.playbook |
| 2 | import ansible.constants as C |
| 3 | import ansible.utils.template |
| 4 | from ansible import errors |
| 5 | from ansible import callbacks |
| 6 | from ansible import utils |
| 7 | from subprocess import call |
| 8 | |
| 9 | class ConfigurationPush: |
| 10 | def __init__(self): |
| 11 | pass |
| 12 | |
| 13 | def config_push(self, service_name, user, playbook_name,hostfile): |
| 14 | '''stats = callbacks.AggregateStats() |
| 15 | playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY) |
| 16 | runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY) |
| 17 | pb = ansible.playbook.PlayBook(playbook="playbook/site.yml", |
| 18 | callbacks=playbook_cb, |
| 19 | runner_callbacks=runner_cb, |
| 20 | stats=stats |
| 21 | ) |
| 22 | result = pb.run() |
| 23 | print result |
| 24 | ''' |
| 25 | |
| 26 | call("ansible-playbook --private-key=planetw "+playbook_name+" -i "+hostfile+" -u "+user+" --extra-vars \"name="+service_name+"\"", shell=True) |
| 27 | |
| 28 | |
| 29 | if __name__ == "__main__": |
| 30 | main() |