saltstack 初始化LINUX系统
前面我们已经了解了saltstack的基础功能,现在就可以使用saltstack为初始化新安装的linux系统。
初始化列表:
1.关闭selinux
3.修改sshd配置文件
4.内核优化
5.ulimit修改
6.history记录
7.时区修改及添加cron
8.安装epel
9.修改resolv解析文件
10.软件安装
好了,此前我们已经修改了salt的base目录,默认在/srv/salt 下我们调整到/etc/salt目录下了
现在呢,我们需要去建立一个目录专门用于存放初始化sls的。
[root@localhost base]# pwd
/etc/salt/base
[root@localhost base]# mkdir init
date_time.sls
系统时区修改
[root@localhost init]# vim date_time.sls
date_time:
pkg.installed:
- name: ntpdate
- unless: rpm -qa | grep ntpdate
cmd.run:
- name: rm -rf /etc/localtime && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && ntpdate pool.ntp.org
- require:
- pkg: ntpdate
cron.present:
- name: /usr/sbin/ntpdate pool.ntp.org >/dev/null
- user: root
- minute: '*/5'
- require:
- pkg: ntpdate
epel.sls
epel文件调整,系统为centos 7
[root@localhost init]#vim epel.sls
epel_install:
pkg.installed:
- sources:
- epel-release: http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
- unless: rpm -qa | grep epel-release-7-5
history.sls
修改操作命令记录
[root@localhost init]# vim history.sls
/etc/bashrc:
file.append:
- text:
- HISTTIMEFORMAT="%F %T `whoami` "
cmd.run:
- name: source /etc/bashrc
limits.sls
limits参数调整
[root@localhost init]# vim limits.sls
/etc/security/limits.conf:
file.append:
- text:
- '* hard nofile 204800'
- '* soft nofile 204800'
/etc/profile:
file.append:
- text:
- 'ulimit -c unlimited'
~/.bashrc:
file.append:
- text:
- alias vi='"'vim'"'
resolv.sls
DNS解析文件修改
[root@localhost init]#vim resolv.sls
resolv:
file.managed:
- name: /etc/resolv.conf
- source: salt://init/resolv.conf
[root@localhost init]# vim resolv.conf
# Generated by NetworkManager
nameserver 114.114.114.114
nameserver 8.8.8.8
[root@localhost init]#
selinux.sls
selinux卸载
[root@localhost init]# vim selinux.sls
selinux:
cmd.run:
- name: yum remove selinux-policy -y
soft_install.sls
基础软件安装
[root@localhost init]# vim soft_install.sls
soft-install:
pkg.installed:
- names:
- lrzsz
- telnet
- openssh-clients
- ftp
- sysstat
- bc
- rsync
- wget
- screen
- dstat
- vim-enhanced
- gcc
- gcc-c++
- make
- dos2unix
- net-tools
[root@localhost init]#
sshd_config.sls
SSHD配置文件调整
[root@localhost init]# vim sshd_config.sls
sshd:
file.managed:
- name: /etc/ssh/sshd_config
- source: salt://init/sshd_config
service.running:
- enable: True
- reload: True
- watch:
- file: /etc/ssh/sshd_config
[root@localhost init]# vim sshd_config
Port 22
Protocol 2
SyslogFacility AUTHPRIV
PasswordAuthentication yes
PermitEmptyPasswords no
ChallengeResponseAuthentication yes
Compression yes
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
X11Forwarding yes
UsePAM yes
UseDNS no
Subsystem sftp /usr/libexec/openssh/sftp-server
LogLevel DEBUG
#allowusers root@192.168.140.129
#allowusers root@192.168.140.1
sysctl.sls
内核参数调整
[root@localhost init]# vim sysctl.sls
net.ipv4.conf.default.rp_filter:
sysctl.present:
- value: 1
net.ipv4.conf.default.accept_source_route:
sysctl.present:
- value: 0
kernel.sysrq:
sysctl.present:
- value: 0
kernel.core_uses_pid:
sysctl.present:
- value: 1
kernel.msgmnb:
sysctl.present:
- value: 65536
kernel.msgmax:
sysctl.present:
- value: 65536
kernel.shmmax:
sysctl.present:
- value: 68719476736
kernel.shmall:
sysctl.present:
- value: 4294967296
kernel.shmmni:
sysctl.present:
- value: 4096
kern.maxfiles:
sysctl.present:
- value: 65536
net.ipv4.tcp_fin_timeout:
sysctl.present:
- value: 30
net.ipv4.tcp_keepalive_time:
sysctl.present:
- value: 1200
net.ipv4.tcp_window_scaling:
sysctl.present:
- value: 1
net.ipv4.tcp_sack:
sysctl.present:
- value: 1
net.ipv4.tcp_syncookies:
sysctl.present:
- value: 1
net.ipv4.tcp_tw_reuse:
sysctl.present:
- value: 1
net.ipv4.tcp_tw_recycle:
sysctl.present:
- value: 1
net.ipv4.ip_local_port_range:
sysctl.present:
- value: 1024 65000
net.ipv4.tcp_max_tw_buckets:
sysctl.present:
- value: 6000
net.ipv4.tcp_max_syn_backlog:
sysctl.present:
- value: 65535
net.core.netdev_max_backlog:
sysctl.present:
- value: 262144
net.core.wmem_default:
sysctl.present:
- value: 8388608
net.core.rmem_default:
sysctl.present:
- value: 8388608
net.core.rmem_max:
sysctl.present:
- value: 16777216
net.core.wmem_max:
sysctl.present:
- value: 16777216
net.ipv4.tcp_timestamps:
sysctl.present:
- value: 0
net.ipv4.tcp_synack_retries:
sysctl.present:
- value: 2
net.ipv4.tcp_syn_retries:
sysctl.present:
- value: 2
net.ipv4.tcp_mem:
sysctl.present:
- value: 94500000 915000000 927000000
net.ipv4.tcp_max_orphans:
sysctl.present:
- value: 3276800
[root@localhost init]#
建立入口文件及管理文件
[root@localhost base]# pwd
/etc/salt/base
[root@localhost base]# ls
init system_init.sls top.sls
[root@localhost base]# vim system_init.sls
include:
- init.selinux
- init.epel
- init.date_time
- init.soft_install
- init.history
- init.limits
- init.sysctl
- init.sshd_config
- init.resolv
[root@localhost base]# vim top.sls
base:
'*':
- system_init
[root@localhost base]#
执行命令
[root@localhost base]# salt '*' state.highstate test=True 执行前先测试
[root@localhost base]# salt '*' state.highstate
saltstack 初始化LINUX系统的更多相关文章
- 浅析 Linux 初始化 init 系统
近年来,Linux 系统的 init 进程经历了两次重大的演进,传统的 sysvinit 已经逐渐淡出历史舞台,新的 UpStart 和 systemd 各有特点,越来越多的 Linux 发行版采纳了 ...
- 【转】Linux 初始化 init 系统 [sysvinit systemd upstart]
http://www.ibm.com/developerworks/cn/views/linux/libraryview.jsp?sort_by=&show_abstract=true& ...
- Linux系统之压缩、解压缩,vi编辑器,系统初始化服务和系统监控
一.正文处理,压缩与解压缩 1.内容重定向>与>> >:覆盖,将>号左边的结果覆盖到>号右边的文件中,如果文件不存在,则先创建一个新的空文件并覆盖 >> ...
- 详解linux系统的启动过程及系统初始化
一.linux系统的启动流程 关于linux系统的启动流程我们可以按步进行划分为如下: POST加电自检 -->BIOS(Boot Sequence)-->加载对应引导上的MBR(boot ...
- 浅析 Linux 初始化 init 系统,第 1 部分: sysvinit 第 2 部分: UpStart 第 3 部分: Systemd
浅析 Linux 初始化 init 系统,第 1 部分: sysvinit 第 2 部分: UpStart 第 3 部分: Systemd http://www.ibm.com/developerw ...
- Linux系统初始化过程及运行级别简介
Linux开机过程: 1 开机自检(BIOS):初始化硬件,查找启动介质 2 MBR引导 3 GRUB引导菜单:GRUB程序安装在Bootloader 4 加载内核(kernel) 5 运行INIT进 ...
- 浅析 Linux 初始化 init 系统,Systemd
原文地址:http://www.ibm.com/developerworks/cn/linux/1407_liuming_init3/ Systemd 的简介和特点 Systemd 是 Linux 系 ...
- 温故之--Linux 初始化 init 系统
参选URL: http://www.ibm.com/developerworks/cn/linux/1407_liuming_init1/index.html 本系列一共三篇,看完记住,那水平就不一样 ...
- KALI LINUX系统初始化配置
1.Kali Linux安装VirtualBox增强功能 VirtualBox增强功能介绍:物理机与虚拟机之间的文件共享.物理机与虚拟机之间的剪切板共享.虚拟机的direct3D支持,这样虚拟机窗口就 ...
随机推荐
- springboot @scheduled 并发
本文介绍如何使用springboot的sheduled实现任务的定时调度,并将调度的任务实现为并发的方式. 1.定时调度配置scheduled 1)注册定时任务 package com.xiaoju. ...
- 用命令生成Webservice 对应的代理类
wsdl /language:C# /namespace:Camstar.WebPortal.WebPortlets.Shopfloor.SAP.GreatWall /out:gwSAPService ...
- Aspose.word
http://my.oschina.net/dancefires/blog/217858
- 396. Rotate Function 移动加权求和,取最大值
[抄题]: Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by ...
- ubuntu中的环境变量
写这句话,给自己提个醒吧,添加路径(所谓的环境变量):系统会去相应的目录中找可执行文件,到时候只要输入命令名字,可以不用输入完整的路径
- 利用springloaded进行java jar&class的动态替换
之前已经写过一篇关于class的动态替换博客,今天我们来介绍一下如何用springloaded进行jar&class的动态替换. 首先说一下实验过程,结合了目前我正在做的项目,这个项目是一个前 ...
- downLoad
String root= ServletActionContext.getServletContext().getRealPath(File.separator).replace("\\&q ...
- atom编辑器使用“apm install”无法响应的解决方案
工具:shadowsocks 利用ss建立代理服务,之后apm --help,得到apm的配置命令: apm - Atom Package Manager powered by https://ato ...
- JS基础-数组的常用方法-冒泡排序
1.数组 1.关联数组 以数字作为元素下标的数组,就是索引数组. 以字符串作为元素下标的数组,就是关联数组. 2.js的关联数组 ex:在php中 $array=[& ...
- # 2019-2020-3 《Java 程序设计》第三周总结
2019-2020-3 <Java 程序设计>第三周知识总结 1.类的定义 语法格式如下(加[]表示可选项): [修饰符] class 类名 { 属性定义(声明) 方法定义(声明)} 2. ...