linux主机性能变差
1、top htop 查看cup负载情况
2、free -h 查看内存负载情况
3. iotop 查看磁盘负载情况
ansible服务部署安装
a.安装服务软件
b.编写主机清单
c.进行管理测试
ansible服务特点说明
01.管理端不需要启动服务程序(no server)
02.管理端不需要编写配置文件(/etc/ansible/ansible.cfg)
03.受控端不需要安装软件程序
受控端selinux服务没有关闭---影响ansible软件的管理
libselinux-python让selinux开启的状态也可以使用ansible程序
04.受控端不需要启动服务程序(no agent)
05.服务程序管理操作模块众多(module)
06.利用剧本编写来实现自动化(playbook)
user模块与group模块
user模块是请求的是useradd, userdel, usermod三个指令,goup模块请求的是groupadd, groupdel, groupmod 三个指令。
1、user模块
-
home:指定用户的家目录,需要与createhome配合使用
-
groups:指定用户的属组
-
uid:指定用的uid
-
password:指定用户的密码
-
name:指定用户名
-
createhome:是否创建家目录 yes|no
-
system:是否为系统用户
-
remove:当state=absent时,remove=yes则表示连同家目录一起删除,等价于userdel -r
-
state:是创建还是删除
-
shell:指定用户的shell环境
gota@gota-linux61:~$ ansible all -i localhost, -m debug -a "msg={{ 'Gota1234' | password_hash('sha512','oldyboy')}}" localhost | SUCCESS => { "msg": "$6$oldyboy$tKcigo1KPPzN.Yh8fij5PLc6o6CzqXQBNHOfq38SgPefqVqfjkahHevDeaKCtK/BJ4WbIJnZmGy.NLIROMV7f1" }
gota@gota-linux61:~$ ansible 192.168.1.62 -m user -a 'name=gota01 password=$6$oldyboy$tKcigo1KPPzN.Yh8fij5PLc6o6CzqXQBNHOfq38SgPefqVqfjkahHevDeaKCtK/BJ4WbIJnZmGy.NLIROMV7f1' 192.168.1.62 | CHANGED => { "ansible_facts": { "discovered_interpreter_python": "/usr/bin/python" }, "changed": true, "comment": "", "create_home": true, "group": 1004, "home": "/home/gota01", "name": "gota01", "password": "NOT_LOGGING_PASSWORD", "shell": "", "state": "present", "system": false, "uid": 1004 }
gota@gota-linux61:~$ python -c "from passlib.hash import sha512_crypt; import getpass; print(sha512_crypt.using(rounds=5000).hash(getpass.getpass()))" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named passlib.hash