forked from Normation/rudder-tests
-
Notifications
You must be signed in to change notification settings - Fork 1
/
technique.py
executable file
·57 lines (45 loc) · 1.68 KB
/
technique.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#
# Techniques specific scenario that runs tests on one or more techniques
#
# Give it a directory parameter and it will test all techniques with a self test in it
from scenario.lib import *
import time
# Get test list from parameters
tests = get_tests()
# Test begins, register start time
start()
# Force inventory
run_on("agent", 'run_agent', Err.CONTINUE, PARAMS="-D force_inventory")
run_on("server", 'run_agent', Err.CONTINUE, PARAMS="")
# Accept nodes
for host in scenario.nodes("agent"):
run('localhost', 'agent_accept', Err.BREAK, ACCEPT=host)
# Run test init script
for test in tests:
if 'init' in test:
run_on("all", 'techniques/technique_init', Err.BREAK, INIT=test['init'])
# Test all techniques
date0 = host_date('wait', Err.CONTINUE, "server")
for test in tests:
# Add a technique/directive/rule
run('localhost', 'techniques/technique_rule', Err.BREAK,
TECHNIQUE=test['name'],
DIRECTIVE=test['directive'],
GROUP="special:all",
NAME=test['directive_name'])
# Wait for generation
for host in scenario.nodes("agent"):
wait_for_generation('wait', Err.CONTINUE, "server", date0, host, 20)
# Deploy all
run_on("server", 'run_agent', Err.CONTINUE, PARAMS="")
run_on("agent", 'run_agent', Err.CONTINUE, PARAMS="-f failsafe.cf")
run_on("agent", 'run_agent', Err.CONTINUE, PARAMS="")
# Test rule result
for test in tests:
run_on("agent", test['check'], Err.CONTINUE)
## Test rule compliance
#time.sleep(5) # wait for server to compute compliance
#for test in tests:
# run('localhost', 'techniques/technique_compliance', Err.CONTINUE, RULE=test['directive_name'], COMPLIANCE=str(test['compliance']))
# test end, print summary
finish()