6.2 System初始化
最后更新于:2022-04-02 07:45:24
### Centos 7 初始化
```shell
# 第一次部署
ansible-playbook -i hosts/system_hosts system_init/centos7/centos7.yml --skip-tags clean_op_tags
```
## 调整配置后再次部署
如果优化后,调整了配置,想再次进行优化,需要修改task下的C7_Clean_Optimiz_Tags.yml文件,注释不优化的部分
假如想重新同步sysct.conf,注释其他即可
```
---
- name: clean optimization tags
lineinfile:
path: "{{ op_tag }}"
state: absent
regexp: '.system_init'
loop:
# - /etc/yum.repos.d/CentOS-Base.repo
# - /etc/yum.repos.d/epel.repo
# - /etc/locale.conf
# - /etc/security/limits.d/20-nproc.conf
# - /etc/limits.conf
# - /etc/ssh/sshd_config
- /etc/sysctl.conf
# - /etc/profile.d/ps.sh
# - /root/.vimrc
# - /etc/fail2ban/jail.conf
# - /var/spool/cron/root
# - /etc/rc.d/rc.local
loop_control:
loop_var: op_tag
tags:
clean_op_tags
```
简单说就是清理掉之前优化后的tag,让程序判断再次优化
```
ansible-playbook -i hosts/system_hosts system_init/centos7/centos7.yml
```
';