RHCE考题

flectrag
第一题

[root@control ~]# yum -y install ansible
[root@control ~]# su - greg 
Last login: Sun Nov 13 15:47:44 CST 2022 on pts/1
[greg@control ~]$ mkdir ansible
[greg@control ~]$ cd ansible/
[greg@control ansible]$ ls
[greg@control ansible]$ cp /etc/ansible/ansible.cfg .
[greg@control ansible]$ ls
ansible.cfg
[greg@control ansible]$ vim inventory
[dev]
node1

[test]
node2

[prod]
node3
node4

[blancers]
node5

[webservers:children]
prod
[greg@control ansible]$ vim ansible.cfg
[defaults]
inventory = /home/greg/ansible/inventory
remote_user = greg
roles_path = /home/greg/ansible/roles 
host_key_checking = false
[privilege_escalation]
become = true
become_method = sudo
become_user = root
become_ask_pass = false
[greg@control ansible]$ mkdir roles
[greg@control ansible]$ ls
ansible.cfg  inventory  roles
[greg@control ansible]$ ansible all -m ping

第二题
在这里插入图片描述

[greg@control ansible]$ cat adhoc.sh 
#!/bin/bash
ansible all -m yum_repository -a "name=EX294_BASE description='EX294 base software' file=rhel_dvd baseurl=http://content/rhel8.0/x86_64/dvd/BaseOS gpgcheck=yes gpgkey=http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release enabled=yes"

ansible all -m yum_repository -a "name=EX294_STREAM description='EX294 stream software' file=rhel_dvd baseurl=http://content/rhel8.0/x86_64/dvd/AppStream gpgcheck=yes gpgkey=http://content/rhel8.0/x86_64/dvd/RPM-GPG-KEY-redhat-release enabled=yes"
[greg@control ansible]$ chmod +x adhoc.sh 
[greg@control ansible]$ ./adhoc.sh 

第三题
在这里插入图片描述

[greg@control ansible]$ vim packages.yml
---
- name: install 
  hosts: dev,test,prod
  tasks:
    - name: install mariadb php
      yum:
        name:
          - php
          - mariadb
        state: present

- name: install group pkgs
  hosts: dev
  tasks:
    - name: install Development Tools
      yum:
        name: "@RPM Development Tools"
        state: present
   - name: update all pkgs
     yum:
       name: '*'
       state: latest
[greg@control ansible]$ ansible-playbook packages.yml  

第四题
在这里插入图片描述

[greg@control ansible]$ cp -r /usr/share/ansible/roles/rhel-system-roles.timesync/ /home/greg/ansible/roles/timesync
[greg@control ansible]$ ls
adhoc.sh  ansible.cfg  inventory  packages.yml  roles
[greg@control ansible]$ vim timesync.yml
[greg@control ansible]$ cat timesync.yml
---
- name: set time sync
  hosts: all
  vars:
    timesync_ntp_servers:
      - hostname: 172.25.254.254
        iburst: yes
  roles:
    - timesync

使用selinux角色
配置该角色,开启所有受控节点的selinux

[greg@control ansible]$ cp -r /usr/share/ansible/roles/rhel-system

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值