Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
body common control {
bundlesequence => { "set_dns_configuration" } ;
}
#######################################################################
# Configure DNS
# Use Google's DNS servers, and set the defaut domain to normation.com
#######################################################################
bundle agent set_dns_configuration {
vars:
"resolvers" slist => { "8.8.8.8", "8.8.4.4" };
"searchlist" slist => { "normation.com" };
files:
"$(sys.resolv)"
create => "true",
edit_line => doresolv("@(this.searchlist)","@(this.resolvers)"),
comment => "Configuring the searchlist and dns in the resolv.conf file ";
}
#######################################################
# Configure the resolv.conf file
# Setting the search and nameserver values
# Adding a header to tell the file is configured by Cfengine
#######################################################
bundle edit_line doresolv(search,resolvers) {
delete_lines:
"search.*";
"nameserver.*";
insert_lines:
"#############################################################
### This file is configured by Cfengine.
### Manually editing the file might lead Cfengine
### to change back its content
#############################################################"
location => start,
insert_type => "preserve_block";
"search $(search)";
"nameserver $(resolvers)";
}
# This body comes from the cfengine_stdlib.cf
body location start {
before_after => "before";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.