ansible的playbook进行yum批量安装nginx最新版本

环境:centos7

版本:nginx最新版本

软件:  ansible

作用: 进行批量执行不同机器上,进行安装nginx版本



检查脚本是否正确:

[root@ansible-test ansible-yaml]# ansible-playbook  --syntax-check  nginx.yml

进行执行:

[root@ansible-test ansible-yaml]# ansible-playbook nginx.yml



具体脚本

[root@ansible-test ansible-yaml]# vim nginx.yml
---
- hosts: web
vars:
hello: ansible
tasks:
- name: add repo
yum_repository:
name: nginx
description: nginx repo
baseurl: http://nginx.org/packages/centos/7/$basearch/
gpgcheck: no
enabled: 1
- name: install centos plungins
shell: yum -y install zlib zlib-devel openssl openssl-devel pcre-devel wget gcc gcc++ autoconf automake

- name: install nginx
yum:
name: nginx
state: latest

- name: copy nginx configuration file
copy:
src: /opt/ansible-yaml/site.conf
dest: /etc/nginx/conf.d/site.conf

- name: create wwwroot directory
file:
dest: /var/www/html
state: directory
- name: create test page index.html
shell: echo "hello {{hello}}" > /var/www/html/index.html

- name: start nginx
service:
name: nginx
state: started

原文地址:https://www.cnblogs.com/qiangyuzhou/p/10572852.html

时间: 2024-10-29 03:11:07

ansible的playbook进行yum批量安装nginx最新版本的相关文章

CentOS7 yum 安装 Nginx最新版本

下载对应当前系统版本的nginx包(package)# wget  http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 建立nginx的yum仓库# rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm 下载并安装nginx# yum install nginx 启动nginx服务systemctl start ng

CentOS7使用yum安装nginx最新版本

(一)环境OS:CentOS Linux release 7.5.1804 (Core)Nginx:1.14.0 (二)安装步骤1.安装epel-release 源[[email protected] ~]# yum -y install epel-release 2.设置nginx安装源 [[email protected] ~]# vim /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/

centOS-64位通过YUM源安装nginx

第一步:在 /etc/yum.repos.d/ 目录下,建立名叫nginx.repo的软件源配置文件.        文件 nginx.repo 的内容是: [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 第二步:使用命令 yum install nginx ,按照提示即可安装完毕:第三步:使用命令 /etc/init.d/ng

centos7 yum 方式安装nginx

centos7  yum 方式安装nginx centos7系统库中默认是没有nginx的rpm包的,所以我们自己需要先更新下rpm依赖库 (1)使用yum安装nginx需要包括Nginx的库,安装Nginx的库 #rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm (2)使用下面命令安装nginx #yum install nginx (3)启动N

CentOS用yum快速安装nginx

增加nginx源 vim  /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 安装nginx yum -y install nginx 配置nginx vim /etc/nginx/nginx.conf

CentOS7下yum方式安装nginx

最近把centos升级到7,发现用之前的一些安装nginx的方法安装后有依赖包冲突,估计是 linux版本和nginx版本不匹配导致. 上官网查看文档, 有针对centos7的安装方法,记录下: step1:  创建yum数据源文件   /etc/yum.repos.d/nginx.repo step2: 编辑nginx.repo文件内容如下并保存 [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/$basear

yum安装nginx最新官网稳定版

1. 增加nginx yum仓库 vi /etc/yum.repos.d/nginx.repo CentOS增加这段: [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1 RHEL增加这段: [nginx] name=nginx repo baseurl=http://nginx.org/packages/rhel/$release

Centos 7.4 yum方式安装nginx

版本信息: OS: CentOS 7.4 Nginx: 1.14.0 1.创建nginx.repo仓库文件 #vi /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/7/x86_64/ gpgcheck=0 enabled=1 2.重建本地yum库缓存 #yum clean all #yum makecache local 3.安装nginx软件包 #yum i

Centos7 通过yum源安装nginx

通过rpm 添加yum源 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 安装 yum -y install nginx 设置启动nginx同时以开机自动运行 systemctl start nginx.service systemctl enable nginx.service 转自:https://www.cnblogs.com/Liang-