10.ansible模块补充

  • 使用firewalld模块可以配置防火墙策略
[root@db04 ansible]# cat firewalld.yml 
---
- host: db01
  tasks:
    - name: install firewalld
      yum:  
        name: firewalld
        state:  present
    - name: run firewalld
      service:
        name: firewalld
        state:  started
        enabled:  yes
    - name: set firewalld rule.
      firewalld:
        port: 80/tcp
        permanent:  yes
        state:  enabled
[root@db04 ansible]# 
  • template模块(它也有拷贝功能)
[root@db04 ansible]# cat template.yml 
---
- hosts:  db01
  tasks:
    - name: use template copy index.html to webserver.
      template:
        src:  ~/ansible/template/index.html
        dest: /var/www/html/index.html
[root@db04 template]# pwd
/root/ansible/template
[root@db04 template]# cat index.html 
welcome to {{ansible_hostname}}

 

posted on 2023-05-17 23:26  太白金星有点烦  阅读(36)  评论(0)    收藏  举报

导航