RHCE作业---- ansible(一)

RHCE作业(一)

  • 1、以all主机组为目标执行id命令
  • 2、使用copy模块修改所有主机上的/etc/motd文件内容为welcome to ansible
  • 3、使用command模块查看/etc/motd文件的内容
  • 4、使用user模块创建用户xinxin,uid为2000
  • 5、使用yum模块安装httpd软件包并使用service模块启动该服务

1、以all主机组为目标执行id命令

[admin@master test1]$ ansible all -m command -a ‘id’

2、使用copy模块修改所有主机上的/etc/motd文件内容为welcome to ansible

[admin@master test1]$ ansible all -m copy -a ‘content=“welcome to ansible\n” dest=/etc/motd’

3、使用command模块查看/etc/motd文件的内容

[admin@master test1]$ ansible all -m command -a ‘cat /etc/motd’

4、使用user模块创建用户xinxin,uid为2000

[admin@master test1]$ ansible all -m user -a ‘name=xinxin uid=2000

5、使用yum模块安装httpd软件包并使用service模块启动该服务

[admin@master test1]$ ansible all -m yum -a ‘name=httpd’
[admin@master test1]$ ansible all -m service -a ‘name=httpd state=started’

你可能感兴趣的:(RHCE,bash,linux,centos)