Slide 1

Slide 1 text

RUDDER Language What ? Why ? CONTINUOUS AUDITING & CONFIGURATION

Slide 2

Slide 2 text

A new language ! Why ? 2

Slide 3

Slide 3 text

Why ? More than one engine ▪ We currently support CFEngine ▪ We currently support DSC ▪ We want more (mgmt ? puppet ? ansible ?) 3

Slide 4

Slide 4 text

Why ? Less code ? ▪ NCF doesn’t map directly to CFEngine and DSC ▪ We need a lot of extra code to make it NCF ▪ We could put this code into a generator 4

Slide 5

Slide 5 text

Why ? New features ▪ NCF contains a lot of methods ▪ Adding a single feature may require to touch each one a. Ex: change logging ▪ We could add the feature quickly in the generator 5

Slide 6

Slide 6 text

Why ? New features 6 F1 F2 F3 F4 M1 x x x x M2 x x x x M3 x x x x F1 F2 F3 F4 M1 M2 M3 Compiler x x x x x x x

Slide 7

Slide 7 text

Why ? Higher level language ▪ Be more descriptive ▪ Be less prescriptive (less logic) ▪ Be more expressive (less code) 7

Slide 8

Slide 8 text

Why ? Compiler ▪ Be stricter ▪ Have compile time errors ▪ Have higher level checks ▪ Have type checking 8

Slide 9

Slide 9 text

Why ? Compiler 9 Code Agent User Feedback Code Agent User Feedback Compiler

Slide 10

Slide 10 text

Why ? Existing languages ▪ Compile time warning and errors - Be strict ▪ Separate compiler from interpreter ▪ We can add things to the language through the compiler ▪ Do not depend on the quirks of a given agent 10

Slide 11

Slide 11 text

Why ? New DSL ! ▪ Yes and ▪ It’s better than poor data format ▪ Everyone should have his own DSL 11

Slide 12

Slide 12 text

A new language ! How ? 12

Slide 13

Slide 13 text

How ? Define a language ▪ Concepts ▪ Syntax ▪ Document design decisions ▪ Try to rewrite existing code 13

Slide 14

Slide 14 text

How ? Build a compiler ▪ In rust we trust ▪ Parse with nom ▪ Create new language structure in memory ▪ Check for sanity ▪ Generate for target engine language 14

Slide 15

Slide 15 text

How ? Build a compiler ▪ Nom ▪ Parser combinator ▪ Easy development of parser ▪ Less easy error reporting 15

Slide 16

Slide 16 text

How ? Nom Separator Word Delimited List of words Regex

Slide 17

Slide 17 text

How ? Build a translator ▪ To transparently keep existing code ▪ In rust we trust ▪ Convert to json and read this ▪ Convert what is obvious ▪ Have heuristics and guesses for new concepts ▪ Fail in case we don’t know and let the user fix it 17

Slide 18

Slide 18 text

How ? Integrate it transparently ▪ Have the translator and compiler work in parallel with existing editor ▪ Make them report error when they see some ▪ Do not block the user ▪ When ready, translate existing code and start from there 18

Slide 19

Slide 19 text

A new language ! What ? 19

Slide 20

Slide 20 text

What ? First aim for techniques ▪ We want the language to be everywhere ▪ But let’s be incremental ▪ Target a language subset for creating techniques ▪ Nothing really new 20

Slide 21

Slide 21 text

What ? Now the boring stuff 21

Slide 22

Slide 22 text

What ? Language concepts ▪ The resource ▪ Identified by parameters ▪ No parameter means it is single instance ▪ Identical instance parameter mean instance equality 22

Slide 23

Slide 23 text

What ? Language concepts ▪ The state ▪ Applies on a resource ▪ Specified by parameters ▪ Either of a ‘present’ kind or ‘absent’ ▪ States are mutually exclusive except identical states 23

Slide 24

Slide 24 text

What ? Example 24 resource File(path) File state content(bytes) { ... } resource OpenNTP() OpenNTP state configured() { File(“/etc/ntpd.conf”).content(“blah”) }

Slide 25

Slide 25 text

What ? Language concepts ▪ The universe ▪ The only resource that is automatically instantiated with a state ▪ Has a main state that you must define 25

Slide 26

Slide 26 text

What ? Language concepts ▪ Metadata ▪ Just key / values ▪ Starts with a ‘@’ ▪ Does not change the language ▪ Change how things are compiled for a given target 26

Slide 27

Slide 27 text

What ? Technique metadata example 27 @name="Configure NTP" @description="NTP test technique" @version="1.0" @parameters=[ “server_name ]

Slide 28

Slide 28 text

What ? Language concepts ▪ Classic types: dict, array, string, integer, boolean ▪ A parameter can have a type and a default value ▪ Default type is “string” ▪ Or detected from default value 28

Slide 29

Slide 29 text

What ? Language concepts ▪ Type: dict ▪ A JSON like object - dict in python - Hashmap - ... 29

Slide 30

Slide 30 text

What ? Type example 30 function1() function2(a:integer, b=”default”) function3(a:integer, b) function4(a = { “key”:”default value”})

Slide 31

Slide 31 text

What ? Language concepts ▪ Type: Enum ▪ One of many (C / rust enum without data) ▪ Can be inferred from other enum ▪ Ex: we can infer a. debian from debian-9 b. OK from success 31

Slide 32

Slide 32 text

What ? Enum example 32 enum outcome { kept, repaired, error } global enum os { ubuntu, debian } enum os ~> family { ubuntu -> debian, debian -> debian }

Slide 33

Slide 33 text

What ? Language concepts ▪ Case: Enum ▪ We can check that all cases are handled ▪ A case must have all cases or a default ▪ Accept complex boolean expression base on enum ▪ Having a default that does nothing is acceptable as long as it is explicit 33

Slide 34

Slide 34 text

What ? Enum example 34 case { ubuntu => File("/tmp").permissions("root", "root", "g+w"), os:debian | centos => File("/tmp").permissions("user", "user", "g+w") default => error(“BUG”) } case { outvar =~ repaired => log(“repaired”) default => noop }

Slide 35

Slide 35 text

What ? Mapping with existing concepts ▪ Generic method : state (all … until next step) ▪ Method category : resource ▪ Technique : resource with a state ▪ Outcome, conditions, classes : enum ▪ Hardclasses : global enum ▪ Report component : metadata 35

Slide 36

Slide 36 text

What ? Full technique example 36 @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 ntp_present }

Slide 37

Slide 37 text

A new language ! When ? 37

Slide 38

Slide 38 text

When ? First release when it’s ready ▪ Rudder 6.1 ▪ But let’s be incremental ▪ Target a language subset to create techniques 38

Slide 39

Slide 39 text

When ? Can still be changed ▪ Language definition still open ▪ First version is for testing applicability ▪ Your input can improve things 39

Slide 40

Slide 40 text

When ? Next, target the rest ▪ Generic methods writing in rudder-lang ▪ Everything in rudder-lang ? ▪ New language elements ▪ Key value store ? 40

Slide 41

Slide 41 text

When ? Language concepts ▪ Function ▪ Takes an input and gives matching output ▪ Output for a given input should not change ▪ Can be a combination of functions 41

Slide 42

Slide 42 text

When ? Language concepts ▪ Measure ▪ Do not modify a resource ▪ Get information that may change or not ▪ Can be a combination of measures and functions 42

Slide 43

Slide 43 text

When ? Language concepts ▪ Action ▪ Modifies the state of a resource ▪ Can be a combinations of actions, functions, and measures 43

Slide 44

Slide 44 text

When ? Language concepts ▪ State ▪ Define a resource state ▪ Do not change things that don’t need ▪ Update things that need ▪ Can be a combination of states and functions 44

Slide 45

Slide 45 text

When ? Language concepts ▪ Unsafe ▪ Allows things that should not usually be allowed ▪ Allows an action to be used in a state a. Ex: restart a service after a file change ▪ Allows an external command to be used in a measure a. Ex: shell command 45

Slide 46

Slide 46 text

When ? Language concepts ▪ Iteration ▪ Iterate over a list ▪ Explicitly 46

Slide 47

Slide 47 text

When ? Language concepts ▪ Templating ▪ Integrate template parsing in the language ▪ Detect template error and missing variables at compile time 47

Slide 48

Slide 48 text

Questions ? 48