Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
gpoblon committed Mar 2, 2020
1 parent b7a7c9a commit 6fd6db0
Show file tree
Hide file tree
Showing 32 changed files with 617 additions and 19 deletions.
3 changes: 1 addition & 2 deletions rudder-lang/README.adoc
Expand Up @@ -61,6 +61,5 @@ The compiler is very pedantic to avoid defining invalid states as much as possib

=== Required modules
- perl (script: *tools/generate-lib*)
cpan Config::IniFiles
=== Configuration
- *rudderc.conf* to define the cfengine and ncf binaries paths, and the compilation, translation paths
- *tools/rudderc.conf* to define the cfengine and ncf binaries paths, and the compilation, translation paths
22 changes: 11 additions & 11 deletions rudder-lang/libs/stdlib.rl
@@ -1,21 +1,21 @@
@format=0

resource condition(p0)
resource kernel_module(p0)
resource variable(p0,p1)
resource environment(p0)
resource directory(p0)
resource sharedfile(p0)
resource group(p0)
resource file(p0)
resource service(p0)
resource command(p0)
resource schedule(p0)
resource package(p0)
resource file(p0)
resource directory(p0)
resource http(p0)
resource user(p0)
resource permissions(p0)
resource http(p0)
resource service(p0)
resource group(p0)
resource condition(p0)
resource schedule(p0)
resource kernel_module(p0)
resource monitoring(p0)
resource variable(p0,p1)
resource package(p0)
resource sharedfile(p0)

command state execution(){}
command state execution_once(p1,p2,p3){}
Expand Down
6 changes: 6 additions & 0 deletions rudder-lang/tests/test_files/source_rl/f_enum.rl
@@ -0,0 +1,6 @@
@format=0

enm error {
true,
false
}
17 changes: 17 additions & 0 deletions rudder-lang/tests/test_files/source_rl/f_fuzzy.rl
@@ -0,0 +1,17 @@
global enum os {
debin # 1 ast::enum_mapping()
}

enum osa ~> family { # 1 ast::add_enum_mappings()
ubunt -> debian, # 1 enum::add_mapping()
}

resource comman(p0) # 3 ast::add_resources()
commandq state execution(){} # 3 ast::add_resources()

resource Configure_NTP()

Configure_NP state technique() { # 3 ast::add_resources()
@component = "Package present"
packae("ntp").preent("","","") as package_present_ntp # respectively 4 + 5 ast::binding_check()
}
13 changes: 13 additions & 0 deletions rudder-lang/tests/test_files/source_rl/s_basic.rl
@@ -0,0 +1,13 @@
@format=0

@name="Configure NTP"
@description="test"
@version="1.0"
@parameters=[]

resource Configure_NTP()

Configure_NTP state technique() {
@component = "Package present"
package("ntp").present("","","") as package_present_ntp
}
11 changes: 11 additions & 0 deletions rudder-lang/tests/test_files/source_rl/s_enum_mapping.rl
@@ -0,0 +1,11 @@
@format=0
enum generations {
ascendant,
descendant,
sibbling
}
enum generations ~> familytree {
ascendant -> dad,
descendant -> son,
sibbling -> sister
}
11 changes: 11 additions & 0 deletions rudder-lang/tests/test_files/source_rl/s_state_case.rl
@@ -0,0 +1,11 @@
@format=0
@metadata=1
resource Configure_NTP()
Configure_NTP state technique() {
case {
# this case makes no sense, testing purpose
os=~ubuntu => file("/tmp").absent(),
os=~os:debian => file("/tmp").present(),
default => log "info: ok"
}
}
2 changes: 2 additions & 0 deletions rudder-lang/tests/test_files/source_rl/s_test.rl
@@ -0,0 +1,2 @@
@format=0
resource Rname (a,b,c)
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/cdt/technique.cf
@@ -0,0 +1,15 @@
# @name cdt
# @description rudderlang cdt for a complete loop
# @version 1.0


bundle agent cdt
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"File absent_${report_data.directive_id}_0" usebundle => _method_reporting_context("File absent", "tmp"),
if => concat("debian");
"File absent_${report_data.directive_id}_0" usebundle => file_absent("tmp"),
if => concat("debian");
}
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/condition_anybsd/technique.cf
@@ -0,0 +1,15 @@
# @name condition any bsd
# @description Kernel simplest
# @version 1.0


bundle agent condition_anybsd
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"Kernel module loaded_${report_data.directive_id}_0" usebundle => _method_reporting_context("Kernel module loaded", "test"),
if => concat("(dragonfly|freebsd|netbsd|openbsd)");
"Kernel module loaded_${report_data.directive_id}_0" usebundle => kernel_module_loaded("test"),
if => concat("(dragonfly|freebsd|netbsd|openbsd)");
}
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/condition_dyn/technique.cf
@@ -0,0 +1,15 @@
# @name condition dyn
# @description
# @version 1.0


bundle agent condition_dyn
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"Command execution_${report_data.directive_id}_0" usebundle => _method_reporting_context("Command execution", "pwd"),
if => concat("any.(",canonify("${coucou}"),")");
"Command execution_${report_data.directive_id}_0" usebundle => command_execution("pwd"),
if => concat("any.(",canonify("${coucou}"),")");
}
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/condition_err/technique.cf
@@ -0,0 +1,15 @@
# @name condition err
# @description one method with several conditons
# @version 1.0


bundle agent condition_err
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"HTTP request check status with headers_${report_data.directive_id}_0" usebundle => _method_reporting_context("HTTP request check status with headers", "/myurl"),
if => concat("debian.(cdt)");
"HTTP request check status with headers_${report_data.directive_id}_0" usebundle => http_request_check_status_headers("GET", "/myurl", "200", ""),
if => concat("debian.(cdt)");
}
@@ -0,0 +1,15 @@
# @name condition_errorprone
# @description
# @version 1.0


bundle agent condition_errorprone
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"Command execution_${report_data.directive_id}_0" usebundle => _method_reporting_context("Command execution", "pwd"),
if => concat("(dragonfly|openbsd)");
"Command execution_${report_data.directive_id}_0" usebundle => command_execution("pwd"),
if => concat("(dragonfly|openbsd)");
}
@@ -0,0 +1,15 @@
# @name conditional method
# @description one method with several conditons
# @version 1.0


bundle agent conditional_method
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"HTTP request check status with headers_${report_data.directive_id}_0" usebundle => _method_reporting_context("HTTP request check status with headers", "/myurl"),
if => concat("debian");
"HTTP request check status with headers_${report_data.directive_id}_0" usebundle => http_request_check_status_headers("GET", "/myurl", "200", ""),
if => concat("debian");
}
@@ -0,0 +1,21 @@
{
"name": "conditional method",
"description": "one method with several conditons",
"version": "1.0",
"bundle_name": "conditional_method",
"bundle_args": [],
"parameter": [],
"method_calls": [
{
"class_context": "debian",
"component": "HTTP request check status with headers",
"method_name": "http_request_check_status_headers",
"args": [
"GET",
"/myurl",
"200",
""
]
}
]
}
@@ -0,0 +1,14 @@
# This file has been generated with rltranslate
@format=0

@name="conditional method"
@description="one method with several conditons"
@version="1.0"
@parameters=[]

resource conditional_method()

conditional_method state technique() {
@component = "HTTP request check status with headers"
if debian => http("GET").request_check_status_headers("/myurl","200","") as http_request_check_status_headers__myurl
}
@@ -0,0 +1,15 @@
# generated by rudder-lang
# @name conditional method
# @description one method with several conditons
# @version 1.0

bundle agent conditional_method_technique
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"HTTP request check status with headers_${report_data.directive_id}_0" usebundle => _method_reporting_context("HTTP request check status with headers", "/myurl"),
if => concat("debian");
"HTTP request check status with headers_${report_data.directive_id}_0" usebundle => http_request_check_status_headers("GET", "/myurl", "200", ""),
if => concat("debian");
}
@@ -0,0 +1,21 @@
{
"name": "conditional method",
"description": "one method with several conditons",
"version": "1.0",
"bundle_name": "conditional_method_technique",
"bundle_args": [],
"parameter": [],
"method_calls": [
{
"class_context": "debian",
"component": "HTTP request check status with headers",
"method_name": "http_request_check_status_headers",
"args": [
"GET",
"/myurl",
"200",
""
]
}
]
}
35 changes: 35 additions & 0 deletions rudder-lang/tests/test_files/tester/multiple_simple/technique.cf
@@ -0,0 +1,35 @@
# @name multiple_simple
# @description
# @version 1.0


bundle agent multiple_simple
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"File absent_${report_data.directive_id}_0" usebundle => _method_reporting_context("File absent", "/tmp"),
if => concat("any");
"File absent_${report_data.directive_id}_0" usebundle => file_absent("/tmp"),
if => concat("any");
"File check exists_${report_data.directive_id}_1" usebundle => _method_reporting_context("File check exists", "/tmp"),
if => concat("any");
"File check exists_${report_data.directive_id}_1" usebundle => file_check_exists("/tmp"),
if => concat("any");
"File present_${report_data.directive_id}_2" usebundle => _method_reporting_context("File present", "/tmp"),
if => concat("any");
"File present_${report_data.directive_id}_2" usebundle => file_present("/tmp"),
if => concat("any");
"Directory absent_${report_data.directive_id}_3" usebundle => _method_reporting_context("Directory absent", "/tmp"),
if => concat("any");
"Directory absent_${report_data.directive_id}_3" usebundle => directory_absent("/tmp", "false"),
if => concat("any");
"Directory present_${report_data.directive_id}_4" usebundle => _method_reporting_context("Directory present", "/tmp"),
if => concat("any");
"Directory present_${report_data.directive_id}_4" usebundle => directory_present("/tmp"),
if => concat("any");
"Directory check exists_${report_data.directive_id}_5" usebundle => _method_reporting_context("Directory check exists", "/tmp"),
if => concat("any");
"Directory check exists_${report_data.directive_id}_5" usebundle => directory_check_exists("/tmp"),
if => concat("any");
}
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/parameters/technique.cf
@@ -0,0 +1,15 @@
# @name parameters
# @description technique using parameters
# @version 1.0
# @parameter { "name": "paramtest", "id": "d74a03dd-5b0b-4b06-8dcf-b4e0cb387c60" }

bundle agent parameters(paramtest)
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"Package absent_${report_data.directive_id}_0" usebundle => _method_reporting_context("Package absent", "vpn"),
if => concat("any");
"Package absent_${report_data.directive_id}_0" usebundle => package_absent("vpn", "", "", ""),
if => concat("any");
}
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/parameters_err/technique.cf
@@ -0,0 +1,15 @@
# @name parameters mult err
# @description technique using multiple parameters
# @version 1.0
# @parameter { "name": "${coucou}", "id": "ac15b0bd-a226-4ad7-b93c-5515cae507a1" }

bundle agent parameters_mult_err(__coucou_)
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"Package absent_${report_data.directive_id}_0" usebundle => _method_reporting_context("Package absent", "vpn"),
if => concat("any");
"Package absent_${report_data.directive_id}_0" usebundle => package_absent("vpn", "", "", ""),
if => concat("any");
}
16 changes: 16 additions & 0 deletions rudder-lang/tests/test_files/tester/parameters_mult/technique.cf
@@ -0,0 +1,16 @@
# @name parameters mult
# @description technique using multiple parameters
# @version 1.0
# @parameter { "name": "paramtest", "id": "d74a03dd-5b0b-4b06-8dcf-b4e0cb387c60" }
# @parameter { "name": "12", "id": "6e82d276-1181-4596-8fd8-bc3c007ae9ff" }

bundle agent parameters_mult(paramtest,12)
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"Package absent_${report_data.directive_id}_0" usebundle => _method_reporting_context("Package absent", "vpn"),
if => concat("any");
"Package absent_${report_data.directive_id}_0" usebundle => package_absent("vpn", "", "", ""),
if => concat("any");
}
15 changes: 15 additions & 0 deletions rudder-lang/tests/test_files/tester/simplest/technique.cf
@@ -0,0 +1,15 @@
# @name simplest
# @description rudderlang simplest for a complete loop
# @version 1.0


bundle agent simplest
{
vars:
"resources_dir" string => "${this.promise_dirname}/resources";
methods:
"File absent_${report_data.directive_id}_0" usebundle => _method_reporting_context("File absent", "tmp"),
if => concat("scientific_linux");
"File absent_${report_data.directive_id}_0" usebundle => file_absent("tmp"),
if => concat("scientific_linux");
}

0 comments on commit 6fd6db0

Please sign in to comment.