官术网_书友最值得收藏!

Ensuring that FirewallD is present and enabled

As you can imagine, the first step is to ensure that FirewallD is installed:

- name: Ensure FirewallD is installed 
  yum: 
    name: firewalld 
    state: present 
  become: True

Since we want to be sure that we will not lose our SSH connection when we enable FirewallD, we will ensure that SSH traffic can always pass through it:

- name: Ensure SSH can pass the firewall 
  firewalld: 
    service: ssh 
    state: enabled 
    permanent: True 
    immediate: True 
  become: True

To do so, we have used the firewalld module. This module will take parameters that are very similar to the ones the firewall-cmd console would use. You will have to specify the service that is to be authorized to pass the firewall, whether you want this rule to apply immediately or not, and whether or not you want the rule to be permanent, so that after a reboot the rule will still be present.

You can specify the service name (such as ssh) using the service parameter, or you can specify the port (such as 22/tcp) using the port parameter.

Now that we have installed FirewallD and we are sure that our SSH connection will survive, we can enable it as we do any other service:

- name: Ensure FirewallD is running 
  service: 
    name: firewalld 
    state: started 
    enabled: True 
  become: True 
主站蜘蛛池模板: 绥宁县| 营山县| 和平县| 安顺市| 通化市| 微博| 若尔盖县| 宁国市| 呼和浩特市| 九台市| 玉环县| 祁连县| 招远市| 洪洞县| 张家界市| 鞍山市| 晋州市| 阳城县| 漯河市| 无锡市| 崇阳县| 司法| 阿克陶县| 尤溪县| 大丰市| 阳新县| 娱乐| 长岭县| 宜丰县| 鱼台县| 淮安市| 崇阳县| 霸州市| 鹿泉市| 宜昌市| 庄浪县| 徐州市| 丹棱县| 陆河县| 田阳县| 运城市|