can sysctl.present have multiple items?

已查看 493 次
跳至第一个未读帖子

Yong Zhang

未读,
2017年6月22日 07:59:292017/6/22
收件人 Salt-users
Hi,

I want to use state sysctl.present to config some sysctl settings, is it possible to define multiple items like below (I tested with below state but doesn't work, just want to know how to define multiple items within one sysctl.present)?


sysctlsettings:
  sysctl.present:
    - name: net.ipv4.tcp_tw_reuse
      value: 1
    - name: net.ipv4.ip_local_port_range
      value: 10240    65535
    - name: kernel.sysrq
      value: 1
    - name: net.ipv6.conf.all.disable_ipv6
      value: 1
    - name: net.ipv6.conf.default.disable_ipv6
      value: 1
    - name: net.core.somaxconn
      value: 262144

Viet Hung Nguyen

未读,
2017年6月22日 12:38:092017/6/22
收件人 Salt-users
No, it is not possible doing exactly what you showed.

The code here says that you can set only 1 item with each sysctl.present https://github.com/saltstack/salt/blob/develop/salt/states/sysctl.py#L30

But you can get the same effect by using a Jinja2 loop over all item, so, create different states
This is an example of doing so  https://github.com/hvnsweeting/states/blob/master/sysctl/init.sls

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/fdfb2159-4a4d-40d4-8c52-342825df3d94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Thanks & Best regards,
Nguyen Viet Hung (Mr)
[a.k.a HVN]

Mobile: 0982090290

Thomas Phipps

未读,
2017年6月22日 15:00:032017/6/22
收件人 Salt-users
actually you can. although getting that many different values together kind of looks ugly to me.

sysctlsettings_true:
  sysctl.present:
    - value: 1
    - names:
      - net.ipv4.tcp_tw_reuse
      - kernel.sysreq
      - net.ipv6.conf.all.disable_ipv6
      - net.ipv6.conf.default.disable_ipv6
      - net.ipv4.ip_local_port_range
        - value: 10240 65535
      - net.core.somaxconn
        - value: 262144






On Thu, Jun 22, 2017 at 9:38 AM Viet Hung Nguyen <h...@familug.org> wrote:
No, it is not possible doing exactly what you showed.

The code here says that you can set only 1 item with each sysctl.present https://github.com/saltstack/salt/blob/develop/salt/states/sysctl.py#L30

But you can get the same effect by using a Jinja2 loop over all item, so, create different states
This is an example of doing so  https://github.com/hvnsweeting/states/blob/master/sysctl/init.sls
On Thu, Jun 22, 2017 at 6:59 PM, Yong Zhang <hisca...@gmail.com> wrote:
Hi,

I want to use state sysctl.present to config some sysctl settings, is it possible to define multiple items like below (I tested with below state but doesn't work, just want to know how to define multiple items within one sysctl.present)?


sysctlsettings:
  sysctl.present:
    - name: net.ipv4.tcp_tw_reuse
      value: 1
    - name: net.ipv4.ip_local_port_range
      value: 10240    65535
    - name: kernel.sysrq
      value: 1
    - name: net.ipv6.conf.all.disable_ipv6
      value: 1
    - name: net.ipv6.conf.default.disable_ipv6
      value: 1
    - name: net.core.somaxconn
      value: 262144

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
--
Thanks & Best regards,
Nguyen Viet Hung (Mr)
[a.k.a HVN]

Mobile: 0982090290

--
You received this message because you are subscribed to the Google Groups "Salt-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to salt-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/salt-users/CAJm7hK%2B%2BKhRQmmy95w5ZTuxpMtKhprp-i3bms2OKdZH5WSVm-A%40mail.gmail.com.

Daniel Wallace

未读,
2017年6月23日 09:34:522017/6/23
收件人 Salt-users
Need some colons after somaxconn, and the other ones that have an extra value, but this is how I would do it.
回复全部
回复作者
转发
0 个新帖子