I am using the following snippet to execute the playbook, this is the only way I can solve the deployment of servers for the first time as the inventory is not present at that time and lot of orchestration is needed to deploy the cluster with several nodes.
def run_playbook(listVMs, playbook, user, extra_vars=None, key_file=None):
print(datetime.datetime.now())
stats = callbacks.AggregateStats()
playbook_cb = callbacks.PlaybookCallbacks(verbose=utils.VERBOSITY)
runner_cb = callbacks.PlaybookRunnerCallbacks(stats, verbose=utils.VERBOSITY)
pb = ansible.playbook.PlayBook(
host_list=listVMs,
playbook=playbook,
forks=20,
remote_user=user,
remote_pass='xxxxx',
runner_callbacks=runner_cb,
callbacks=playbook_cb,
stats=stats,
extra_vars=extra_vars
)
pb.run()
running one of the playbook with the copying the large 1.5G file is taking excruciatingly 10 minutes.
- name: copy large file
copy: src={{ xxx_largefile }} dest=/yyyy owner=zzz group=zzz
If I run the same playbook from the command line, it is very quick less than a minute.
ansible-playbook --inventory-file=host.ini playbookcopy.yml
What might be the difference, I have the latest ansible installed..
How can I make it easy using the above the code snippet.