8. 如果托管主机agentX的/opt/db.info文件内容里有mariadb,则安装mariadb和mariadb-server;如果没有/opt/db.info或其中没有mariadb,则什么也不做。
9-1 编写剧本,在webservers组上安装httpd服务,启动相应服务。
(1) 打开网页http://192.BJ.XH.101页面后,应显示“Welcome, This is XH-NAME’s homepage!, The host is agentX”(定义在参数和模板中,XH-NAME为个人定制)。
(2) 修改 /etc/httpd/conf/httpd.conf ,使用 replace 模块搜索所有 AllowOverride None 内容并替换为 AllowOverride AuthConfig
- name: install httpd
hosts: webservers
gather_facts: no
tasks:
- name: install
yum:
name: httpd
state: present
- name: start
service:
name: httpd
state: started
enabled: yes
- name: 3
shell: echo "Welcome, This is XH-NAME's homepage!, The host is agentX" > /var/www/html/index.html
- name: 4
replace:
path: /etc/httpd/conf/httpd.conf
regexp: '^AllowOverride None'
replace: 'AllowOverride AuthConfig'
9-2 编写剧本,在webservers组上安装httpd服务,启动相应服务。
(1) 打开网页http://192.BJ.XH.101页面后,应显示“Hello, This is XH-NAME’s homepage!, The host IP is 192.BJ.XH.10X”(定义在参数和模板中,XH-NAME为个人定制)。
(2) 修改 /etc/httpd/conf/httpd.conf ,使用 replace 模块搜索所有 AllowOverride None 内容并替换为 AllowOverride All。
10. 在 workstation 上创建名为/ansible/playbooks/safty.yml,
实现远程关闭agent1和agent2防火墙和selinux,并分别实现重启后保持生效。
- name: stop selinux
hosts: webservers
tasks:
- name: stop firewalld
service:
name: firewalld
state: stopped
enabled: no
- name: selinux disable
replace:
path: /etc/selinux/config
regexp: '^SELINUX=enforcing'
replace: 'SELINUX=disabled'
- name: setenforce 0
shell: " setenforce 0 "
转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论