环境: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. 向Spring容器中注册组件的方法汇总小结

    1.通过xml定义 <bean class=""> <property name="" value=""></ ...

  2. Redirection

    Typically, the syntax of these characters is as follows, using < to redirect input, and > to r ...

  3. java.net.ProtocolException:unexpected end of stream

    原因:php 给android 写接口出现java.net.ProtocolException:unexpected end of stream,查找android方面原因时发现数据超长 ,发现htm ...

  4. 实现响应式——CSS变量

    CSS 变量是 CSS 引入的一个新特性,目前绝大多数浏览器已经支持了,它可以帮助我们用更少的代码写出同样多的样式,大大提高了工作效率,本篇文章将教你如何使用 CSS 变量(css variable) ...

  5. JS实现缓动效果-让div运动起来

    var tween = { linear:function(t,b,c,d){ return c*t/d + b; }, easeIn:function(t,b,c,d){ return c * ( ...

  6. 洛谷P3379 【模板】最近公共祖先(LCA)(树链剖分)

    题目描述 如题,给定一棵有根多叉树,请求出指定两个点直接最近的公共祖先. 输入输出格式 输入格式: 第一行包含三个正整数N.M.S,分别表示树的结点个数.询问的个数和树根结点的序号. 接下来N-1行每 ...

  7. font-face在ie无法识别问题

    font-face在ie的时候,需要其他格式eot,但是按照网上的设置无法识别,需要把原来的fotmat设置成format('eot');

  8. html 获取数据并发送给后端方式

    一.方式一 使用ajax提交 function detailed() { var date = $("#asset_ip").text() $.ajax({ url: " ...

  9. Python基础知识点

    自学记录: 1.字符串 python中单引号和双引号使用完全相同. 使用三引号('''或""")可以指定一个多行字符串. 转义符 '\' 反斜杠可以用来转义,使用r可以让 ...

  10. Stable Fur Generation on Mesh

    After tested the Maya 2015 XGen Grooming, we dropped it, that's really slow and unstable, totally no ...