Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hiera #330

Open
axelag opened this issue Sep 4, 2024 · 1 comment
Open

Hiera #330

axelag opened this issue Sep 4, 2024 · 1 comment

Comments

@axelag
Copy link

axelag commented Sep 4, 2024

Hello,
is there any way to create a network interface and routes with Hiera? I can't seem to do it, any examples?

@antaflos
Copy link

A wrapper profile like the following should work. Assuming you known of and follow the Roles & Profiles pattern that has been long established as a best practice in Puppet:

class profile::network {
  $if_defaults = lookup('profile::network::interface_defaults', Hash, 'deep', {})
  $interfaces = lookup('profile::network::interfaces', Hash, 'deep', {})

  $route_defaults = lookup('profile::network::route_defaults', Hash, 'deep', {})
  $routes = lookup('profile::network::routes', Hash, 'deep', {})

  create_resources('network_config', $interfaces, $if_defaults)
  create_resources('network_route',  $routes, $route_defaults)
}

You Puppet node should include 'profile::network', then in Hiera you can do something like this:

profile::network::interfaces:
  lo:
    ensure: present
    family: inet
    method: loopback
  enp5s0:
    ensure: present
    family: inet
    method: static
    address: 10.1.2.3/24
    options:
      gateway: 10.1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants