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. NETTY 心跳机制

    最近工作比较忙,但闲暇之余还是看了阿里的冯家春(fengjiachun)的github上的开源代码Jupiter,写的RPC框架让我感叹人外有人,废话不多说,下面的代码全部截取自Jupiter,写了一 ...

  2. soapui教程

    简介 SOAPUI,一款专业的web service的测试软件,SoapUI也是一个开源测试工具,通过soap/http来检查.调用.实现Web Service的功能/负载/符合性测试.该工具既可作为 ...

  3. git使用安装

    下载地址 http://msysgit.github.io/ 配置个人的用户名称和电子邮件地址: $ git config --global user.name "runoob" ...

  4. 帮你培养类型思维TypeScript(一)

    前言:作为一名程序员,相信你已经熟练掌握了JavaScript语言,由于其应用领域非常的广泛,所以算得上是每一个程序员必须要掌握的语言.但是JavaScript自身的缺点,相信每一个程序员也是深有体会 ...

  5. (模板)hdoj1251(字典树模板题)

    题目链接:https://vjudge.net/problem/HDU-1251 题意:给定一系列字符串之后,再给定一系列前缀,对每个前缀查询以该字符串为前缀的字符串个数. 思路: 今天开始学字典树, ...

  6. 过滤器( filter )的使用

    转自:https://www.jianshu.com/p/2ea2b0e4d1f2 过滤器通常 在 web 服务端用的比较多,有要功能 在客户端的请求访问后端资源之前,拦截这些请求. 在服务器的响应发 ...

  7. 利用Python进行数据分析 第6章 数据加载、存储与文件格式(2)

    6.2 二进制数据格式 实现数据的高效二进制格式存储最简单的办法之一,是使用Python内置的pickle序列化. pandas对象都有一个用于将数据以pickle格式保存到磁盘上的to_pickle ...

  8. WxWidgets与其他工具包的比较(15种方案)

    一些一般注意事项: wxWidgets不仅适用于C ++,而且具有python,perl,php,java,lua,lisp,erlang,eiffel,C#(.NET),BASIC,ruby甚至ja ...

  9. 多线程面试题之【三线程按顺序交替打印ABC的方法】

    建立三个线程,线程名字分别为:A.B.C,要求三个线程分别打印自己的线程名字,但是要求三个线程同时运行,并且实现交替打印,即按照ABCABCABC的顺序打印.打印10轮,打印完毕控制台输出字符串:&q ...

  10. 使用querySelector添加移除style和class

    document.querySelector(selector).style.styleName = 样式 对dom节点添加一个样式 document.querySelector(".nam ...