04 ansible其他常见模块(yum模块、service模块、mount模块、cron模块、user模块、group模块)...

 

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

 

转载于:https://www.cnblogs.com/linux985/p/11308429.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值