ansible安装nginx1.18(用官方的yum源)
环境:centos7.6 ansible:2.9.13 nginx1.18
到nginx官网获得nginx官方yum源方法
2.找到对应版本的yum配置
将信息保存为nginx.reop文件
[root@localhost conf]# pwd
/root/ansible/nginx/conf
[root@localhost conf]# cat nginx.repo
[nginx-stable]
name=nginx stable repo
gpgcheck=1
enabled=1
module_hotfixes=true
编写playbook
[root@localhost nginx]# pwd
/root/ansible/nginx
[root@localhost nginx]# cat 1-install-nginx.yml
---
- hosts: k1
remote_user: root
tasks:
- name: copy nginx-yum-file
copy: src=/root/ansible/nginx/conf/nginx.repo dest=/etc/yum.repos.d/nginx.repo mode=0644
- name: install nginx
yum: name=nginx state=latest
- name : start nginx
service: name=nginx state=started
执行playbook
查看是否部署成功