roles
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的更多相关文章
- MongoDB的内置角色 Built-In Roles
关于芒果的权限控制说白了就是定义 Role(角色) 来控制对数据库进行的操作(调用的方法比如查询方法find). 系统内置的Role分为 以下几大类: Database User Roles 这个是针 ...
- Apple Developer Program Roles Overview
Apple Developer Program Roles Overview There are three roles that can be assigned to Apple Developer ...
- 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 ...
- 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 ...
- [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 ...
- Ansible系列(五):playbook应用和roles自动化批量安装示例
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- IdentityServer4 指定角色授权(Authorize(Roles="admin"))
1. 业务场景 IdentityServer4 授权配置Client中的AllowedScopes,设置的是具体的 API 站点名字,也就是使用方设置的ApiName,示例代码: //授权中心配置 n ...
- ansible roles
roles 特点 目录结构清晰 重复调用相同的任务 目录结构相同 web - tasks - install.yml - copfile.yml - start.yml - main.yml - t ...
- ansible基础-roles
一 简介 注:本文demo使用ansible2.7稳定版 在我看来,role是task文件.变量文件.handlers文件的集合体,这个集合体的显著特点是:可移植性和可重复执行性. 实践中,通常我们以 ...
- Ansible系列之roles使用说明
roles(角色)介绍 ansible自1.2版本开始引入的新特性,用于层次性,结构化地组织playbook.roles能够根据层次型结构自动装载变量文件.tasks以及handlers等.要使用ro ...
随机推荐
- LeetCode_349. Intersection of Two Arrays
349. Intersection of Two Arrays Easy Given two arrays, write a function to compute their intersectio ...
- 【 Linux 】Systemd 配置文件说明及编写(2)
1. 开机启动 对于支持 systemd 的软件,如果想要设置开机启动,就执行如下命令(以 http 为例): systemctl enable httpd 上面的命令相当于在 /etc/system ...
- keepalived+lvs tcp check 引起的后端服务报Connection reset by peer
方法一: 取消LVS方式进行tcp转发,进而改为http方式反向代理,问题即可解决. 当然,这是在业务允许使用http的情况下,如果必须使用tcp协议,那就得使用下面的方法了. 方法二: 修改keep ...
- 最新 博盾习言java校招面经 (含整理过的面试题大全)
从6月到10月,经过4个月努力和坚持,自己有幸拿到了网易雷火.京东.去哪儿. 博盾习言等10家互联网公司的校招Offer,因为某些自身原因最终选择了 博盾习言.6.7月主要是做系统复习.项目复盘.Le ...
- PDO 查询mysql返回字段int变为String型解决方法
PDO 查询mysql返回字段int变为String型解决方法使用PDO查询mysql数据库时,执行prepare,execute后,返回的字段数据全都变为字符型. 例如id在数据库中是Int的,查询 ...
- Tomcat 服务器介绍和使用
服务器的概念和作用: 问题: 学习了 java 编程之后,java 代码的一个很重要的作用就是进行数据的处理,但是目前来说我们运行编写的代码,只有一次性,也就是运行完毕后,如果需要再次运行则需要再次手 ...
- LeetCode 206. 反转链表(Reverse Linked List) 16
206. 反转链表 206. Reverse Linked List 题目描述 反转一个单链表. 每日一算法2019/5/19Day 16LeetCode206. Reverse Linked Lis ...
- NumPy使用图解教程
NumPy是Python中用于数据分析.机器学习.科学计算的重要软件包.它极大地简化了向量和矩阵的操作及处理.python的不少数据处理软件包依赖于NumPy作为其基础架构的核心部分(例如scikit ...
- [转帖]浅谈响应式编程(Reactive Programming)
浅谈响应式编程(Reactive Programming) https://www.jianshu.com/p/1765f658200a 例子写的非常好呢. 0.9312018.02.14 21:22 ...
- 关于String Json 与其他类型数据转换的总结:
一:关于自己遇到的坑: 跨域请求获取到 String Json(GSON处理) 数据后处理转换为实体类进行存储: 跨域 return Gson.toJson(map): 通过Http等方法获取请求结果 ...