环境:centos7

版本:nginx最新版本

软件: ansible

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


检查脚本是否正确:

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

进行执行:

[root@ansible-test ansible-yaml]# ansible-playbook 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

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

  1. CentOS7 yum 安装 Nginx最新版本

    CentOS7 yum 安装 Nginx最新版本 下载对应当前系统版本的nginx包(package) # wget  http://nginx.org/packages/centos/7/noarc ...

  2. Debian 8 安装Nginx最新版本

    在Debian下如果直接apt-get install nginx直接装发现nginx版本是很旧的,本文主要讲一下如何在Debian 8上装新版的nginx. 原文资料:https://nginx.o ...

  3. 阿里云 通过YUM源安装nginx

    阿里云centOS-6.3-64位通过YUM源安装nginx 第一步:在 /etc/yum.repos.d/ 目录下,建立名叫nginx.repo的软件源配置文件.   文件 nginx.repo 的 ...

  4. yum标准化安装nginx最新版

    yum标准化安装nginx最新版 cat > /etc/yum.repos.d/nginx.repo [nginx] name=nginx repo baseurl=http://nginx.o ...

  5. yum无法安装nginx,报错内容为1:nginx-1.14.2-1.el7_4.ngx.x86_64: [Errno 5] [Errno 2] 没有那个文件或目录

    yum命令安装nginx时报错:1:nginx-1.14.2-1.el7_4.ngx.x86_64: [Errno 5] [Errno 2] 没有那个文件或目录 一.问题原因:Python版本的问题 ...

  6. Centos8 Yum 安装Nginx指定版本

    查看系统和EPEL的nginx版本   dnf info nginx 通过官方 yum 源安装nginx       vi /etc/yum.repos.d/nginx.repo 列出所有版本    ...

  7. Git安装教程最新版本(国内gitee国外github)

    Git安装教程最新版本(国内gitee国外github) 欢迎关注博主公众号「Java大师」, 专注于分享Java领域干货文章, 关注回复「资源」, 获取大师使用的typora主题: http://w ...

  8. centos7 yum 方式安装nginx

    centos7系统库中默认是没有nginx的rpm包的,所以我们自己需要先更新下rpm依赖库 (1)使用yum安装nginx需要包括Nginx的库,安装Nginx的库 #rpm -Uvh http:/ ...

  9. 【nginx】利用yum源安装nginx

    先安装nginx的yum源 http://nginx.org/en/linux_packages.html#stable 找到链接,安装: rpm -ivh http://nginx.org/pack ...

随机推荐

  1. CSS基础知识思维导图xmind

    这是我根据自己的学习笔记整理的思维导图,WEB前端的知识很多,汇总来看会比较清晰.

  2. date('Y-m-d H:i:s',time()) 与 date('Y-m-d h:i:s',time())区别是什么

    date('Y-m-d H:i:s',time()) 按24小时制 date('Y-m-d h:i:s',time()) 按12小时制

  3. ListView子项点击无反应的解决办法

    在使用ListView控件的过程中,当子项包括Button或者CheckBoX等控件时,直接点击子项无反应,分析发现原来是Button,CheckBoX等控件会优先获取焦点,那么子项点击的焦点就被上述 ...

  4. CSS3效果:5种预载动画效果

    实现如图所示的动画效果: 预载动画一:双旋圈 在两个不同方向旋转的圆圈.我们对内圈的转速定义了一个CSS代码,即内圈比外圈的速率快2倍.实现如图所示: html代码: <body style=& ...

  5. UOJ#310. 【UNR #2】黎明前的巧克力(FWT)

    题意 题目链接 Sol 挂一个讲的看起来比较好的链接 然鹅我最后一步还是没看懂qwq.. 坐等SovietPower大佬发博客 #include<bits/stdc++.h> using ...

  6. 洛谷P5205 【模板】多项式开根(多项式sqrt)

    题意 题目链接 Sol 这个就很没意思了 求个ln,然后系数除以2,然后exp回去. #include<bits/stdc++.h> #define Pair pair<int, i ...

  7. 【20190226】CSS-知识点记录::nth-child,:nth-of-type

    :nth-child: ele:nth-child(k):选择父元素下第k个子元素,且该子元素为ele,若不是,则选择失败,k从1开始计数 ele:nth-child(-n+5):选中前五个子元素,n ...

  8. 照葫芦画瓢系列之Java --- eclipse下使用maven创建Struts 2项目

    一.创建Maven项目 http://www.cnblogs.com/zhanqun/p/8425571.html 二.添加struts2核心依赖包以及其他依赖项 打开pom.xm配置界面 点击Add ...

  9. 客户化软件时代的前夜 ZT

    制造业:从手工模式到大规模生产,再到大规模定制 工业革命开始以后,机器全面代替了手工工具.随着工业经济的不断发展,机器的使用导致了两种截然不同的方式.一种是手工生产基本思想的延续,另一种则是大规模生产 ...

  10. 折半插入排序算法的C++实现

    折半插入排序思想和直接插入排序类似. 1)找到插入位置: 2)依次后移正确位置及后面的元素. 区别是查找插入位置的方法不同. 折半插入排序使用的折半查找法在一个已经有序的序列中找到查找位置. 注意,折 ...