关于实战中nginx安装的问题
来源:5-5 Freestyle job实战 - Freestyle任务构建和自动化部署

MenHung
2019-01-08
老师,你好!
在实战案例中,你的playbook如下,我不是很理解,这里只是安装的nginx的yum源,并没有哪个步骤是安装nginx,后面又直接重启nginx服务了。不知道是不是我理解有问题,麻烦老师指教。
- name: Disable system firewall
service: name=firewalld state=stopped
- name: Disable SELINUX
selinux: state=disabled
- name: setup nginx yum source
yum: pkg=epel-release state=latest
- name: write then nginx config file
template: src=roles/nginx/templates/nginx.conf.j2 dest=/etc/nginx/nginx.conf
- name: create nginx root folder
file: 'path={{ root }} state=directory owner={{ user }} group={{ user }} mode=0755'
- name: copy index.html to remote
copy: 'remote_src=no src=roles/nginx/files/index.html dest=/www/index.html mode=0755'
- name: restart nginx service
service: name=nginx state=restarted
- name: run the health check locally
shell: "sh roles/nginx/files/health_check.sh {{ server_name }}"
delegate_to: localhost
register: health_status
写回答
1回答
-
感谢这位同学的关注, 这部分代码是我们pipeline实战章节的编写的, 因为之前的ansible章节已经安装好了nginx服务, 所以这里就略过这个nginx安装部分, 这里仍然需要安装的话可以在重启nginx前添加这个安装task
- name: ensure nginx is at the latest version
yum: pkg=nginx state=latest
012019-01-09
相似问题