jeromer / haiconf Goto Github PK
View Code? Open in Web Editor NEWLua based configuration management
License: BSD 2-Clause "Simplified" License
Lua based configuration management
License: BSD 2-Clause "Simplified" License
A multiple of things are handled in distro specific ways. For example, Debian and RHEL use different way of managing services
As such we need to support these distributions. But instead of trying to guess which distribution we use at runtime, we could simply use build specific flag so we can provide distribution specific builds (Debian, RHEL, etc).
Documentation about build tags is available at http://golang.org/pkg/go/build/.
We can start by using the debian
tag as it is the distribution haiconf is primiraly built for.
First shot of the prototype:
Cron({
Command = "/path/to/ntpdate",
Ensure = "present",
Env = {
PATH = "/foo/bin",
MAILTO = "foo",
SHELL = "/bin/zsh",
},
Schedule = {
-- yearly / monthly / weekly / daily / hourly
Predefined = "yearly",
-- alternatively :
WeekDay = "*",
Month = "*",
MonthDay = "*",
Hour = "*",
Minute = "*",
},
Owner="root",
})
Command
corresponds to the command to run
Ensure
: either present
(the crontab entry must be there) or absent
(the crontab entry must be removed)
Env
: a map of the environment variables that must be used for the crontab entry. This directly maps to the system's env variables.
Schedule
: a map of different possibilities to handle the crontab entry. Either as a Predefined
setting or manually by using WeekDay
, Month
, MonthDay
, Hour
, Minute
such as:
* * * * * command to execute
┬ ┬ ┬ ┬ ┬
│ │ │ │ │
│ │ │ │ │
│ │ │ │ └───── WeekDay (0 - 6, 0 = sunday)
│ │ │ └────────── Month (1 - 12)
│ │ └─────────────── MonthDay (1 - 31)
│ └──────────────────── Hour (0 - 23, 0 = midnight)
└───────────────────────── Minute (0 - 59)
Owner
corresponds to the user who will store the crontab entry. Equivalent to crontab -u
. Owner
is mandatory.
We need to get access to https://github.com/jeromer/libsysinfo/ variables as template variables.
All variables must be namespaced under "haiconf".
Initial prototype
Group({
Name="group1",
Ensure="present",
})
Group
creates a system group Name
if Ensure
is set to Present
or removes it of Ensure
is set to absent
.
First shot of a prototype:
Exec({
Command = "/usr/bin/foo",
ExecutionDir = "/home/someuser",
RunAs = "root",
LogOutput="/path/to/logfile.log",
Env = {
PATH = "$PATH:/usr/bin/foo",
ENV_VAR2 = "foo-bar",
}
-- in seconds
TimeOut=30
})
The Command
specified will be run from ExecutionDir
by user defined in RunAs
using extra Env
variables if specified and output will be logged to LogOutput
if specified. If the file defined in LogOutput
already exists the captured output is appended to the existing file.
If the command is still running after TimeOut
seconds, the command will be stopped. The default TimeOut
is defined to 5 seconds, which is more than enough for a normal command.
We will not implement retries as it is for very specific use case and this can be easily implement in a loop in lua.
In case the Exec
primitive is not enough/adapted users could eventually use os.execute()
available in lua: http://www.lua.org/manual/5.2/manual.html#pdf-os.execute
The prototype is
User({
Name="foo",
Password="sEcr3t",
Ensure="present",
PrimaryGroup="group1",
SecondaryGroups={"group2", "group3", "groupN"},
})
User
creates (if Ensure
it set to present
) or removes (if Ensure
is set to absent
) a user defined by Name
and Password
. If the user is created, it can be assigned to a mandatory PrimaryGroup
and optionaly SecondaryGroups
.
Lua code to reproduce the problem:
TarGz({
Source = "/etc/",
Dest = "/tmp/etc.tar.gz",
})
Obtained output:
Archiving /etc/ to /tmp/etc.tar.gz
2013/12/14 05:48:28 archive/tar: header field too long
The problematic file is
/etc/ssl/certs/TÜBİTAK_UEKAE_Kök_Sertifika_Hizmet_Sağlayıcısı_-_Sürüm_3.pem
The title says it all.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.