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

[FEATURE] Permit to install files from salt fileserver instead of getting content in pillar #17

Closed
baby-gnu opened this issue Apr 20, 2020 · 2 comments · Fixed by #18
Closed

Comments

@baby-gnu
Copy link

Is your feature request related to a problem?

I need to tweak my exim configure to:

I need to:

  1. Create /etc/exim4/exim4.conf.localmacros with proper macro definitions
  2. Create /etc/exim4/passwd.client

Describe the solution you'd like

I think that the current handling of extra configuration files could be extended or modified to lookup files as template from the salt fileserver instead of the pillar.

As an example of what I'm thinking:

{%- set extra_files = salt['config.get']('exim:extra_files')
{%- if extra_files %}
{%-   for filename, params in extra_files.items() %}
{#-     Use filename as default source name %}
{%-     set sources = params.get('sources', [filename])
{%-     set user = params.get('user', 'root') %}
{%-     set group = params.get('group', 'root') %}
{%-     set mode = params.get('mode, '0644') %}
{%-     set template = params.get('template', None)
{%-     set tofs_lookup = 'exim/config/' ~ filename %}
{{ exim.config_dir }}/{{ filename }}:
  file.managed:
    - name: {{ exim.config_dir | path_join(filename) }}
	- source: {{ files_switch(sources, lookup=tofs_lookup) }}
	- user: {{ user }}
	- group: {{ group }}
	- mode: {{ mode }}
	- makedirs: True
{%      if template %}
	- template: jinja
	- context:
	    exim: {{ exim | json }}
{%- endif %}
	- require:
	  - sls: {{ sls_package_install }}
{%-   endfor %}
{%- endif %}

This way I could:

  1. Define a pillar like
    exim:
      extra_files:
        exim4.conf.localmacros:
          sources: ['exim4.conf.localmacros.jinja']
     	 template: 'jinja'
        passwd.client:
          sources: [passwd.client.jinja']
     	 user: 'root'
     	 group: 'Debian-exim'
     	 mode: '0640'
     	 template: 'jinja'
  2. Put the template files under /exim/files/default/ somewhere in the fileserver files_root.

NB: templating is parameterised because exim configuration file syntax can be seen interpreted as bogus jinja.

Describe alternatives you've considered

I think I could use exim.use_split_config=True and overwrite files under /etc/exim4/conf.d/ but the exim syntax can stay in the way of templating.

Additional context

javierbertoli added a commit to netmanagers/exim-formula that referenced this issue May 7, 2020
* should fix saltstack-formulas#17
* restart exim service on config change
@myii myii closed this as completed in #18 May 8, 2020
myii pushed a commit that referenced this issue May 8, 2020
* should fix #17
* restart exim service on config change

Also:

* feat(service): reload service instead of restarting it
* fix(service): reorder watchers to match org defaults
saltstack-formulas-travis pushed a commit that referenced this issue May 8, 2020
# [0.7.0](v0.6.1...v0.7.0) (2020-05-08)

### Bug Fixes

* **libtofs:** “files_switch” mess up the variable exported by “map.jinja” [skip ci] ([c7cbd5c](c7cbd5c))
* **release.config.js:** use full commit hash in commit link [skip ci] ([8356de8](8356de8))

### Continuous Integration

* **gemfile:** restrict `train` gem version until upstream fix [skip ci] ([bdb1196](bdb1196))
* **gemfile.lock:** add to repo with updated `Gemfile` [skip ci] ([7e1a0c1](7e1a0c1))
* **kitchen:** avoid using bootstrap for `master` instances [skip ci] ([b40fa5f](b40fa5f))
* **kitchen:** use `debian-10-master-py3` instead of `develop` [skip ci] ([c9fa91a](c9fa91a))
* **kitchen:** use `develop` image until `master` is ready (`amazonlinux`) [skip ci] ([edca139](edca139))
* **kitchen+travis:** remove `master-py2-arch-base-latest` [skip ci] ([88b504b](88b504b))
* **kitchen+travis:** upgrade matrix after `2019.2.2` release [skip ci] ([ef89686](ef89686))
* **travis:** apply changes from build config validation [skip ci] ([00b5f30](00b5f30))
* **travis:** opt-in to `dpl v2` to complete build config validation [skip ci] ([bebca43](bebca43))
* **travis:** quote pathspecs used with `git ls-files` [skip ci] ([00fc26f](00fc26f))
* **travis:** run `shellcheck` during lint job [skip ci] ([c2f403b](c2f403b))
* **travis:** update `salt-lint` config for `v0.0.10` [skip ci] ([7cb4790](7cb4790))
* **travis:** use `major.minor` for `semantic-release` version [skip ci] ([29ab6b3](29ab6b3))
* **travis:** use build config validation (beta) [skip ci] ([5eb57e3](5eb57e3))
* **workflows/commitlint:** add to repo [skip ci] ([c07995c](c07995c))

### Documentation

* **contributing:** remove to use org-level file instead [skip ci] ([b0994c9](b0994c9))
* **readme:** update link to `CONTRIBUTING` [skip ci] ([96b07dd](96b07dd))

### Features

* **config:** allow to manage config files under CONFDIR ([fd6debd](fd6debd)), closes [#17](#17)

### Performance Improvements

* **travis:** improve `salt-lint` invocation [skip ci] ([b4a8f6a](b4a8f6a))
@saltstack-formulas-travis

🎉 This issue has been resolved in version 0.7.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@OrangeDog
Copy link

OrangeDog commented Jul 14, 2021

The title of this issue is completely different to its content...
Was the feature request in the title ever done?

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

Successfully merging a pull request may close this issue.

3 participants