Coder Social home page Coder Social logo

ansible-dhcpd's Introduction

DebOps logo DebOps

Your Debian-based data center in a box

GitHub CI GitLab CI CII Best Practices REUSE status RSS commits

The DebOps project provides a set of general-purpose Ansible roles that can be used to manage Debian or Ubuntu hosts. In addition, a default set of Ansible playbooks can be used to apply the provided roles in a controlled way, using Ansible inventory groups.

The roles are written with a high customization in mind, which can be done using Ansible inventory. This way the role and playbook code can be shared between multiple environments, with different configuration in to each one.

Services can be managed on a single host, or spread between multiple hosts. DebOps provides support for different SQL and NoSQL databases, web servers, programming languages and specialized applications useful in a data center environment or in a cluster. The project can also be used to deploy virtualization environments using KVM/libvirt, Docker or LXC technologies to manage virtual machines and/or containers.

You can find out more about DebOps features on the project's documentation page.

Quick start

Start a Docker container which acts as an Ansible Controller host with DebOps support, based on Debian Buster:

docker run -it --rm debops/debops
cd src/controller ; debops run common --diff

Or, create a Vagrant VM which acts as an Ansible Controller host:

git clone https://github.com/debops/debops
cd debops && vagrant up && vagrant ssh
cd src/controller ; debops run common --diff

You can use configuration in the src/controller subdirectory to try out DebOps against the container/VM, or create your own DebOps project directory using debops project init command.

More quick start tips can be found in the DebOps quick start guide.

Installation

You can install the DebOps Python package, which includes the DebOps roles and playbooks, as well as additional scripts which can be used to setup separate project directories and run Ansible in a convenient way. To install the Python package with Ansible and other required dependencies, run the command:

pip install --user debops[ansible]

Alternatively, DebOps roles are available on Ansible Galaxy as an Ansible Collection which can be installed using the ansible-galaxy command:

ansible-galaxy collection install debops.debops

Read the installation instructions in the DebOps documentation for more details about required software and dependencies.

Getting started

Ansible uses SSH to connect to and manage the hosts. DebOps enforces the SSH security by disabling password authentication, therefore using SSH keys to connect to the hosts is strongly recommended. This can be changed using the inventory variables.

During initial deployments you might find that the firewall created by DebOps blocked you from accessing the hosts. Because of that it's advisable to have an out-of-band console access to the host which can be used to login and troubleshoot the connection.

Create a new environment within a DebOps "project directory", add some hosts in the Ansible inventory and run the default DebOps playbook against them to configure them:

# Create a new environment
debops project init ~/src/projects/my-environment
cd ~/src/projects/my-environment

# Modify the 'ansible/inventory/hosts' file to suit your needs, for example
# uncomment the local host to configure it with DebOps

# Run the full playbook against all hosts in the inventory
debops run site

# Run the common playbook against specific host in the inventory
debops run common -l <hostname>

You should read the Getting Started with DebOps guide for a more in-depth explanation of how the project can be used to manage multiple hosts via Ansible.

Development

Create a fork of this repository and clone it to your workstation. Create a development DebOps environment and symlink the forked repository in it. Now you can create new playbooks/roles in the forked repository and see their results in the development environment.

git clone [email protected]:<username>/debops ~/src/github.com/<username>/debops
cd ~/src/github.com/<username>/debops
git remote add upstream https://github.com/debops/debops.git

debops project init ~/src/projects/debops-devel
cd ~/src/projects/debops-devel
ln -s ~/src/github.com/<username>/debops debops

You can pull latest changes to the project from the upstream repository:

cd ~/src/github.com/<username>/debops
git checkout master
git fetch upstream
git rebase upstream/master

Read the development guide file for more details about the DebOps development process.

Contributing

DebOps development is done via a distributed development model. New features and changes are prepared in a fork of the official repository and are published to the original repository via GitHub pull requests. PRs are reviewed by the DebOps developer team and if accepted, are merged in the main repository.

GPG-signed git commits are preferred to ensure authenticity.

Read the contributing guide file for more details about how to contribute to DebOps.

Licensing

The DebOps project is licensed under the GNU General Public License 3.0 or later. You can find full text of the license in the LICENSES/GPL-3.0-or-later.txt file.

Some files included with the DebOps project use a different license. The licenses are marked in these files using the SPDX license identifiers and can be found in the LICENSES/ subdirectory. They are also included in the project tarballs, Ansible Collections and Python packages. The project uses the REUSE Specification and its associated tool to check and verify copyright and license information in all files.

ansible-dhcpd's People

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-dhcpd's Issues

"subnet None" in dhcp.conf

The template seems to have some issues with my config which results in a dhcp.conf with "subnet None".

config:

dhcpd_mode: 'server'
dhcpd_ipversion: '4'
dhcpd_authoritative: True
dhcpd_interfaces: [eth0]
dhcpd_nameservers: [100.126.1.16]
dhcpd_domain_name: [domain.de]

dhcpd_shared_networks:
  - name: 'shared'
    comment: "Remote shared network"
    subnets: '{{ dhcpd_subnets_local }}'
    options: |
      default-lease-time 600;
      max-lease-time 900;

dhcpd_subnets_local:
  - subnet: '100.126.1.0'
    netmask: '255.255.254.0'
    routers: '100.126.0.1'
    options: |
      default-lease-time 300;
      max-lease-time 7200;
      allow booting;
      allow bootp;
      filename "pxelinux.0";
      next-server 100.126.1.21;
    pools:
      - comment: "default ip pool for common services"
        range: '100.126.1.115 100.126.1.200'

resulting /etc/dhcp/dhcp.conf:

# Remote shared network
shared-network "shared" {
        default-lease-time 600;
        max-lease-time 900;

        subnet None netmask 255.255.254.0 {
                option routers 100.126.0.1;
                default-lease-time 300;
                max-lease-time 7200;
                allow booting;
                allow bootp;
                filename "pxelinux.0";
                next-server 100.126.1.21;
                pool {
                        # default ip pool for common services
                        range 100.126.1.115 100.126.1.200;
                }
        }
}

# Generated automatically by Ansible
subnet 100.126.0.0 netmask 255.255.254.0 {
        option routers 100.126.0.1;
}

Thanks in advance

how to define hosts inside pools?

I don't get it ... how can I define hosts inside a pool?

I tried:

  - subnet: '10.1.3.0'
    netmask: '255.255.255.0'
    routers: '10.1.3.245'
    options: |
      default-lease-time 300;
      max-lease-time 7200;
    pools:
      - comment: "am-vip pool"
        range: '10.1.3.1 10.1.3.20'
        options: |
          default-lease-time 300;
          max-lease-time 7200;
        hosts:
         - hostname: 'examplehost'
           address: '10.1.3.11'
           ethernet: '00:00:45:00:00:00'
         - hostname: 'drei'
           address: '10.1.3.13'
           ethernet: '00:00:46:00:00:00'

and would like to have:

2 pools, one for unknown clients, one for defined/known clients, defined as above.

Is it possible with this role .. ?

Thanks in advance, Stefan

Template error (file not found) when using Jinja >= 2.8

If this is run by Jinja higher than 2.8 it fails on looking for the templates. In this bug (debops/debops#179) there is explained, that behaviour in the Python Jinja library changed in the newer version. So templates have to be changed.

Other playbooks could be affected too.

failed: [gateway] (item=etc/dhcp/dhcpd.conf) => { "changed": false, "item": "etc/dhcp/dhcpd.conf", "msg": "AnsibleError: An unhandled exception occurred while templating '{{ lookup(\"template\", \"lookup/ifupdown__kmod__dependent_load.j2\", convert_data=False) | from_yaml }}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: An unhandled exception occurred while running the lookup plugin 'template'. Error was a <class 'ansible.errors.AnsibleError'>, original message: the template file lookup/ifupdown__kmod__dependent_load.j2 could not be found for the lookup" }

dhcp-probe tasks depends on some local facts

TASK: [debops.dhcpd | Create dhcp-probe lib directory] ************************ 
fatal: [192.168.0.1] => One or more undefined variables: 'ansible_local' is undefined

Looks like 'tasks/dhcp-probe.yml' depends on some local facts that that is not mentioned in README.

Ansible Galaxy broken

I find recently I'm unable to download this role via ansible-galaxy when using the short name. Says the version does not exist. I switch to downloading via git and it fails again because it depends on secret and again ansible-galaxy is unable to fetch it. The workaround has been to define this role and secret in requirements.yml and to fetch directly from github.

Dependency missing

This play has a dependency on the debops.secret role which I no longer see here. Can that repo be restored?

# Dependancy of Debops ansible-dhcpd
#- src: https://github.com/debops/ansible-secret.git
#  scm: git
#  version: "v0.3.1"
#  name: debops.secret

"Install DHCP packages" does not work in tag v0.1.1

Ansible will fail with the following error:

failed: [dhcp.foo.bar] (item=[u'dhcpd_base_packages_map[dhcpd_mode]']) => {"failed": true, "item": ["dhcpd_base_packages_map[dhcpd_mode]"], "msg": "No package(s) matching 'dhcpd_base_packages_map[dhcpd_mode]' available"}

This happens because dhcpd_base_packages_map[dhcpd_mode] as a plain string and not as an variable.

I wonder what this means for v0.1.1 (which I got from Ansible-Galaxy). Should I simply use the master branch (since this bug is fixed there) and avoid the tagged version?

Undefined variables: 'dict object' has no attribute 'address'

I'm getting the same error again and again while trying to run the playbook for the first time and didn't manage to solve it on my own. So right now I don't know if it's a bug or I just configured something wrong.

The failure:

...
TASK: [debops.dhcpd | Configure DHCP server] **********************************
ok: [100.126.1.21] => (item=etc/default/isc-dhcp-server)
fatal: [100.126.1.21] => {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'address'", 'failed': True}
fatal: [100.126.1.21] => {'msg': 'One or more items failed.', 'failed': True, 'changed': False, 'results': [{'group': 'root', 'uid': 0, 'changed': False, 'owner': 'root', 'item': 'etc/default/isc-dhcp-server', 'state': 'file', 'gid': 0, 'mode': '0644', 'invocation': {'module_name': 'template', 'module_args': ''}, 'path': '/etc/default/isc-dhcp-server', 'size': 721}, {'msg': "AnsibleUndefinedVariable: One or more undefined variables: 'dict object' has no attribute 'address'", 'failed': True}]}

and the configs:


---
# apply debops.dhcpd Role to a target node.
- name: Infrastructure Services [DHCP server]
  hosts: 100.126.1.21

  vars_files:
    - vars-dhcpd.yml
  roles:
     - debops.dhcpd

---
dhcpd_mode: 'server'
dhcpd_ipversion: '4'
dhcpd_authoritative: True
dhcpd_interfaces: [eth0]
dhcpd_nameservers: [100.126.2.2]
dhcpd_domain_name: [domain.de]

ansible_domain: domain.de

# where to ask for DNS Server / dhcpd_dns_servers
ansible_default_ipv4.address: 100.126.1.16

dhcpd_subnets_local:
  - subnet: '100.126.10.0'
    netmask: '255.255.255.0'
    routers: '100.126.10.2'
    options: |
      default-lease-time 300;
      max-lease-time 7200;
      allow booting;
      allow bootp;
      filename "pxelinux.0";
      next-server 100.126.1.21;
    pools:
      - comment: "default ip pool for common services"
        range: '100.126.10.115 100.126.10.255'

thanks in advance

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.