Various tests using datafiles are being moved into the integration test framework (tests_new right now).

The unit test infrastructure will remain for things that are mocked out and testable with out filesystem
side effects, and a few cases of things that might not be quite so much (like inventory) that can still
benefit from heavy access to the API.

See the 'tests_new/integration' directory, this will soon fold into tests_new.
This commit is contained in:
Michael DeHaan 2014-02-20 16:20:05 -05:00
parent 0581746a80
commit fe7d3773ae
42 changed files with 0 additions and 1607 deletions

View file

@ -1,4 +0,0 @@
---
# could test something different here but want people running tests on
# different OS platforms to still have passing tests
testing: default

View file

@ -1,62 +0,0 @@
# (C) 2013, Michael Scherer, <misc@zarb.org>
# This file is part of Ansible
#
# Ansible is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Ansible is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
import os
import unittest
import subprocess
# if you change here, also change in the plugin
FILE_DISABLE = '/tmp/ansible_test_disable'
FILE_RUN = '/tmp/ansible_test_finish'
class TestInventory(unittest.TestCase):
def setUp(self):
self.cwd = os.getcwd()
os.chdir(os.path.join(os.path.dirname(__file__), 'test_callbacks'))
def clean_file(self):
if os.path.exists(FILE_RUN):
os.unlink(FILE_RUN)
if os.path.exists(FILE_DISABLE):
os.unlink(FILE_DISABLE)
def tearDown(self):
os.chdir(self.cwd)
def run_ansible_playbook(self):
subprocess.call(('source ../../hacking/env-setup 2>&1 >/dev/null;'
'ansible-playbook -i "127.0.0.1," test_playbook.yml 2>&1 >/dev/null'),
shell=True, executable='/bin/bash')
def test_callback(self):
self.clean_file()
self.run_ansible_playbook()
assert os.path.exists(FILE_RUN)
self.clean_file()
def test_callback_disabled(self):
self.clean_file()
open(FILE_DISABLE, 'w').close()
self.run_ansible_playbook()
assert not os.path.exists(FILE_RUN)
self.clean_file()

View file

@ -1,443 +0,0 @@
# tests are fairly 'live' (but safe to run)
# setup authorized_keys for logged in user such
# that the user can log in as themselves before running tests
import unittest
import getpass
import ansible.playbook
import ansible.utils as utils
import ansible.callbacks as ans_callbacks
import os
import shutil
import ansible.constants as C
EVENTS = []
class TestCallbacks(object):
# using same callbacks class for both runner and playbook
def __init__(self):
pass
def set_playbook(self, playbook):
self.playbook = playbook
def on_no_hosts_remaining(self):
pass
def on_start(self):
EVENTS.append('start')
def on_skipped(self, host, item=None):
EVENTS.append([ 'skipped', [ host ]])
def on_import_for_host(self, host, filename):
EVENTS.append([ 'import', [ host, filename ]])
def on_error(self, host, msg):
EVENTS.append([ 'stderr', [ host, msg ]])
def on_not_import_for_host(self, host, missing_filename):
pass
def on_notify(self, host, handler):
EVENTS.append([ 'notify', [ host, handler ]])
def on_task_start(self, name, is_conditional):
EVENTS.append([ 'task start', [ name, is_conditional ]])
def on_failed(self, host, results, ignore_errors):
EVENTS.append([ 'failed', [ host, results, ignore_errors ]])
def on_ok(self, host, result):
# delete certain info from host_result to make test comparisons easier
host_result = result.copy()
for k in [ 'ansible_job_id', 'results_file', 'md5sum', 'delta', 'start', 'end' ]:
if k in host_result:
del host_result[k]
for k in host_result.keys():
if k.startswith('facter_') or k.startswith('ohai_'):
del host_result[k]
EVENTS.append([ 'ok', [ host, host_result ]])
def on_play_start(self, pattern):
EVENTS.append([ 'play start', [ pattern ]])
def on_async_ok(self, host, res, jid):
EVENTS.append([ 'async ok', [ host ]])
def on_async_poll(self, host, res, jid, clock):
EVENTS.append([ 'async poll', [ host ]])
def on_async_failed(self, host, res, jid):
EVENTS.append([ 'async failed', [ host ]])
def on_unreachable(self, host, msg):
EVENTS.append([ 'failed/dark', [ host, msg ]])
def on_setup(self):
pass
def on_no_hosts(self):
pass
class TestPlaybook(unittest.TestCase):
def setUp(self):
self.user = getpass.getuser()
self.cwd = os.getcwd()
self.test_dir = os.path.join(self.cwd, 'test')
self.stage_dir = self._prepare_stage_dir()
if os.path.exists('/tmp/ansible_test_data_copy.out'):
os.unlink('/tmp/ansible_test_data_copy.out')
if os.path.exists('/tmp/ansible_test_data_template.out'):
os.unlink('/tmp/ansible_test_data_template.out')
if os.path.exists('/tmp/ansible_test_messages.out'):
os.unlink('/tmp/ansible_test_messages.out')
if os.path.exists('/tmp/ansible_test_role_messages.out'):
os.unlink('/tmp/ansible_test_role_messages.out')
def _prepare_stage_dir(self):
stage_path = os.path.join(self.test_dir, 'test_data')
if os.path.exists(stage_path):
shutil.rmtree(stage_path, ignore_errors=False)
assert not os.path.exists(stage_path)
os.makedirs(stage_path)
assert os.path.exists(stage_path)
return stage_path
def _get_test_file(self, filename):
# get a file inside the test input directory
filename = os.path.join(self.test_dir, filename)
assert os.path.exists(filename)
return filename
def _get_stage_file(self, filename):
# get a file inside the test output directory
filename = os.path.join(self.stage_dir, filename)
return filename
def _run(self, test_playbook, host_list='test/ansible_hosts', extra_vars=None):
''' run a module and get the localhost results '''
# This ensures tests are independent of eachother
global EVENTS
ansible.playbook.SETUP_CACHE.clear()
EVENTS = []
self.test_callbacks = TestCallbacks()
self.playbook = ansible.playbook.PlayBook(
playbook = test_playbook,
host_list = host_list,
module_path = 'library/',
forks = 1,
timeout = 5,
remote_user = self.user,
remote_pass = None,
extra_vars = extra_vars,
stats = ans_callbacks.AggregateStats(),
callbacks = self.test_callbacks,
runner_callbacks = self.test_callbacks
)
result = self.playbook.run()
return result
def test_playbook_vars(self):
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'test_playbook_vars', 'playbook.yml'),
host_list='test/test_playbook_vars/hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
playbook.run()
def _test_playbook_undefined_vars(self, playbook, fail_on_undefined):
# save DEFAULT_UNDEFINED_VAR_BEHAVIOR so we can restore it in the end of the test
saved_undefined_var_behavior = C.DEFAULT_UNDEFINED_VAR_BEHAVIOR
C.DEFAULT_UNDEFINED_VAR_BEHAVIOR = fail_on_undefined
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'test_playbook_undefined_vars', playbook),
host_list='test/test_playbook_undefined_vars/hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
actual = playbook.run()
C.DEFAULT_UNDEFINED_VAR_BEHAVIOR = saved_undefined_var_behavior
# if different, this will output to screen
print "**ACTUAL**"
print utils.jsonify(actual, format=True)
expected = {
"localhost": {
"changed": 0,
"failures": 0,
"ok": int(not fail_on_undefined) + 1,
"skipped": 0,
"unreachable": int(fail_on_undefined)
}
}
print "**EXPECTED**"
print utils.jsonify(expected, format=True)
assert utils.jsonify(expected, format=True) == utils.jsonify(actual, format=True)
#def test_playbook_undefined_vars1_ignore(self):
# self._test_playbook_undefined_vars('playbook1.yml', False)
#def test_playbook_undefined_vars1_fail(self):
# self._test_playbook_undefined_vars('playbook1.yml', True)
#def test_playbook_undefined_vars2_ignore(self):
# self._test_playbook_undefined_vars('playbook2.yml', False)
#def test_playbook_undefined_vars2_fail(self):
# self._test_playbook_undefined_vars('playbook2.yml', True)
def test_yaml_hosts_list(self):
# Make sure playbooks support hosts: [host1, host2]
# TODO: Actually run the play on more than one host
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'hosts_list.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
play = ansible.playbook.Play(playbook, playbook.playbook[0], os.getcwd())
assert play.hosts == ';'.join(('host1', 'host2', 'host3'))
def test_playbook_hash_replace(self):
# save default hash behavior so we can restore it in the end of the test
saved_hash_behavior = C.DEFAULT_HASH_BEHAVIOUR
C.DEFAULT_HASH_BEHAVIOUR = "replace"
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'test_hash_behavior', 'playbook.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
playbook.run()
filename = '/tmp/ansible_test_messages.out'
expected_lines = [
"goodbye: Goodbye World!"
]
self._compare_file_output(filename, expected_lines)
filename = '/tmp/ansible_test_role_messages.out'
expected_lines = [
"inside_a_role: Indeed!"
]
self._compare_file_output(filename, expected_lines)
# restore default hash behavior
C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior
def test_playbook_hash_merge(self):
# save default hash behavior so we can restore it in the end of the test
saved_hash_behavior = C.DEFAULT_HASH_BEHAVIOUR
C.DEFAULT_HASH_BEHAVIOUR = "merge"
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'test_hash_behavior', 'playbook.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
playbook.run()
filename = '/tmp/ansible_test_messages.out'
expected_lines = [
"goodbye: Goodbye World!",
"hello: Hello World!"
]
self._compare_file_output(filename, expected_lines)
filename = '/tmp/ansible_test_role_messages.out'
expected_lines = [
"goodbye: Goodbye World!",
"hello: Hello World!",
"inside_a_role: Indeed!"
]
self._compare_file_output(filename, expected_lines)
# restore default hash behavior
C.DEFAULT_HASH_BEHAVIOUR = saved_hash_behavior
def test_playbook_ignore_errors(self):
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'playbook-ignore-errors.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
actual = playbook.run()
# if different, this will output to screen
print "**ACTUAL**"
print utils.jsonify(actual, format=True)
expected = {
"localhost": {
"changed": 1,
"failures": 1,
"ok": 1,
"skipped": 0,
"unreachable": 0
}
}
print "**EXPECTED**"
print utils.jsonify(expected, format=True)
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
def test_playbook_changed_when(self):
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'playbook-changed_when.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
actual = playbook.run()
# if different, this will output to screen
print "**ACTUAL**"
print utils.jsonify(actual, format=True)
expected = {
"localhost": {
"changed": 3,
"failures": 0,
"ok": 6,
"skipped": 0,
"unreachable": 0
}
}
print "**EXPECTED**"
print utils.jsonify(expected, format=True)
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
def test_playbook_failed_when(self):
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'playbook-failed_when.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks
)
actual = playbook.run()
# if different, this will output to screen
print "**ACTUAL**"
print utils.jsonify(actual, format=True)
expected = {
"localhost": {
"changed": 2,
"failures": 1,
"ok": 2,
"skipped": 0,
"unreachable": 0
}
}
print "**EXPECTED**"
print utils.jsonify(expected, format=True)
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
def test_playbook_always_run(self):
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(
playbook=os.path.join(self.test_dir, 'playbook-always-run.yml'),
host_list='test/ansible_hosts',
stats=ans_callbacks.AggregateStats(),
callbacks=test_callbacks,
runner_callbacks=test_callbacks,
check=True
)
actual = playbook.run()
# if different, this will output to screen
print "**ACTUAL**"
print utils.jsonify(actual, format=True)
expected = {
"localhost": {
"changed": 4,
"failures": 0,
"ok": 4,
"skipped": 8,
"unreachable": 0
}
}
print "**EXPECTED**"
print utils.jsonify(expected, format=True)
assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
#def test_playbook_logging_non_ascii(self):
# pb = 'test/playbook-logging-non-ascii.yml'
# actual = self._run(pb)
#
# expected = {
# "localhost": {
# "changed": 3,
# "failures": 0,
# "ok": 3,
# "skipped": 0,
# "unreachable": 0
# }
# }
#
# assert utils.jsonify(expected, format=True) == utils.jsonify(actual, format=True)
# Disabled for now as there are permissions issues that happen if you are not the owner that created files
# in the archive.
# def test_unarchive(self):
# pb = 'test/playbook-unarchive.yml'
# actual = self._run(pb)
#
# expected = {
# "localhost": {
# "changed": 29,
# "failures": 0,
# "ok": 33,
# "skipped": 12,
# "unreachable": 0
# }
# }
#
# assert utils.jsonify(expected, format=True) == utils.jsonify(actual,format=True)
def _compare_file_output(self, filename, expected_lines):
actual_lines = []
with open(filename) as f:
actual_lines = [l.strip() for l in f.readlines()]
actual_lines = sorted(actual_lines)
print "**ACTUAL**"
print actual_lines
print "**EXPECTED**"
print expected_lines
assert actual_lines == expected_lines

View file

@ -1,129 +0,0 @@
# tests are fairly 'live' (but safe to run)
# setup authorized_keys for logged in user such
# that the user can log in as themselves before running tests
import unittest
import getpass
import ansible.runner
import os
import shutil
import time
import tempfile
from nose.plugins.skip import SkipTest
def get_binary(name):
for directory in os.environ["PATH"].split(os.pathsep):
path = os.path.join(directory, name)
if os.path.isfile(path) and os.access(path, os.X_OK):
return path
return None
class TestRunner(unittest.TestCase):
def setUp(self):
self.user = getpass.getuser()
self.runner = ansible.runner.Runner(
basedir='test/',
module_name='ping',
module_path='library/',
module_args='',
remote_user=self.user,
remote_pass=None,
host_list='test/ansible_hosts',
timeout=5,
forks=1,
background=0,
pattern='all',
transport='local',
)
self.cwd = os.getcwd()
self.test_dir = os.path.join(self.cwd, 'test')
self.stage_dir = self._prepare_stage_dir()
def _prepare_stage_dir(self):
stage_path = os.path.join(self.test_dir, 'test_data')
if os.path.exists(stage_path):
shutil.rmtree(stage_path, ignore_errors=False)
assert not os.path.exists(stage_path)
os.makedirs(stage_path)
assert os.path.exists(stage_path)
return stage_path
def _get_test_file(self, filename):
# get a file inside the test input directory
filename = os.path.join(self.test_dir, filename)
assert os.path.exists(filename)
return filename
def _get_stage_file(self, filename):
# get a file inside the test output directory
filename = os.path.join(self.stage_dir, filename)
return filename
def _run(self, module_name, module_args, background=0, check_mode=False):
''' run a module and get the localhost results '''
self.runner.module_name = module_name
args = ' '.join(module_args)
self.runner.module_args = args
self.runner.background = background
self.runner.check = check_mode
results = self.runner.run()
# when using nosetests this will only show up on failure
# which is pretty useful
assert "localhost" in results['contacted']
return results['contacted']['localhost']
def test_action_plugins(self):
result = self._run("uncategorized_plugin", [])
assert result.get("msg") == "uncategorized"
result = self._run("categorized_plugin", [])
assert result.get("msg") == "categorized"
def test_ping(self):
result = self._run('ping', [])
assert "ping" in result
def test_async(self):
# test async launch and job status
# of any particular module
result = self._run('command', [get_binary("sleep"), "3"], background=20)
assert 'ansible_job_id' in result
assert 'started' in result
jid = result['ansible_job_id']
# no real chance of this op taking a while, but whatever
time.sleep(5)
# CLI will abstract this (when polling), but this is how it works internally
result = self._run('async_status', ["jid=%s" % jid])
# TODO: would be nice to have tests for supervisory process
# killing job after X seconds
assert 'finished' in result
assert 'failed' not in result
assert 'rc' in result
assert 'stdout' in result
assert result['ansible_job_id'] == jid
def test_assemble(self):
input = self._get_test_file('assemble.d')
output = self._get_stage_file('sample.out')
result = self._run('assemble', [
"src=%s" % input,
"dest=%s" % output,
])
assert os.path.exists(output)
out = file(output).read()
assert out.find("first") != -1
assert out.find("second") != -1
assert out.find("third") != -1
assert result['changed'] is True
assert 'md5sum' in result
assert 'failed' not in result
result = self._run('assemble', [
"src=%s" % input,
"dest=%s" % output,
])
assert result['changed'] is False

View file

@ -16,94 +16,6 @@ sys.setdefaultencoding("utf8")
class TestUtils(unittest.TestCase):
#####################################
### varReplace function tests
def test_varReplace_var_complex_var(self):
vars = {
'x': '$y',
'y': {
'foo': 'result',
},
}
template = '${x.foo}'
res = template2.template(None, template, vars)
assert res == 'result'
#####################################
### template_ds function tests
def test_template_ds_basic(self):
vars = {
'data': {
'var': [
'foo',
'bar',
'baz',
],
'types': [
'str',
u'unicode',
1,
1L,
1.2,
],
'alphas': '$alphas',
},
'alphas': [
'abc',
'def',
'ghi',
],
}
template = '${data.var}'
res = template2.template(None, template, vars)
assert sorted(res) == sorted(vars['data']['var'])
template = '${data.types}'
res = template2.template(None, template, vars)
assert sorted(res) == sorted(vars['data']['types'])
template = '${data.alphas}'
res = template2.template(None, template, vars)
assert sorted(res) == sorted(vars['alphas'])
template = '${data.nonexisting}'
res = template2.template(None, template, vars)
assert res == template
#####################################
### Template function tests
def test_template_basic(self):
vars = {
'who': 'world',
}
res = template2.template_from_file("test", "template-basic", vars)
assert res == 'hello world'
def test_template_whitespace(self):
vars = {
'who': 'world',
}
res = template2.template_from_file("test", "template-whitespace", vars)
assert res == 'hello world\n'
def test_template_unicode(self):
vars = {
'who': u'wórld',
}
res = template2.template_from_file("test", "template-basic", vars)
assert res == u'hello wórld'
#####################################
### check_conditional tests
@ -204,44 +116,3 @@ class TestUtils(unittest.TestCase):
assert (ansible.utils.parse_kv('a=simple b="with space" c="this=that"') ==
{'a': 'simple', 'b': 'with space', 'c': 'this=that'})
#####################################
### plugins
def test_loaders_expanduser_each_dir(self):
# Test that PluginLoader will call expanduser on each path
# when it splits its "config" argument.
home_dir = os.path.expanduser("~")
if home_dir == "~":
raise SkipTest("your platform doesn't expand ~ in paths")
elif not os.path.isdir(home_dir):
raise SkipTest("~ expands to non-directory %r" % (home_dir,))
elif not os.path.isabs(home_dir):
raise SkipTest("~ expands to non-absolute path %r" % (home_dir,))
# Unfortunately we have to create temporary directories in
# your home directory; the directories have to exist for
# PluginLoader to accept them.
abs_dirs, tilde_dirs = [], []
try:
for _ in range(2):
temp_dir = tempfile.mkdtemp(prefix="ansible", dir=home_dir)
abs_dirs.append(temp_dir)
# Convert mkdtemp's absolute path to one starting with "~".
tilde_dir = os.path.join("~", os.path.relpath(temp_dir,
home_dir))
tilde_dirs.append(tilde_dir)
loader = ansible.utils.plugins.PluginLoader(
"",
"",
os.pathsep.join(tilde_dirs),
"something_under_basedir"
)
loader_paths = loader.print_paths().split(os.pathsep)
for abs_dir in abs_dirs:
assert abs_dir in loader_paths, \
"%r not in %r" % (abs_dir, loader_paths)
finally:
for a_dir in abs_dirs:
try:
os.rmdir(a_dir)
except os.error:
pass

View file

@ -1,90 +0,0 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.10 (GNU/Linux)
mQINBEx4Hs8BEADmfmcyCpVx8f+0lfdFYuRL7VDNdp6awUktY/KLYux/hC0nU1VH
dUGzvWYV579lFjkILtfBG+9WqXwaFnOp4xo3NbZAzVHs0oxNerXn5i5dQZw9bQVG
Vbcb0YbQss8fBQpKvUaXJ4Toj0DO7cFGTddBBlPZM2aZCB0/HWrzxRQWiC2v9Mdc
IoK92QbCz+4S4QAy8NegiRDAfXL5+pwDeLJyT1/d57g2UKDTshfaiPafWs063Eob
cQoJr4n2ENCCjiF/oUw8Hs5tB0TgoJ2zD0wwXCRZx0Vkcnxa6ZBUrpP/Bb6Uhw0g
gsz1H6PoTrQ7joMQs3rVFMNpNQQ4lPt5cS0Q20l+Z0bdgvESPouQPatbSU9fYusK
7tiB/Igvc1qMW8N7UVICGPYdfnH/juSJcc8vaoiNcRweR0DV/bGXJ4FzV9xzQbLL
WcmOgIfsPXgS/urBzakau94K144yPtBth3iaVtM2h7mzAeAaEbuE1UuBt0wBLYhv
/n3Sgxm3mP2S8zS7ZJ4/LIBJw7RRo3/6rDasU23ni6vetIUgOBCMhzeiAw99VRJm
e4lyDgfMb1QZvjkMfJv4ae5HHntdCKnd2wtagvjs46IaKiJpgyEQVZJFIkmfrKsM
3oEU8EW1A685ErBI/fPEZ0fvtTdM3hpwCzs1RyUyVgDRhlD55NqLyKqUQQARAQAB
tElEZWJpYW4gQXJjaGl2ZSBBdXRvbWF0aWMgU2lnbmluZyBLZXkgKDYuMC9zcXVl
ZXplKSA8ZnRwbWFzdGVyQGRlYmlhbi5vcmc+iQI9BBMBAgAnAhsDBQkOJYiAAh4B
AheABQJM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c1j3UVYmHmiabAfyEqtHC3gWsiiIny0/PnOIN+in
k5oFAJodAdIlOHlRaUBfY5iEGZFTOoO0dDnv9nHJn5nJorWtwoZ05tm9rcluPCFx
MB7Q6fgI+0h4h1MPXPPU2RmWtVRJ6fk0HtNBilHFV2OlUZ3lG/FeFs4ARgW4kH3X
wOnwf7R7oESAS6QIQYDLV+VJ7lqGlOpSmcxxYBSiUYIGsuE+aeXk14BiXPETt7EI
THM7rNItKf0vwxlPlEEAa7KNxRcMk3rVA8C64JzUIZJ4pHABr+xFsRpKOiDgWev4
hqsRKcw+Z9k=
=sw5O
-----END PGP PUBLIC KEY BLOCK-----

View file

@ -1,2 +0,0 @@
# This is the first comment.
[somegroup]

View file

@ -1,2 +0,0 @@
# This is the second comment.
localhost

View file

@ -1,4 +0,0 @@
# This is the third comment.
[somegroup:vars]
foo=bar
# 無 可 無 非 常 無

View file

@ -1,42 +0,0 @@
-
hosts: all
gather_facts: no
remote_user: root
vars:
color: brown
tasks:
- name: test 1
cron: name="execution test 1" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" cron_file=yum-autoupdate state=absent
tags:
- cron
- name: test 1-1
cron: name="execution test 1" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" cron_file=yum-autoupdate state=absent
tags:
- cron
- name: test 2-1
cron: name="execution test 2" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" state=absent
tags:
- cron
- name: test 2-2
cron: name="execution test 2" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" state=absent
tags:
- cron
- name: test 2-3
cron: name="execution test 2" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate"
tags:
- cron
- name: test 3-1
cron: name="execution test 3" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" cron_file=yum-autoupdate state=absent
tags:
- cron
- name: test 3-2
cron: name="execution test 3" weekday="2,3" minute=0 hour=12 user="root" job="YUMINTERACTIVE=0 /usr/sbin/yum-autoupdate" cron_file=yum-autoupdate
tags:
- cron

View file

@ -1,2 +0,0 @@
---
testing: default

View file

@ -1,10 +0,0 @@
#jinja2: variable_end_string: @@, variable_start_string: @@
{% raw %}
if this succeeds you should see '{{ ansible_hostname }}' with the hostname on the line above
if this fails you should see '@@ ansible_hostname @@' with the hostname on the line beneath
{% endraw %}
@@ ansible_hostname @@
{{ ansible_hostname }}

View file

@ -1,113 +0,0 @@
# simple test of lookup plugins in with_*
---
- hosts: all
connection: local
vars:
empty_list: []
tasks:
- name: test with_items
action: command true
with_items:
- 1
- 2
- 3
- name: test with_items with empty list
action: command true
with_items: $empty_list
- name: test with_file and FILE
action: command test "$item" = "$FILE(sample.j2)"
with_file: sample.j2
- name: test with_pipe
action: command test "$item" = "$PIPE(cat sample.j2)"
with_pipe: cat sample.j2
- name: test LOOKUP and PIPE
action: command test "$LOOKUP(pipe, cat sample.j2)" = "$PIPE(cat sample.j2)"
- name: test with_sequence, generate
command: touch /tmp/seq-${item}
with_sequence: 0-16/2:%02x
- name: test with_sequence, fenceposts 1
copy: src=/tmp/seq-00 dest=/tmp/seq-10
- name: test with_sequence, fenceposts 2
file: dest=/tmp/seq-${item} state=absent
with_items: [11, 12]
- name: test with_sequence, missing
file: dest=/tmp/seq-${item} state=absent
with_sequence: 0x10/02:%02x
- name: test with_sequence,remove
file: dest=/tmp/seq-${item} state=absent
with_sequence: 0-0x10/02:%02x
- name: ensure test file doesnt exist
# command because file will return differently
action: command rm -f /tmp/ansible-test-with_lines-data
- name: test with_lines
action: shell echo "$item" >> /tmp/ansible-test-with_lines-data
with_lines: cat sample.j2
- name: verify with_lines
action: copy src=sample.j2 dest=/tmp/ansible-test-with_lines-data
- name: cleanup test file
action: file path=/tmp/ansible-test-with_lines-data state=absent
# Test nested loop
- name: test nested loop with more than 3 elements
command: test "{{ item[0] }}, {{ item[1] }}, {{ item[2] }}, {{ item[3] }}" = "red, 1, up, top"
with_nested:
- [ 'red' ]
- [ 1 ]
- [ 'up']
- [ 'top']
# password lookup plugin
- name: ensure test file doesn't exist
# command because file will return differently
action: command rm -f /tmp/ansible-test-with_password
- name: test LOOKUP and PASSWORD with non existing password file
action: command test "$LOOKUP(password, /tmp/ansible-test-with_password)" = "$PASSWORD(/tmp/ansible-test-with_password)"
- name: test LOOKUP and PASSWORD with existing password file
action: command test "$LOOKUP(password, /tmp/ansible-test-with_password)" = "$PASSWORD(/tmp/ansible-test-with_password)"
- name: now test existing password via $item and with_password
action: command test "$PASSWORD(/tmp/ansible-test-with_password)" = "$item"
with_password:
- /tmp/ansible-test-with_password
- name: cleanup test file
action: file path=/tmp/ansible-test-with_password state=absent
- name: now test a password of non-default length (default=20, but here length=8)
action: command test "$PASSWORD(/tmp/ansible-test-with_password length=8)" = "$LOOKUP(password, /tmp/ansible-test-with_password)"
# - name: did we really create a password of length=8?
# action: command test "`expr length $PASSWORD(/tmp/ansible-test-with_password)`" = "8"
- name: cleanup test file, again
action: file path=/tmp/ansible-test-with_password state=absent
# indexed_items lookup plugin
- name: create directory for indexed_items
file: path=/tmp/ansible-test-with_indexed_items-data state=directory
- name: test indexed_items
shell: echo "{{ item.0 }}" > /tmp/ansible-test-with_indexed_items-data/{{ item.1 }}
with_indexed_items:
- a
- b
- c
- name: check indexed_items content
shell: test -f /tmp/ansible-test-with_indexed_items-data/{{ item.1 }} &&
test "{{ item.0 }}" = "$(cat /tmp/ansible-test-with_indexed_items-data/{{ item.1 }})"
with_indexed_items:
- a
- b
- c
- name: cleanup indexed_items test
file: path=/tmp/ansible-test-with_indexed_items-data/{{ item.1 }} state=absent
with_indexed_items:
- a
- b
- c
- name: remove with_indexed_items directory
file: path=/tmp/ansible-test-with_indexed_items-data state=absent

View file

@ -1,48 +0,0 @@
---
- hosts: all
connection: local
gather_facts: False
vars:
var_true: True
var_false: False
var_empty_str: "''"
var_null: ~
tasks:
- action: command echo ping
always_run: yes
- action: command echo pong 1
- action: command echo pong 2
always_run: no
- action: command echo pong 3
always_run: 1 + 1
- action: command echo pong 4
always_run: "''"
- action: command echo pong 5
always_run: False
- action: command echo pong 6
always_run: True
- action: command echo pong 7
always_run: var_true
- action: command echo pong 8
always_run: var_false
- action: command echo pong 9
always_run: var_empty_str
- action: command echo pong 10
always_run: var_null
# this will never run...
- action: command echo pong 11
always_run: yes
when: no

View file

@ -1,25 +0,0 @@
---
- hosts: all
connection: local
gather_facts: False
tasks:
- action: command echo first action
- action: command echo second action
register: var
changed_when: "'X' in var.stdout"
- action: shell exit 2
register: exit
ignore_errors: yes
changed_when: "exit.rc < 1"
- action: command echo third action
changed_when: false
- action: file path=/ state=directory
changed_when: true
- action: command echo {{item}}
register: out
changed_when: "'e' in out.stdout"
with_items:
- hello
- foo
- bye

View file

@ -1,15 +0,0 @@
---
- hosts: all
connection: local
gather_facts: False
tasks:
- action: shell exit 0
register: exit
failed_when: not exit.rc in [0, 1]
- action: shell exit 1
register: exit
failed_when: exit.rc not in [0, 1]
- action: shell exit 2
register: exit
failed_when: exit.rc not in [0, 1]

View file

@ -1,9 +0,0 @@
---
- hosts: all
connection: local
gather_facts: False
tasks:
- action: command false
ignore_errors: true
- action: command false

View file

@ -1,17 +0,0 @@
---
- hosts: localhost
connection: local
gather_facts: False
tasks:
- name: Loggføring fungerer
command: echo "Feilsøking"
always_run: yes
- name: Die Süßigkeit
command: echo "Die Süßigkeit"
always_run: yes
- name: Logging works
command: echo "Debugging"
always_run: yes

View file

@ -1,98 +0,0 @@
---
# run with option -i localhost
# need root permissions
- name: host module testing
hosts: localhost
connection: local
gather_facts: no
sudo: yes
pre_tasks:
- name: backup /etc/hosts
command: cp /etc/hosts /etc/hosts.origin
post_tasks:
- name: restore /etc/hosts
command: cp /etc/hosts.origin /etc/hosts
tasks:
- name: test add a record
host: hostname=foobar ip=192.168.123.1
register: result
failed_when: not result.changed
- name: test error handling only hostname given on present
host: hostname=foobar
register: result
failed_when: result.changed
- name: test error handling only ip given on present
host: ip=192.168.123.1
register: result
failed_when: result.changed
- name: test record exists
host: hostname=foobar ip=192.168.123.1
register: result
failed_when: result.changed
- name: test remove record using hostname
host: hostname=foobar state=absent
register: result
failed_when: not result.changed
- name: test remove not existing record using hostname
host: hostname=foobar state=absent
register: result
failed_when: result.changed
- name: test add a record again
host: hostname=foobar ip=192.168.123.1
register: result
failed_when: not result.changed
- name: test remove record using ip
host: ip=192.168.123.1 state=absent
register: result
failed_when: not result.changed
- name: test remove not existing record using ip
host: ip=192.168.123.1 state=absent
register: result
failed_when: result.changed
- name: test add a record with alias
host: hostname=foobar ip=192.168.123.1 aliases=foobar.com,foobar.net
register: result
failed_when: not result.changed
- name: test add an existing record with alias
host: hostname=foobar ip=192.168.123.1 aliases=foobar.com,foobar.net
register: result
failed_when: result.changed
- name: test add an existing record with changed alias
host: hostname=foobar ip=192.168.123.1 aliases=foobar.net,foobar.com
register: result
failed_when: not result.changed
- name: test remove aliases from existing record
host: hostname=foobar ip=192.168.123.1
register: result
failed_when: not result.changed
- name: test add aliases for existing record
host: hostname=foobar ip=192.168.123.1 aliases=foobar.net,foobar.com
register: result
failed_when: not result.changed
- name: test change ip on existing record
host: hostname=foobar ip=192.168.123.2
register: result
failed_when: not result.changed
- name: test change hostname on existing record
host: hostname=barfoo ip=192.168.123.2
register: result
failed_when: not result.changed

View file

@ -1,133 +0,0 @@
---
# To run me manually, use: -i "localhost,"
- hosts: localhost
connection: local
gather_facts: no
vars:
- testdir: /tmp/ansible-rcopy
- filesdir: test_recursive_copy/files
tasks:
#
# First, regression tests for single-file behavior
#
- name: "src single file, dest file"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/file1
register: res
- command: test -f {{testdir}}/file1
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/file1
register: res
- command: test "{{res.changed}}" = "False"
- name: "src single file, dest dir w/trailing slash"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/
register: res
- command: test -f {{testdir}}/test1
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}/
register: res
- command: test "{{res.changed}}" = "False"
- name: "src single file, dest dir wo/trailing slash - doesn't behave in sane way"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}
register: res
- shell: test -f {{testdir}}/test1
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir/subdir2/subdir3/test1 dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
#
# Now, test recursive behavior
#
- name: "src dir w/trailing slash, dest w/trailing slash"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir/ dest={{testdir}}/
register: res
- command: test -d {{testdir}}/subdir2
- command: test -d {{testdir}}/subdir2/subdir3
- command: test -d {{testdir}}/subdir2/subdir3
- command: test -f {{testdir}}/subdir2/subdir3/test1
- command: test -f {{testdir}}/subdir2/subdir3/test2
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir/ dest={{testdir}}/
register: res
- command: test "{{res.changed}}" = "False"
# Expecting the same behavior
- name: "src dir w/trailing slash, dest wo/trailing slash"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir/ dest={{testdir}}
register: res
- command: test -d {{testdir}}/subdir2
- command: test -d {{testdir}}/subdir2/subdir3
- command: test -d {{testdir}}/subdir2/subdir3
- command: test -f {{testdir}}/subdir2/subdir3/test1
- command: test -f {{testdir}}/subdir2/subdir3/test2
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir/ dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
- name: "src dir wo/trailing slash, dest w/trailing slash"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir dest={{testdir}}/
register: res
- command: test -d {{testdir}}/subdir/subdir2
- command: test -d {{testdir}}/subdir/subdir2/subdir3
- command: test -d {{testdir}}/subdir/subdir2/subdir3
- command: test -f {{testdir}}/subdir/subdir2/subdir3/test1
- command: test -f {{testdir}}/subdir/subdir2/subdir3/test2
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir dest={{testdir}}/
register: res
- command: test "{{res.changed}}" = "False"
# Expecting the same behavior
- name: "src dir wo/trailing slash, dest wo/trailing slash"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir dest={{testdir}}
register: res
- command: test -d {{testdir}}/subdir/subdir2
- command: test -d {{testdir}}/subdir/subdir2/subdir3
- command: test -d {{testdir}}/subdir/subdir2/subdir3
- command: test -f {{testdir}}/subdir/subdir2/subdir3/test1
- command: test -f {{testdir}}/subdir/subdir2/subdir3/test2
- command: test "{{res.changed}}" = "True"
- copy: src={{filesdir}}/subdir dest={{testdir}}
register: res
- command: test "{{res.changed}}" = "False"
- name: "Verifying notify handling for recursive files"
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/subdir dest={{testdir}}
notify:
- files changed
- meta: flush_handlers
- command: test -f {{testdir}}/notify_fired
- command: rm {{testdir}}/notify_fired
- copy: src={{filesdir}}/subdir dest={{testdir}}
notify:
- files changed
- meta: flush_handlers
- command: test ! -f {{testdir}}/notify_fired
handlers:
- name: files changed
command: touch {{testdir}}/notify_fired

View file

@ -1,2 +0,0 @@
---
- include: "{{dir}}/playbook-included.yml variable=foobar"

View file

@ -1,90 +0,0 @@
---
# To run me manually, use: -i "localhost,"
- hosts: localhost
connection: local
gather_facts: no
vars:
- testdir: /tmp/ansible-unarchive
- filesdir: test_unarchive/files
tasks:
- name: "Simple tar unarchive."
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- unarchive: src={{filesdir}}/test.tar dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{filesdir}}/test.tar dest={{testdir}}
register: res
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Simple tar.gz unarchive."
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- unarchive: src={{filesdir}}/test.tar.gz dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{filesdir}}/test.tar.gz dest={{testdir}}
register: res
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Simple zip unarchive."
command: rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- unarchive: src={{filesdir}}/test.zip dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{filesdir}}/test.zip dest={{testdir}}
register: res
- fail: msg="Resource was expected to be changed."
when: not res|changed
- name: "Unarchive a local tar file."
command : rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/test.tar dest={{testdir}}
- unarchive: src={{testdir}}/test.tar dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{testdir}}/test.tar dest={{testdir}}
register: res
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Unarchive a local tar.gz file."
command : rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/test.tar.gz dest={{testdir}}
- unarchive: src={{testdir}}/test.tar.gz dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{testdir}}/test.tar.gz dest={{testdir}}
register: res
- fail: msg="Resource was not expected to be changed."
when: res|changed
- name: "Unarchive a local zip file."
command : rm -rf {{testdir}}
- file: state=directory dest={{testdir}}
- copy: src={{filesdir}}/test.zip dest={{testdir}}
- unarchive: src={{testdir}}/test.zip dest={{testdir}}
register: res
- command: test -f {{testdir}}/foo
- fail: msg="Resource was expected to be changed."
when: not res|changed
- unarchive: src={{testdir}}/test.zip dest={{testdir}}
register: res
- fail: msg="Resource was expected to be changed."
when: not res|changed

View file

@ -1,70 +0,0 @@
# extremely simple test of the most basic of playbook engine/functions
---
- hosts: all
connection: local
# the 'weasels' string should show up in the output
vars:
answer: "Wuh, I think so, Brain, but if we didn't have ears, we'd look like weasels."
port: 5150
# we should have import events for common_vars and CentOS.yml (if run on CentOS)
# sorry, tests are a bit platform specific just for now
vars_files:
- common_vars.yml
- [ '{{facter_operatingsystem.yml}}', 'default_os.yml' ]
tasks:
- name: test basic success command
action: command true
- name: test basic success command 2
action: command true
- name: test basic shell, plus two ways to dereference a variable
action: shell echo {{port}}
- name: test vars_files imports
action: shell echo {{duck}} {{cow}} {{testing}}
# in the command below, the test file should contain a valid template
# and trigger the change handler
- name: test copy
action: copy src=sample.j2 dest=/tmp/ansible_test_data_copy.out
notify:
- on change 1
# there should be various poll events within the range
- name: async poll test
action: shell sleep 5
async: 10
poll: 3
# the following command should be skipped
- name: this should be skipped
action: shell echo 'if you see this, this is wrong'
when: 2 == 3
handlers:
# in the above test example, this should fire ONCE (at the end)
- name: on change 1
action: shell echo 'this should fire once'
# in the above test example, this should fire ONCE (at the end)
- name: on change 2
action: shell echo 'this should fire once also'
# in the above test example, this should NOT FIRE
- name: on change 3
action: shell echo 'if you see this, this is wrong'

View file

@ -1,20 +0,0 @@
---
# Test iterating over lines of stdout stored in a register.
- hosts: localhost
connection: local
vars:
small_file: /etc/resolv.conf
temp_file: /tmp/ansible_result_list.tmp
tasks:
- action: command cat $small_file
register: result
- action: file dest=$temp_file state=absent
- action: shell echo '$item' >> $temp_file
with_items: ${result.stdout_lines}
- action: command diff $small_file $temp_file
- action: file dest=$temp_file state=absent

View file

@ -1,6 +0,0 @@
An ansible is a fictitious machine capable of instantaneous or superluminal
communication. Typically it is depicted as a lunch-box sized object with some
combination of microphone, speaker, keyboard and display. It can send and
receive messages to and from a corresponding device over any distance
whatsoever with no delay. Ansibles occur as plot devices in science fiction
literature.

View file

@ -1,4 +0,0 @@
Are you pondering what I'm pøndering?
I think so Brain, but {{ answer }}

View file

@ -1 +0,0 @@
hello {{ who }}

View file

@ -1 +0,0 @@
hello {{ who }}

View file

@ -1,5 +0,0 @@
localhost
[all:vars]
inventory_var_good="{{ playbook_var_good }}"
inventory_var_bad="{{ playbook_var_bad }}"

View file

@ -1,7 +0,0 @@
- hosts: all
vars:
playbook_var_good: "ok"
playbook_var_bad: "{{ undefined_var }}"
tasks:
- debug: msg="{{ playbook_var_good }}"
- debug: msg="{{ playbook_var_bad }}"

View file

@ -1,7 +0,0 @@
- hosts: all
vars:
playbook_var_good: "ok"
playbook_var_bad: "{{ undefined_var }}"
tasks:
- debug: msg="{{ inventory_var_good }}"
- debug: msg="{{ inventory_var_bad }}"

View file

@ -1,2 +0,0 @@
---
attr2: 2

View file

@ -1,2 +0,0 @@
---
attr1: 1

View file

@ -1,6 +0,0 @@
host1
host2
[group]
host1
host2

View file

@ -1,2 +0,0 @@
---
- hosts: group

Binary file not shown.

Binary file not shown.

View file

@ -1 +0,0 @@
world