ship playbooks with python

This patch makes the playbooks ship directly with the Python
files which means no need to run inside working directory.

Change-Id: I3f2d3c95a8443383b47d806e293c9bb75d9fcec7
This commit is contained in:
Mohammed Naser 2019-08-23 14:26:15 -04:00
parent eddb78f48a
commit cc4ec215d3
6 changed files with 9 additions and 7 deletions

4
.gitignore vendored
View File

@ -3,4 +3,6 @@
.vagrant
.vscode
__pycache__
*.egg-info
*.egg-info
AUTHORS
ChangeLog

View File

@ -14,6 +14,7 @@
import shutil
import tempfile
import os
import ansible_runner
@ -23,10 +24,11 @@ class Cluster(object):
self.config = config
def deploy(self):
playbooks_dir = "%s/playbooks" % os.path.dirname(__file__)
private_data_dir = tempfile.mkdtemp()
try:
shutil.copytree('ansible', '%s/project' % private_data_dir)
shutil.copytree(playbooks_dir, '%s/project' % private_data_dir)
ansible_runner.run(private_data_dir=private_data_dir,
inventory=self.config.inventory,
playbook='site.yaml')

View File

@ -18,8 +18,6 @@
- name: Test kue-cli
shell: >-
kue-cli --user {{ ansible_user }} {% for master in groups['masters'] %}--master {{ hostvars[master]['ansible_host'] }} {% endfor %}{% for minion in groups['minions'] %}--minion {{ hostvars[minion]['ansible_host'] }} {% endfor %}
args:
chdir: "{{ zuul.project.src_dir }}"
- hosts: masters[0]
tasks:

View File

@ -1,9 +1,9 @@
[tox]
skipsdist = True
#[tox]
#skipsdist = True
[testenv]
basepython = python3
usedevelop = True
#usedevelop = True
passenv = SSH_AUTH_SOCK
deps =
-r{toxinidir}/requirements.txt