1.编写salt配置文件

[root@master state]# tree
├── sysctl
└── init.sls

[root@master sysctl]# cat init.sls
net.ipv4.ip_forward:
sysctl.present:
- name: net.ipv4.ip_forward
- value: 0
net.ipv4.tcp_syn_retries:
sysctl.present:
- name: net.ipv4.tcp_syn_retries
- value: 1
net.ipv4.tcp_tw_recycle:
sysctl.present:
- name: net.ipv4.tcp_tw_recycle
- value: 1
net.ipv4.tcp_tw_reuse:
sysctl.present:
- name: net.ipv4.tcp_tw_reuse
- value: 1

2.执行命令推送



[root@master sysctl]# salt minion02 state.sls state.sysctl
minion02:
----------
ID: net.ipv4.ip_forward
Function: sysctl.present
Result: True
Comment: Updated sysctl value net.ipv4.ip_forward = 0
Started: 08:05:48.749903
Duration: 55.633 ms
Changes:
----------
net.ipv4.ip_forward:
0
----------
ID: net.ipv4.tcp_syn_retries
Function: sysctl.present
Result: True
Comment: Updated sysctl value net.ipv4.tcp_syn_retries = 1
Started: 08:05:48.806563
Duration: 30.301 ms
Changes:
----------
net.ipv4.tcp_syn_retries:
1
----------
ID: net.ipv4.tcp_tw_recycle
Function: sysctl.present
Result: True
Comment: Updated sysctl value net.ipv4.tcp_tw_recycle = 1
Started: 08:05:48.837344
Duration: 15.974 ms
Changes:
----------
net.ipv4.tcp_tw_recycle:
1
----------
ID: net.ipv4.tcp_tw_reuse
Function: sysctl.present
Result: True
Comment: Updated sysctl value net.ipv4.tcp_tw_reuse = 1
Started: 08:05:48.854493
Duration: 24.37 ms
Changes:
----------
net.ipv4.tcp_tw_reuse:
1

Summary for minion02
------------
Succeeded: 4 (changed=4)
Failed: 0
------------
Total states run: 4
Total run time: 126.278 ms

3.在minion02端查看



[root@minion02 ~]# cat /etc/sysctl.d/99-salt.conf 
#
# Kernel sysctl configuration
#
net.ipv4.ip_forward = 0
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1

版权声明:本文为博主原创文章,未经博主允许不得转载。

LINUX