myops/scripts/common/ansible/run_playbook.py
pengtao 8e0fb41973 1
2021-06-23 14:49:35 +08:00

24 lines
617 B
Python

from .task import Runner
# You may want this to run as user root instead
# or make this an environmental variable, or
# a CLI prompt. Whatever you want!
become_user_password = 'foo-whatever'
run_data = {
"user_id": 12345,
'foo': 'bar',
'baz': 'cux-or-whatever-this-one-is'
}
runner = Runner(hostnames='192.168.10.233'
playbook='run.yaml',
private_key='/home/user/.ssh/id_whatever',
run_data=run_data,
become_pass=become_user_password,
verbosity=0)
stats = runner.run()
# Maybe do something with stats here? If you want!