mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 08:35:21 +00:00
add ansible playbook test
This commit is contained in:
parent
a5677a5ed1
commit
a1423c2a1f
@ -37,3 +37,5 @@ junos-eznc
|
||||
jxmlease
|
||||
croniter
|
||||
kazoo
|
||||
ansible; sys.platform != 'win32' and sys.platform != 'darwin' and python_version >= '3.5'
|
||||
ansible; sys.platform != 'win32' and sys.platform != 'darwin' and python_version == '2.7'
|
||||
|
68
tests/integration/states/test_ansiblegate.py
Normal file
68
tests/integration/states/test_ansiblegate.py
Normal file
@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Test AnsibleGate State Module
|
||||
'''
|
||||
from __future__ import absolute_import, unicode_literals, print_function
|
||||
|
||||
# Import python libraries
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import yaml
|
||||
|
||||
# Import salt libraries
|
||||
import salt.utils.path
|
||||
|
||||
# Import testing libraries
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import destructiveTest
|
||||
from tests.support.mixins import SaltReturnAssertsMixin
|
||||
from tests.support.paths import FILES, TMP
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
@destructiveTest
|
||||
@skipIf(not salt.utils.path.which('ansible-playbook'), 'ansible-playbook is not installed')
|
||||
class AnsiblePlaybooksTestCase(ModuleCase, SaltReturnAssertsMixin):
|
||||
'''
|
||||
Test ansible.playbooks states
|
||||
'''
|
||||
def setUp(self):
|
||||
priv_file = os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'key_test')
|
||||
data = {
|
||||
'all': {
|
||||
'hosts': {
|
||||
'localhost': {
|
||||
'ansible_host': '127.0.0.1',
|
||||
'ansible_port': 2827,
|
||||
'ansible_user': RUNTIME_VARS.RUNNING_TESTS_USER,
|
||||
'ansible_ssh_private_key_file': priv_file,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
self.inventory = self.tempdir + 'inventory'
|
||||
with open(self.inventory, 'w') as yaml_file:
|
||||
yaml.dump(data, yaml_file, default_flow_style=False)
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir)
|
||||
delattr(self, 'tempdir')
|
||||
delattr(self, 'inventory')
|
||||
|
||||
def test_ansible_playbook(self):
|
||||
ret = self.run_state(
|
||||
'ansible.playbooks',
|
||||
name='remove.yml',
|
||||
gitrepo='git://github.com/gtmanfred/playbooks.git',
|
||||
ansible_kwargs={'inventory': self.inventory}
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
ret = self.run_state(
|
||||
'ansible.playbooks',
|
||||
name='install.yml',
|
||||
gitrepo='git://github.com/gtmanfred/playbooks.git',
|
||||
ansible_kwargs={'inventory': self.inventory}
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
Loading…
Reference in New Issue
Block a user