Giter Club home page Giter Club logo

dnsmasq's Introduction

DNSMasq

Cookbook Version Build Status OpenCollective OpenCollective License

Install and configure dnsmasq.

Maintainers

This cookbook is maintained by the Sous Chefs. The Sous Chefs are a community of Chef cookbook maintainers working together to maintain important cookbooks. If you’d like to know more please visit sous-chefs.org or come chat with us on the Chef Community Slack in #sous-chefs.

Recipes

default

Installs the dnsmasq package. Depending on the [:dnsmasq][:enable_dns] and [:dnsmasq][:enable_dhcp] attributes it includes the dns and dhcp recipes respectively.

dhcp

Includes the default recipe and writes the contents of the node[:dnsmasq][:dhcp] attribute hash to /etc/dnsmasq.d/dhcp.conf. Here is an example of the necessary attributes for DHCP with TFTP enabled:

'dnsmasq' => {
  'enable_dhcp' => true,
  'dhcp' => {
    'dhcp-authoritative' => nil,
    'dhcp-range' => 'eth0,10.0.0.10,10.0.0.100,12h',
    'dhcp-option' => '3', #turns off everything except basic DHCP
    'domain' => 'lab.atx',
    'interface' => 'eth0',
    'dhcp-boot' => 'pxelinux.0',
    'enable-tftp' => nil,
    'tftp-root' => '/var/lib/tftpboot',
    'tftp-secure' => nil
  }
}

dns

Includes the default and manage_hostsfile recipes, then writes the content of the node[:dnsmasq][:dns] attribute hash to /etc/dnsmasq.d/dns.conf.

manage_hostsfile

Loads the dnsmasq data bag managed_hosts item and merges it with any nodes in the [:dnsmasq][:managed_hosts] attribute, then writes them out to /etc/hosts/ via the hosts_file cookbook.

Usage

Data Bag

If you need manage your DNS hosts you may use the dnsmasq data bag managed_hosts item. It takes the form:

{
    "id": "managed_hosts",
    "maps": {
      "192.168.0.100": "www.google.com",
      "192.168.0.101": ["www.yahoo.com", "www.altavista.com"]
    }
}

Attributes

  • [:dnsmasq][:enable_dns] whether to enable the DNS service, default is true
  • [:dnsmasq][:enable_dhcp] whether to enabled the DHCP service, default is false
  • [:dnsmasq][:managed_hosts] hash of IPs and hostname/array of hostnames for the manage_hostfile recipe, default is empty
  • [:dnsmasq][:managed_hosts_bag] name of the data bag item, default is managed_hosts
  • [:dnsmasq][:dhcp] = hash of settings and values for the /etc/dnsmasq.d/dhcp.conf, default is empty
  • [:dnsmasq][:dhcp_options] = list of options to be added to the /etc/dnsmasq.d/dhcp.conf (ie. ['dhcp-host=80:ee:73:0a:fa:d9,crushinator,10.0.0.11']), default is empty.
  • [:dnsmasq][:dns] hash of settings and values for the /etc/dnsmasq.d/dns.conf, defaults are
{
  'no-poll' => nil,
  'no-resolv' => nil,
  'server' => '127.0.0.1'
}
  • [:dnsmasq][:dns_options] = list of options to be added to the /etc/dnsmasq.d/dns.conf, default is empty.

Testing

Please refer to the TESTING file to see instructions for testing this cookbook.

Contributors

This project exists thanks to all the people who contribute.

Backers

Thank you to all our backers!

https://opencollective.com/sous-chefs#backers

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website.

https://opencollective.com/sous-chefs/sponsor/0/website https://opencollective.com/sous-chefs/sponsor/1/website https://opencollective.com/sous-chefs/sponsor/2/website https://opencollective.com/sous-chefs/sponsor/3/website https://opencollective.com/sous-chefs/sponsor/4/website https://opencollective.com/sous-chefs/sponsor/5/website https://opencollective.com/sous-chefs/sponsor/6/website https://opencollective.com/sous-chefs/sponsor/7/website https://opencollective.com/sous-chefs/sponsor/8/website https://opencollective.com/sous-chefs/sponsor/9/website

dnsmasq's People

Contributors

akovtunov avatar axelrtgs avatar chrisroberts avatar cwjohnston avatar damacus avatar e100 avatar johnroesler avatar ka2n avatar kampfschlaefer avatar kitchen-porter avatar lpmi-13 avatar markgibbons avatar mattray avatar powerschill avatar ramereth avatar renovate[bot] avatar tas50 avatar ton31337 avatar whitekid avatar xorima avatar xorimabot avatar zmaupin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnsmasq's Issues

Update builds to be parallel

🗣️ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

👻 Brief Description

As part of our build process we should build each possible operating system separately

  1. Ensure you have dokken setup and working:
  2. dokken: aliased to KITCHEN_LOCAL_YAML=kitchen.dokken.yml kitchen
  3. run dokken list, you should see a list of builds with dokken as the provider
  4. download: https://github.com/sous-chefs/repo-management/blob/master/scripts/circleci_maker.rb and make this executable
  5. run: dokken list -j | ./circleci_maker.rb > .circleci/config.yml

Issue sprouted from sous-chefs/meta/issues/112. If not applicable then issue should be closed.

Disabled systemd-resolved breaks cookbook

Since version 0.3.0 the cookbook fails due to the fact systemd-resolved is disabled which results in the problem, that the dnsmasq package can't be installed because apt can't resolve the package repository URL. I'm converging against Ubuntu 18.04 using chef-client 14.12.9

having dnsmasq cookbook work with chef-client < 10.28 (or 11.6)

Hi, I'm currently using chef-client 10.12, which doesn't include the lazy attribute evaluation feature included in Chef 11.6 and 10.28 ( http://www.getchef.com/blog/2013/09/03/chef-10-28-0-released/ ).

In order to have the dnsmasq cookbook working with my platform, I made the following update:

--- a/cookbooks/dnsmasq/recipes/dhcp.rb
+++ b/cookbooks/dnsmasq/recipes/dhcp.rb
@@ -13,10 +13,10 @@ end
 template '/etc/dnsmasq.d/dhcp.conf' do
   source 'dynamic_config.erb'
   mode 0644
-  variables lazy {{
+  variables(
     :config => node['dnsmasq']['dhcp'].to_hash,
     :list => node['dnsmasq']['dhcp_options']
-    }}
+  )
   notifies :restart, resources(:service => 'dnsmasq'), :immediately
 end

Well, with this patch everything seems to work well on my platform. I was just wondering what is the reason you use this lazy evaluation, which makes dnsmasq cookbook incompatible with former chef versions ?

how to deploy it for community use

hello i am a member of fedora chinese community ,for some reason chinese could't open utube or google,so i wanna build a 'green' dns server like openerdns.(for open google without VPN.)
with the help of http://blog.cnwyhx.com/centos-linux-dnsmasq-install-dns/
i have build dnsmasq in digitalocean (Singapore) and now i wanna it for community use(every one in community could just change their dns to my DO public IP and open google normally.
how could i get it done?

DNS resolution not working on Ubunut 20.04

🗣️ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

👻 Brief Description

When including the dnsmasq default recipe, the dns setting on my vagrant box are broken by the DNSSTUBLISTENER option. This prevents the dnsmasq package from being installed.

🥞 Cookbook version

1.1.0

👩‍🍳 Chef-Infra Version

Chef Infra Client, version 17.10.3

🎩 Platform details

Ubuntu 20.04 LTS

Steps To Reproduce

Steps to reproduce the behavior:

When I try to include the dnsmasq recipe using following

apt_update 'update' do
  action :update
end

include_recipe 'dnsmasq::default'

the /etc/systemd/resolved.conf.d/dnsmasq.conf is updated with DNSStubListener=no which break any DNS queries and prevents the next step from installing the dnsmasq package.

       Recipe: dnsmasq::default
         * directory[/etc/systemd/resolved.conf.d] action create
           - create new directory /etc/systemd/resolved.conf.d
         * file[Fix systemd-resolved conflict] action create
           - create new file /etc/systemd/resolved.conf.d/dnsmasq.conf
           - update content in file /etc/systemd/resolved.conf.d/dnsmasq.conf from none to 4f33e1
           --- /etc/systemd/resolved.conf.d/dnsmasq.conf	2022-10-26 08:01:38.049011854 +0000
           +++ /etc/systemd/resolved.conf.d/.chef-dnsmasq20221026-12866-fsbqaf.conf	2022-10-26 08:01:38.049011854 +0000
           @@ -1,2 +1,4 @@
           +[Resolve]
           +DNSStubListener=no
         * service[systemd-resolved] action restart
           - restart service service[systemd-resolved]
         * service[systemd-resolved] action nothing (skipped due to action :nothing)
         * apt_package[dnsmasq] action install
           
           ================================================================================
           Error executing action `install` on resource 'apt_package[dnsmasq]'
           ================================================================================
           
           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '100'
           ---- Begin output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "dnsmasq=2.80-1.1ubuntu1.5"] ----
           STDOUT: Reading package lists...
           Building dependency tree...
           Reading state information...
           The following additional packages will be installed:
             dns-root-data dnsmasq-base libidn11
           Suggested packages:
             resolvconf
           The following NEW packages will be installed:
             dns-root-data dnsmasq dnsmasq-base libidn11
           0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
           Need to get 383 kB of archives.
           After this operation, 1,155 kB of additional disk space will be used.
           Err:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 dns-root-data all 2019052802
             Temporary failure resolving 'in.archive.ubuntu.com'
           Err:2 http://in.archive.ubuntu.com/ubuntu focal/main amd64 libidn11 amd64 1.33-2.2ubuntu2
             Temporary failure resolving 'in.archive.ubuntu.com'
           Ign:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1.5
           Ign:4 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 dnsmasq all 2.80-1.1ubuntu1.5
           Err:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1.5
             Temporary failure resolving 'in.archive.ubuntu.com'
           Err:4 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 dnsmasq all 2.80-1.1ubuntu1.5
             Temporary failure resolving 'in.archive.ubuntu.com'
           STDERR: E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/d/dns-root-data/dns-root-data_2019052802_all.deb  Temporary failure resolving 'in.archive.ubuntu.com'
           E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/libi/libidn/libidn11_1.33-2.2ubuntu2_amd64.deb  Temporary failure resolving 'in.archive.ubuntu.com'
           E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/d/dnsmasq/dnsmasq-base_2.80-1.1ubuntu1.5_amd64.deb  Temporary failure resolving 'in.archive.ubuntu.com'
           E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/universe/d/dnsmasq/dnsmasq_2.80-1.1ubuntu1.5_all.deb  Temporary failure resolving 'in.archive.ubuntu.com'
           E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
           ---- End output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "dnsmasq=2.80-1.1ubuntu1.5"] ----
           Ran ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "dnsmasq=2.80-1.1ubuntu1.5"] returned 100
           
           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cache/cookbooks/dnsmasq/recipes/default.rb
           
            15: package 'dnsmasq'
            16: user 'dnsmasq'
           
           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cache/cookbooks/dnsmasq/recipes/default.rb:15:in `from_file'
           
           apt_package("dnsmasq") do
             package_name "dnsmasq"
             action [:install]
             default_guard_interpreter :default
             declared_type :package
             cookbook_name "dnsmasq"
             recipe_name "default"
           end
           
           System Info:
           ------------
           chef_version=17.10.3
           platform=ubuntu
           platform_version=20.04
           ruby=ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]
           program_name=/opt/chef/bin/chef-client
           executable=/opt/chef/bin/chef-client
           
       
       Running handlers:
       [2022-10-26T08:01:42+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2022-10-26T08:01:42+00:00] ERROR: Exception handlers complete
       Infra Phase failed. 3 resources updated in 08 seconds
       [2022-10-26T08:01:42+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2022-10-26T08:01:42+00:00] FATAL: ---------------------------------------------------------------------------------------
       [2022-10-26T08:01:42+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
       [2022-10-26T08:01:42+00:00] FATAL: ---------------------------------------------------------------------------------------
       [2022-10-26T08:01:42+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: apt_package[dnsmasq] (dnsmasq::default line 15) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '100'
       ---- Begin output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "dnsmasq=2.80-1.1ubuntu1.5"] ----
       STDOUT: Reading package lists...
       Building dependency tree...
       Reading state information...
       The following additional packages will be installed:
         dns-root-data dnsmasq-base libidn11
       Suggested packages:
         resolvconf
       The following NEW packages will be installed:
         dns-root-data dnsmasq dnsmasq-base libidn11
       0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
       Need to get 383 kB of archives.
       After this operation, 1,155 kB of additional disk space will be used.
       Err:1 http://in.archive.ubuntu.com/ubuntu focal/main amd64 dns-root-data all 2019052802
         Temporary failure resolving 'in.archive.ubuntu.com'
       Err:2 http://in.archive.ubuntu.com/ubuntu focal/main amd64 libidn11 amd64 1.33-2.2ubuntu2
         Temporary failure resolving 'in.archive.ubuntu.com'
       Ign:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1.5
       Ign:4 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 dnsmasq all 2.80-1.1ubuntu1.5
       Err:3 http://in.archive.ubuntu.com/ubuntu focal-updates/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1.5
         Temporary failure resolving 'in.archive.ubuntu.com'
       Err:4 http://in.archive.ubuntu.com/ubuntu focal-updates/universe amd64 dnsmasq all 2.80-1.1ubuntu1.5
         Temporary failure resolving 'in.archive.ubuntu.com'
       STDERR: E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/d/dns-root-data/dns-root-data_2019052802_all.deb  Temporary failure resolving 'in.archive.ubuntu.com'
       E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/libi/libidn/libidn11_1.33-2.2ubuntu2_amd64.deb  Temporary failure resolving 'in.archive.ubuntu.com'
       E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/main/d/dnsmasq/dnsmasq-base_2.80-1.1ubuntu1.5_amd64.deb  Temporary failure resolving 'in.archive.ubuntu.com'
       E: Failed to fetch http://in.archive.ubuntu.com/ubuntu/pool/universe/d/dnsmasq/dnsmasq_2.80-1.1ubuntu1.5_all.deb  Temporary failure resolving 'in.archive.ubuntu.com'
       E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
       ---- End output of ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "dnsmasq=2.80-1.1ubuntu1.5"] ----
       Ran ["apt-get", "-q", "-y", "--allow-downgrades", "-o", "Dpkg::Options::=--force-confdef", "-o", "Dpkg::Options::=--force-confold", "install", "dnsmasq=2.80-1.1ubuntu1.5"] returned 100

🚓 Expected behavior

The default recipe to install dnsmasq without breaking dns resolution until further configurations are applied.

Remove .rubocop.yml with Dangerfile

🗣️ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

👻 Brief Description

If the only thing in the .rubocop/yml is Dangerfile
Run the latest cookstyle
Remove .rubpopo.yml

Issue sprouted from sous-chefs/meta/issues/108. If not applicable then issue should be closed.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • sous-chefs/.github 3.1.1
  • actions/checkout v4
  • actionshub/chef-install 3.0.0
  • actionshub/test-kitchen 3.0.0
.github/workflows/stale.yml
  • actions/stale v9

  • Check this box to trigger a request for Renovate to run again on this repository

Update Changelog

🗣️ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

👻 Brief Description

Update all CHANGELOGs to follow standard defined at https://keepachangelog.com/

Issue sprouted from sous-chefs/meta/issues/101. If not applicable then issue should be closed.

Run latest cookstyle

🗣️ Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

👻 Brief Description

Chef have released updated cookstyle rules, we should therefore run the auto fix against the cookbook

  1. Ensure you are on the latest stable chef-workstation
  2. Run cookstyle -a

Issue sprouted from sous-chefs/meta/issues/111. If not applicable then issue should be closed.

manage_hostsfile recipe not working

👻 Brief Description

manage_hostsfile does not work as expected. The following error msg is encountered:

'hosts_file_entry' is not a valid Chef resource.

Please consult the documentation for a list of valid resources:

  https://docs.chef.io/resource_reference.html

🥞 Cookbook version

1.0.1

👩‍🍳 Chef-Infra Version

chef-client 16/17

🎩 Platform details

CentOS 7

Steps To Reproduce

Steps to reproduce the behavior:

  1. Create wrapper cookbook.
  2. add include_recipe 'dnsmasq' to the default recipe
  3. Set the following attributes:
default[:dnsmasq][:managed_hosts] = {
    '10.0.0.1' => 'a.random.hostname',
    '10.0.0.2' => 'evenmore.random.hostname'
  }

🚓 Expected behavior

Should create two entries in /etc/hosts that dnsmasq will resolv dns requests for.

chef compile error

Recipe Compile Error in /var/cache/chef/cookbooks/dnsmasq/recipes/default.rb

Chef::Exceptions::ResourceNotFound

Cannot find a resource matching template[managed_hosts_file](did you define it first?)

Cookbook Trace:

/var/cache/chef/cookbooks/dnsmasq/recipes/default.rb:9:in from_file' /var/cache/chef/cookbooks/dnsmasq/recipes/default.rb:7:infrom_file'

Relevant File Content:

/var/cache/chef/cookbooks/dnsmasq/recipes/default.rb:

1: package 'dnsmasq'
2:
3: if(node[:dnsmasq][:manage_hostsfile])
4: include_recipe 'hosts_file'
5: end
6:
7: service 'dnsmasq' do
8: action :nothing
9: subscribes :restart, resources(:template => 'managed_hosts_file'), :immediately

Log message should be WARN or INFO message when the data bag item "dnsmasq" "managed_hosts" isn't found

👻 Brief Description

Chef logs an ERROR when the data bag item dnsmasq managed_hosts is not found. This data bag item is optional, so it shouldn't be logged as an ERROR. Perhaps a WARN is more appropriate or no message at all.

[2020-12-29T08:50:42+00:00] ERROR: Failed to load data bag item: "dnsmasq" "managed_hosts"

🥞 Cookbook version

0.3.4

👩‍🍳 Chef-Infra Version

Chef 15 & 16

🎩 Platform details

RHEL8

Steps To Reproduce

Steps to reproduce the behavior:

  1. Run the dnsmasq::dns recipe with all attributes unmodified from their default values
  2. look at the Chef Infra Client log file output

🚓 Expected behavior

The message logged should not be ERROR level since the data bag item is optional.

➕ Additional context

Add any other context about the problem here. e.g. related issues or existing pull requests.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.