Allow "multiple state declarations of the same type" when function is different
It would be great if one could do the following:
apache_sites:
apache_site.enabled:
- names:
- my-server
- your-server
apache_site.disabled:
- names:
- 000-default
Right now, we circumvent the error by introducting another state such as:
apache_sites_enabled:
apache_site.enabled:
- names:
- my-server
- your-server
apache_sites_disabled:
apache_site.disabled:
- names:
- 000-default
@srkunze I believe this is a duplicate of #29142 . If you agree please feel free to close this issue and comment on #29142 and we will track this feature request there. Thanks
@Ch3LL I looked that issue up already but it's not 100% the same I think.
They need 2x "apache_site.enabled". I need "apache_site.enabled" + "apache_site.disabled" which is different.
So, I let you the choice to close the issue if you think the internal implementation would be the same. :)
Thanks for clarifying . Will add this as a feature request instead of treating as a duplciate thanks.
Glad to see that this is already in the queue. Just wanted to add another (probably more common) example ... file.managed and file.symlink
I ran into this exact issue today, with the following use case: locale.present and locale.system
same here trying to do:
diamond:
file.directory:
.....
file.managed:
....
kafka-config-dir:
file.absent:
- name: /not/useful/dir
file.directory:
- name: /some/useful/dir
Ran into this as well using:
lvm.pv_present:
- name: /dev/xvdd
lvm.vg_present:
- name: vol_grp1
lvm.lv_present:
- name: logical_vol1
I'd like this feature as well
/etc/ssh/sshd_config:
file.uncomment:
- regex: '.*AuthorizedKeysFile.*'
file.replace:
- pattern: '(.*LoginGraceTime.*)'
- repl: 'LoginGraceTime 120'
- show_changes: true
Another use case:
Configure network time service:
pkg.purged:
- pkgs:
- ntp
- ntp-doc
- ntpdate
pkg.installed:
- name: chrony
One of the most 'in your face' features that should be added...but I'm guessing backwards compatibility limits this.
And another, possibly quite common use case!
edit some file two ways when needed:
file.replace:
- name: '/some/file/path'
- pattern: 'replace_me'
- repl: 'better_string'
file.line:
- name: '/same/file/path'
- match: 'delete_this_string'
- mode: delete
I would have liked to setup passwordless ssh keys to a repo host (without using 'id-rsa' for the keyfile) in one state
ssh_repo_passwordless:
file.copy:
- name: /root/.ssh/your_repo_rsa_priv
- source: salt://sshkeys/your_repo_rsa_priv
- user: root
- group: root
- mode: 0600
file.append:
- name: /root/.ssh/config
- text: |
Host your_repo your_repoIP
HostName your_repoIP
User repo_user
IdentityFile /root/.ssh/your_repo_rsa_priv
additional case:
the alternatives system: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.alternatives.html
openjdk.set.java:
alternatives.install:
- name: java
- link: /usr/bin/java
- path: /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java
- priority: 5
- require:
- pkg: openjdk.install
alternatives.set:
- name: java
- path: /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/java
👍
Another use case:
/home/{{ user }}/.ssh/config:
file.managed:
- user: {{ user }}
- mode: '0644'
- makedirs: True
- dir_mode: '0766'
- source:
file.append:
- name: /home/{{ user }}/.ssh/config
- text:
- "Host: git.example.org"
- " IdentityFile /etc/salt/rsa.id"
file.append would create file with the wrong permission (aka root) if the files doesn't exist and you can't define that info. So you must run an empty manage that will create an empty file if absent with the proper permissions, then append logically follow.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.
not stale
Thank you for updating this issue. It is no longer marked as stale.
👍