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 request: ini.managed all-in-one state #55603

Open
oeuftete opened this issue Dec 11, 2019 · 1 comment
Open

Feature request: ini.managed all-in-one state #55603

oeuftete opened this issue Dec 11, 2019 · 1 comment
Labels
Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Feature new functionality including changes to functionality and code refactors, etc. ZD The issue is related to a Zendesk customer support ticket.
Milestone

Comments

@oeuftete
Copy link
Contributor

oeuftete commented Dec 11, 2019

Description of Issue

(ref. ZD-4366)

To simplify the maintenance and change reporting of ini file management states, especially when building an ini from a standard starting point, it would be useful to have an all-in-one state, perhaps ini.managed.

Here's how it might look.

all_in_one_ini_state:
  ini.managed:
    - name: target.ini
    - source: salt://vanilla.ini
    - options:
        present:
          test:
            testkey: 'testval'
        absent:
          test:
            - badkey
    - sections:
        present:
          - good_empty_section
        absent:
          - bad_section

That state would get the source file, perform the various options and sections modifications to it as in the standalone ini states, and only if that result differs from target.ini would the state return with changes.

The current workaround looks a bit like:

{% set SALT_REFERENCE = 'salt://vanilla.ini' %}
{% set LOCAL_REFERENCE = 'local_reference.ini' %}
{% set LOCAL_TMP = '/tmp/tmp.ini' %}
{% set LOCAL_FINAL = 'target.ini' %}

get_ini_from_source_if_changed:
  file.managed:
    - name: {{ LOCAL_REFERENCE }}
    - source: {{ SALT_REFERENCE }}

rebuild_ini_if_reference_changed:
  file.managed:
    - name: {{ LOCAL_TMP }}
    - source: {{ SALT_REFERENCE }}
    - onchanges:
      - file: get_ini_from_source_if_changed

apply_ini_modifications:
  ini.options_present:
    - name: {{ LOCAL_TMP }}
    - sections:
        test:
          testkey: 'testval'

{# ... more ini states possibly ... #}

copy_tmp_ini_to_target:
  file.managed:
    - name: {{ LOCAL_FINAL }}
    - source: {{ LOCAL_TMP }}
@oeuftete oeuftete added Feature new functionality including changes to functionality and code refactors, etc. ZD The issue is related to a Zendesk customer support ticket. labels Dec 11, 2019
@flassman
Copy link

The proposed feature would be exactly what I need. The workaround has the drawback that if I remove one of the ini modifications from the state and run again, change is not reflected in the target until the source changes and the target is recreated.

@waynew waynew added this to Needs triage in [Test] Triage Dec 12, 2019
@waynew waynew added Confirmed Salt engineer has confirmed bug/feature - often including a MCVE and removed needs-triage labels Jan 7, 2020
@waynew waynew removed their assignment Jan 7, 2020
@waynew waynew moved this from Needs triage to Low priority in [Test] Triage Jan 7, 2020
@Ch3LL Ch3LL added this to the Approved milestone Jan 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Confirmed Salt engineer has confirmed bug/feature - often including a MCVE Feature new functionality including changes to functionality and code refactors, etc. ZD The issue is related to a Zendesk customer support ticket.
Projects
No open projects
[Test] Triage
  
Low priority
Development

No branches or pull requests

5 participants