Ejemplo n.º 1
0
        ]
    return Result(candidate.path, errors)


def host_vars_exist(candidate, settings):
    return Result(candidate.path,
                  [Error(None, "Host vars are generally "
                         "not required")])


def noop(candidate, settings):
    return Result(candidate.path)


rolesfile_should_be_in_yaml = Standard(
    dict(name="Roles file should be in yaml format",
         check=yamlrolesfile,
         types=["rolesfile"]))

role_must_contain_meta_main = Standard(
    dict(name="Roles must contain suitable meta/main.yml",
         check=lintcheck('EXTRA0012'),
         types=["meta"]))

role_meta_main_must_contain_info = Standard(
    dict(name="Roles meta/main.yml must contain important info",
         check=lintcheck('EXTRA0013'),
         types=["meta"]))

variables_should_contain_whitespace = Standard(
    dict(name="Variable uses should contain whitespace",
         check=lintcheck('EXTRA0001'),
Ejemplo n.º 2
0
from ansiblereview import Standard, Result, Error, lintcheck


def check_fail(candidate, settings):
    return Result(candidate, [Error(1, "test failed")])


def check_success(candidate, settings):
    return Result(candidate)


test_task_ansiblelint_success = Standard(
    dict(check=lintcheck('TEST0002'),
         name="Test task lint success",
         version="0.2",
         types=["playbook", "tasks", "handlers"]))

test_task_ansiblelint_failure = Standard(
    dict(check=lintcheck('TEST0001'),
         name="Test task lint failure",
         version="0.4",
         types=["playbook", "tasks", "handlers"]))

test_failure = Standard(
    dict(check=check_fail,
         name="Test general failure",
         version="0.5",
         types=[
             "playbook", "task", "handler", "rolevars", "hostvars",
             "groupvars", "meta"
         ]))
Ejemplo n.º 3
0
from ansiblereview import Standard, Result, Error, lintcheck
from ansiblereview.groupvars import same_variable_defined_in_competing_groups


def check_fail(candidate, settings):
    return Result(candidate, [Error(1, "test failed")])


def check_success(candidate, settings):
    return Result(candidate)


test_task_ansiblelint_success = Standard(
    dict(check=lintcheck('TEST0002'),
         name="Test task lint success",
         version="0.2",
         types=["playbook", "tasks", "handlers"]))

test_task_ansiblelint_failure = Standard(
    dict(check=lintcheck('TEST0001'),
         name="Test task lint failure",
         version="0.4",
         types=["playbook", "tasks", "handlers"]))

test_failure = Standard(
    dict(check=check_fail,
         name="Test general failure",
         version="0.5",
         types=[
             "playbook", "task", "handler", "rolevars", "hostvars",
             "groupvars", "meta"
Ejemplo n.º 4
0
        except Exception, e:
            result.errors = [
                Error(
                    None,
                    "Cannot parse YAML from %s: %s" % (candidate.path, str(e)))
            ]
    return result


def host_vars_exist(candidate, settings):
    return Result(candidate.path,
                  [Error(None, "Host vars are generally not required")])


rolesfile_should_be_in_yaml = Standard(
    dict(name="Roles file should be in yaml format",
         check=yamlrolesfile,
         types=["rolesfile"]))

role_must_contain_meta_main = Standard(
    dict(name="Roles must contain suitable meta/main.yml",
         check=metamain,
         types=["meta"]))

commands_should_be_idempotent = Standard(
    dict(name="Commands should be idempotent",
         check=lintcheck('ANSIBLE0012'),
         types=["playbook", "task"]))

commands_should_not_be_used_in_place_of_modules = Standard(
    dict(name="Commands should not be used in place of modules",
         check=lintcheck('ANSIBLE0006,ANSIBLE0007'),