我有一个安装 nginx 的 ansible playbook。但是当我输入 ip 地址时,我无法访问服务器。服务运行良好。
---
- name: Install nginx
hosts: nginx
become: true
tasks:
- name: Add epel-release repo
yum:
name: epel-release
state: present
- name: Install nginx
yum:
name: nginx
state: present
- name: Ansible copy file to remote server
copy:
src: /root/ansible/nginx.conf
dest: /etc/nginx
force: yes
- name: Start NGiNX
service:
name: nginx
state: started
enabled: yes
我该如何开发这个脚本来从 ip 地址访问?
sudo firewall-cmd --permanent --zone=public --add-service=http
sudo firewall-cmd --permanent --zone=public --add-service=https
sudo firewall-cmd --reload
我可以在剧本中使用上述命令吗?
答案1
我找到了这个问题的答案。
- firewalld:
service: https
permanent: yes
state: enabled
- firewalld:
zone: public
service: http
permanent: yes
state: enabled
- name: Bounce firewalld
service:
name: firewalld
state: restarted