nginx 官方下载

[root@ansible roles]# tree yngx
yngx
├── defaults
├── files
│   ├── blog.conf
│   ├── edusoho-8.2..tar.gz
│   ├── nginx.repo
│   ├── WeCenter_v3.1.9.zip
│   └── wordpress-5.0.-zh_CN.tar.gz
├── handlers
│   └── main.yml
├── tasks
│   ├── load.yml
│   ├── main.yml
│   └── main.yml.bak
├── template
└── vars
└── main.yml
变量
[root@ansible yngx]# cat vars/main.yml
user: www
group: www
dir: /code/
官方yum源
[root@ansible files]# cat nginx.repo 
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1 任务剧本
[root@ansible yngx]# cat tasks/main.yml
- name: cp ngxconf
copy: src=blog.conf dest=/etc/nginx/conf.d
notify: restart ngx
tags: restart ngx - name: cp repo
copy: src=nginx.repo dest=/etc/yum.repos.d/ - name: ingx
yum: name=nginx state=installed - name: chang ngx user
shell: sed -i '/^user/c user www;' /etc/nginx/nginx.conf - include: load.yml
tags: load - name: start ngx
service: name=nginx state=started enabled=yes
下载产品

[root@ansible yngx]# cat tasks/load.yml
- name: load pag
get_url: url={{ item }} dest=/code/
with_items:
- https://cn.wordpress.org/wordpress-5.0.2-zh_CN.tar.gz
- http://ahdx.down.chinaz.com/201605/WeCenter_v3.1.9.zip
- http://download.edusoho.com/edusoho-8.2.17.tar.gz
解压
- name: tar
unarchive: src=files/{{ item }} dest=/code/ owner={{ user }} group={{ group }} copy=yes
with_items:
- wordpress-5.0.-zh_CN.tar.gz
- edusoho-8.2..tar.gz
#- WeCenter_v3.1.9.zip
tags: load
nginx配置文件
[root@ansible files]# cat blog.conf
server {
listen ;
server_name blog.oldboy.com;
root /code/wordpress;
index index.php index.html; location ~ \.php$ {
root /code/wordpress;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}

安装php7.2剧本

[root@ansible roles]# tree yphp
yphp
├── files
├── handlers
│   └── main.yml
├── tasks
│   └── main.yml
└── vars
[root@ansible tasks]# cat main.yml 
- name: install three epel
yum: name=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm state=installed
- name: install three epel
yum: name=https://mirror.webtatic.com/yum/el7/webtatic-release.rpm state=installed - name: chang www
shell: sed -i '/^user/c user = www' /etc/php-fpm.d/www.conf - name: chang www
shell: sed -i '/^group/c group = www' /etc/php-fpm.d/www.conf - name: del pag
yum: name={{ item }} state=absent
with_items:
- php-mysql-5.4
- php
- php-fpm
- php-common - name: insatll php
yum: name={{ item }} state=latest
with_items:
- php72w
- php72w-cli
- php72w-common
- php72w-devel
- php72w-embedded
- php72w-gd
- php72w-mbstring
- php72w-pdo
- php72w-xml
- php72w-fpm
- php72w-mysqlnd
- php72w-opcache - name: start php
service: name=php-fpm state=started enabled=yes

用户目录,基础任务

[root@ansible roles]# tree base/
base/
├── defaults
├── tasks
│   ├── dir.yml
│   ├── main.yml
│   └── user.yml
└── vars
└── main.yml

[root@ansible base]# cat vars/main.yml
user: www
group: www
appdir: /code

[root@ansible tasks]# cat dir.yml
- name: create {{ dir }}
  file: path=/code state=directory

[root@ansible tasks]# cat dir.yml
- name: create {{ dir }}
file: path=/code state=directory
[root@ansible tasks]# cat user.yml
- name: create group
  group: name={{ group }} gid=777 system=yes
- name: create user
  user: name={{ user }} uid=777 system=yes group={{ group }}

[root@ansible tasks]# cat main.yml
- include: dir.yml
- include: user.yml

命令行可执行 剧本里定义的 tags

ansible-playbook -C -t cp lnmp.yml

roles的更多相关文章

  1. MongoDB的内置角色 Built-In Roles

    关于芒果的权限控制说白了就是定义 Role(角色) 来控制对数据库进行的操作(调用的方法比如查询方法find). 系统内置的Role分为 以下几大类: Database User Roles 这个是针 ...

  2. Apple Developer Program Roles Overview

    Apple Developer Program Roles Overview There are three roles that can be assigned to Apple Developer ...

  3. Show Roles Assigned to a Specific User

     Here is a query that I often use to lookup Roles assigned to a specific PeopleSoft user. At run tim ...

  4. Developers, do consider different user roles! - A bad experience with cron

    The Story: Last week, I found one of our embedded arm linux device  ran out of flash space( totally ...

  5. [Hive - LanguageManual] Create/Drop/Grant/Revoke Roles and Privileges / Show Use

    Create/Drop/Grant/Revoke Roles and Privileges Hive Default Authorization - Legacy Mode has informati ...

  6. Ansible系列(五):playbook应用和roles自动化批量安装示例

    html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...

  7. IdentityServer4 指定角色授权(Authorize(Roles="admin"))

    1. 业务场景 IdentityServer4 授权配置Client中的AllowedScopes,设置的是具体的 API 站点名字,也就是使用方设置的ApiName,示例代码: //授权中心配置 n ...

  8. ansible roles

    roles 特点 目录结构清晰 重复调用相同的任务 目录结构相同 web - tasks - install.yml - copfile.yml - start.yml -  main.yml - t ...

  9. ansible基础-roles

    一 简介 注:本文demo使用ansible2.7稳定版 在我看来,role是task文件.变量文件.handlers文件的集合体,这个集合体的显著特点是:可移植性和可重复执行性. 实践中,通常我们以 ...

  10. Ansible系列之roles使用说明

    roles(角色)介绍 ansible自1.2版本开始引入的新特性,用于层次性,结构化地组织playbook.roles能够根据层次型结构自动装载变量文件.tasks以及handlers等.要使用ro ...

随机推荐

  1. Nginx - upstream sent invalid chunked response while reading upstream 异常问题

    一个 post 的请求,直接调接口服务数据正常返回,但是通过 nginx 代理后, 什么都没有返回. nginx 配置如下: 使用 postman 调用,返回如下: 于是检查日志报错信息,如下: ng ...

  2. v-for key的作用

    v-for中的key来给每个节点做一个唯一的标识,diff算法就可以正确的识别此节点,找到正确的位置区插入新的节点:key的主要作用是为了高效的更新虚拟dom,另外vue在使用相同标签名元素的过渡切换 ...

  3. CHIMA网络安全攻防大赛经验分享

    比赛模式 第一轮:20分钟基础知识赛(50道题) 安全运维,法律法规,linux操作系统等 第二轮:50分钟CTF夺旗(5道题) 题目涵盖 密码学 运用多种工具,如ASCII对照,古典密码,凯撒密码, ...

  4. Python离线环境

    一.应用场景 比如:对于数据安全要求比较严格的机房,服务器是不允许上网的.那么我现在开发了一套python程序,需要一些模块,怎么运行? 二.离线包制作 有2个解决方案: 1. 使用requireme ...

  5. 解决ubuntu的firefox上网速度慢【转】

    在ubuntu上用firefox上网十分慢,但是在切换了chrome后发现上网速度很快,是解析域名上出现了问题,所以要为FF设置DNS缓存以提高速度.(在WIN下这个是自动设置好的,在ubuntu下需 ...

  6. 管道式编程(Pipeline Style programming)

    受 F# 中的管道运算符和 C# 中的 LINQ 语法,管道式编程为 C# 提供了更加灵活性的功能性编程.通过使用 扩展函数 可以将多个功能连接起来构建成一个管道. 前言 在 C# 编程中,管道式编程 ...

  7. 030 Android 第三方开源下拉框:NiceSpinner的使用+自定义Button样式+shape绘制控件背景图+图片选择器(selector)

    1.NiceSpinner下拉框控件介绍 Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Android原生提供的下拉框 ...

  8. Python23之内置函数filter()和map()

    首先我们了解一个概念:迭代 迭代是访问集合元素的⼀种⽅式.迭代器是⼀个可以记住遍历的位置的对象.迭代器对象从集合的第⼀个元素开始访问,直到所有的元素被访问完结束.迭代器只能往前不会后退. 我们已经知道 ...

  9. 使用脚本将AspNetCore发布到IIS上

    首先你必须要了解的是,没有脚本的情况下,如何把AspNetCore的应用发布到IIS上. 大致分为这些步骤: 安装MS C++ 2015 x86&x64 安装正确版本的.NET Core Ru ...

  10. springboot调用mongo

    目录 添加 删除 文档操作更新 简单聚合操作 count, distinct 普通查询 分组 group Aggregate mapReduce 分页查询 文件上传 文件下载 随便测试了一下,有问题请 ...