Coder Social home page Coder Social logo

saltstack-formulas / dhcpd-formula Goto Github PK

View Code? Open in Web Editor NEW
8.0 41.0 55.0 376 KB

Home Page: http://docs.saltstack.com/en/latest/topics/development/conventions/formulas.html

License: Other

SaltStack 7.61% Ruby 51.45% JavaScript 14.82% Shell 4.49% Jinja 21.63%

dhcpd-formula's Introduction

dhcpd

Travis CI Build Status Semantic Release

Formula to install, configure and start dhcpd.

Table of Contents

General notes

See the full SaltStack Formulas installation and usage instructions.

If you are interested in writing or contributing to formulas, please pay attention to the Writing Formula Section.

If you want to use this formula, please pay attention to the FORMULA file and/or git tag, which contains the currently released version. This formula is versioned according to Semantic Versioning.

See Formula Versioning Section for more details.

Contributing to this repo

Commit message formatting is significant!!

Please see How to contribute for more details.

Available states

dhcpd

Install and turn on dhcpd.

Note

To have more pythonic variables the dashes ('-') in their names are replaced with underscores ('_') so 'dynamic-bootp' becomes 'dynamic_bootp' in pillar[dhcpd].

dhcpd.config

Manage configuration for dhcpd. See pillar.example for pillar-data for a sample configuration.

Testing

Linux testing is done with kitchen-salt.

Requirements

  • Ruby
  • Docker
$ gem install bundler
$ bundle install
$ bin/kitchen test [platform]

Where [platform] is the platform name defined in kitchen.yml, e.g. debian-9-2019-2-py3.

bin/kitchen converge

Creates the docker instance and runs the dhcpd.config main state, ready for testing.

bin/kitchen verify

Runs the inspec tests on the actual instance.

bin/kitchen destroy

Removes the docker instance.

bin/kitchen test

Runs all of the stages above in one go: i.e. destroy + converge + verify + destroy.

bin/kitchen login

Gives you SSH access to the instance for manual testing.

dhcpd-formula's People

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dhcpd-formula's Issues

Rewrite of dhcpd-formula

Hi,

  • I am rewriting dhcpd-formula, using #18 and my #25.
  • I am also adding IPv6 capability.
  • Also changing underscores to dashes everywhere for consistency.

I am wondering what you will accept. I don't want my work to go to waste... If I do the work, will you accept it?
Also: shall I put my "new" stuff under a new pillar like the nginx formula, i.e. like this:

dhcpd:
    ng:
        authoritative: true

This would stop any name clashing between the old and the new stanzas. But it would make things awkward, perhaps, since IPv6 isn't even present in the old style.

Any thoughts?

[InSpec] Unused assignment of `service_config_filename` when fixing using `rubocop`

@baby-gnu I've been working through the formulas and fixing the "easy ones" for rubocop lint issues. This formula is a good candidate; rubocop --safe-auto-correct gets us down to the last two offenses:

dhcpd-formula$ rubocop --safe-auto-correct
Inspecting 5 files
..W..

Offenses:

test/integration/default/controls/config_spec.rb:9:3: W: Lint/UselessAssignment: Useless assignment to variable - service_config_filename.
  service_config_filename = '/etc/default/isc-dhcp-server'
  ^^^^^^^^^^^^^^^^^^^^^^^
test/integration/default/controls/config_spec.rb:12:3: W: Lint/UselessAssignment: Useless assignment to variable - service_config_filename.
  service_config_filename = '/etc/rc.conf.d/dhcpd'
  ^^^^^^^^^^^^^^^^^^^^^^^

5 files inspected, 2 offenses detected

Tracking back gets us to eb3c948. We're defining service_config_filename but actually using config_filename, the same as the block above. Now if service_config_filename was defined for 'arch', 'suse' and 'redhat', this would be a simple fix.

How would you like this to be resolved?

[FEATURE]

While developing our deployment server, we encountered the following issues:

  1. We would like to add omapi settings (global) to the dhcpd.conf file.
  2. We would like to add the next-server setting (global) to the dhcpd.conf file.
  3. We would like to add custom options to the dhcpd.conf file.
  4. We would like to add custom lines to the dhcpd.conf file.

Rationale:

  1. We make use of Foreman for deploying nodes and Foreman makes use of the omapi interface.
  2. We need the next-server setting for all hosts.
  3. We have some specific custom options like:
    option fqdn.no-client-update True;
  4. We have some specific lines to add:
    if option architecture = 00:06 {
    filename "grub2/shim.efi";
    } elsif option architecture = 00:07 {
    filename "grub2/shim.efi";
    } elsif option architecture = 00:09 {
    filename "grub2/shim.efi";
    } else {
    filename "pxelinux.0";
    }

In order to realize this, we made some modifications to the dhcpd formula. But that will give
us a maintenance issue in the future. It would be nice to have these updates in a next version
of the formula.

The changes we made are:
changes.patch.txt

[BUG] allow and deny items parsed on single line

Your setup

Formula commit hash / release tag

The formula used is v0.11.1, I checked the code in the master branch and it has the same problem.

Versions reports (master & minion)

Salt Version:
Salt: 2019.2.4

Dependency Versions:
cffi: Not Installed
cherrypy: Not Installed
dateutil: Not Installed
docker-py: Not Installed
gitdb: Not Installed
gitpython: Not Installed
ioflo: Not Installed
Jinja2: 2.8.1
libgit2: Not Installed
libnacl: Not Installed
M2Crypto: 0.33.0
Mako: Not Installed
msgpack-pure: Not Installed
msgpack-python: 0.5.6
mysql-python: Not Installed
pycparser: Not Installed
pycrypto: Not Installed
pycryptodome: Not Installed
pygit2: Not Installed
Python: 3.6.8 (default, Aug 7 2019, 17:28:10)
python-gnupg: Not Installed
PyYAML: 3.11
PyZMQ: 15.3.0
RAET: Not Installed
smmap: Not Installed
timelib: Not Installed
Tornado: 4.4.2
ZMQ: 4.1.4

System Versions:
dist: centos 7.7.1908 Core
locale: UTF-8
machine: x86_64
release: 3.10.0-1062.18.1.el7.x86_64
system: Linux
version: CentOS Linux 7.7.1908 Core

Pillar / config used

Below an example of the pillar file used. Note the allow key.

dhcpd:
    domain_name: example.org
    authoritative: false
    omapi_port: port
    omapi_key: key
    next-server: ip-address
    ddns_update_style: none
    keys:                    # Replace values below with created key
      key:
          algorithm: algorithm
          secret: key
    allow:
      - booting
      - bootp
    domain_name_servers:
        - ns1.example.org       # replace and add the local dns server if exists
    default_lease_time: 43200
    max_lease_time: 86400
    log_facility: local7

Bug details

Describe the bug

When running the formula and adding items 'allow' items in the pillar file they are pasted after each other and after the last item declared before it. This is caused to due to the for loop stripping the new lines. The first option when not specified is dhcpd.use_host_decl_names, which when not specified pastes the allow items behind a commented item.

Output:
#use-host-decl-names off;allow booting;allow bootp;

Steps to reproduce the bug

Do not specify the key dhcpd.use_host_decl_names and add several allow items like shown in the pillar example.

Expected behaviour

Output everything with newlines properly like show below.

#use-host-decl-names off;

allow booting;
allow bootp;

Attempts to fix the bug

Below the dhcp.allow with the allow in its own line

    {%- if dhcpd.allow %}
      {% if dhcpd.allow is iterable and dhcpd.allow  is not string %}  
        {%- for item in dhcpd.allow  %}  
allow {{ item }};  
       {%- endfor %}  
      {%- else %}
allow {{ dhcpd.allow }};  
      {%- endif %}  
    {%- endif %}  

Using the code above will result in the mentioned expected outcome

Additional context

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.