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

Add ability to include completely raw files #146

Closed
hashworks opened this issue Aug 26, 2022 · 4 comments · Fixed by #147
Closed

Add ability to include completely raw files #146

hashworks opened this issue Aug 26, 2022 · 4 comments · Fixed by #147

Comments

@hashworks
Copy link
Member

I have a list of files I need to include without any header or footer, which currently isn't possible. According to the README one should use nftables::config for that which Manages a raw file in /etc/nftables/puppet/${name}.nft, but that always surrounds the provided source or content with stuff.

Currently, I have to create the files manually, which isn't clean at all:

  file { '/etc/nftables/puppet/custom-include-geoipsets.nft':
    ensure  => 'present',
    mode    => '0640',
    content => @(EOT),
    # THIS FILE IS MANAGED BY PUPPET

    include "/var/local/geoipsets/dbip/nftset/ipv4/*.ipv4"
    include "/var/local/geoipsets/dbip/nftset/ipv6/*.ipv6"
    |EOT
  }

  file { '/etc/nftables/puppet-preflight/custom-include-geoipsets.nft':
    ensure => 'link',
    target => '/etc/nftables/puppet/custom-include-geoipsets.nft',
  }

Am I missing something here?

There should be an ability to A) provide a list of external *.nft files to include or B) a flag for nfttables::config to use the content as-is.

@hashworks hashworks changed the title Add ability to include completly raw files Add ability to include completely raw files Aug 26, 2022
@traylenator
Copy link
Collaborator

Do you have the nftables::config resource you tried.

I don't use this but I would have thought it was.

nftables::config{'inet-filter':
    content => @(EOT),
    # THIS FILE IS MANAGED BY PUPPET

    include "/var/local/geoipsets/dbip/nftset/ipv4/*.ipv4"
    include "/var/local/geoipsets/dbip/nftset/ipv6/*.ipv6"
    |EOT,
}

presumably those dbip files are generated from something else and the sets in there will be added to inet-filter table.

@traylenator
Copy link
Collaborator

Wrong:

nftables::config{'geoip-sets':
    content => @(EOT),
    # THIS FILE IS MANAGED BY PUPPET

    include "/var/local/geoipsets/dbip/nftset/ipv4/*.ipv4"
    include "/var/local/geoipsets/dbip/nftset/ipv6/*.ipv6"
    |EOT,
}

Though I confess I am bit confused why the title has to xyz-abc

@hashworks
Copy link
Member Author

This won't work, since it will always surround it with a table:

table geoip sets {
# THIS FILE IS MANAGED BY PUPPET

include "/var/local/geoipsets/dbip/nftset/ipv4/*.ipv4"
include "/var/local/geoipsets/dbip/nftset/ipv6/*.ipv6"
}

@traylenator
Copy link
Collaborator

So we need a new type nftables::file that does the the whole pre-flight thing.

traylenator added a commit to traylenator/puppet-nftables that referenced this issue Sep 1, 2022
For example:

```puppet
nftables::file{'geoip':
  content => "include \"/files/geoipsets/dbip/*.ipv4\"\n",
}
```

will right a file or content into the nftables configuration.

The file written will be included in configuration.

Fixes voxpupuli#146
traylenator added a commit to traylenator/puppet-nftables that referenced this issue Sep 1, 2022
For example:

```puppet
nftables::file{'geoip':
  content => "include \"/files/geoipsets/dbip/*.ipv4\"\n",
}
```

will right a file or content into the nftables configuration.

The file written will be included in configuration.

Fixes voxpupuli#146
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

Successfully merging a pull request may close this issue.

2 participants