设为首页 加入收藏

TOP

Ansible--项目实战(二)
2019-09-02 23:21:25 】 浏览:35
Tags:Ansible-- 项目 实战
ble roles]#
cat mysql_roles.yml #yum安装MySQL --- - hosts: all remote_user: root roles: - role: mysql [root@ansible roles]# cat lnmp.yml #配置lnmp,创建虚拟主机 --- - hosts: all remote_user: root roles: - role: nginx - role: php - role: mysql vars: PORT: 8081 WEBDIR: "/opt/www" CONFIGDIR: "/usr/local/nginx/conf/conf.d" tasks: - name: create vhost dir file: name={{ WEBDIR }} state=directory owner=www group=www mode=755 - name: create vhost conf template: src=vhost.conf.j2 dest={{ CONFIGDIR }}/vhost.conf notify: Restart Nginx - name: create index.php shell: "echo '<?php phpinfo(); ?>' > {{ WEBDIR }}/index.php" handlers: - name: Restart Nginx service: name=nginx state=restarted # hostslist文件准备,这样方便执行,可以在执行playbook时指定某台机器上运行 [root@ansible roles]# cat hostlist 192.168.1.31 192.168.1.32 192.168.1.33 192.168.1.36 #所有文件查看 [root@ansible roles]# ll 总用量 28 -rw-r--r--. 1 root root 53 6月 4 22:37 hostlist -rw-r--r--. 1 root root 824 6月 5 10:53 init_pkg.yml -rw-r--r--. 1 root root 646 6月 5 12:05 lnmp.yml drwxr-xr-x. 7 root root 77 6月 5 10:44 mysql -rw-r--r--. 1 root root 81 6月 5 10:06 mysql_roles.yml drwxr-xr-x. 7 root root 77 6月 4 15:37 nginx -rw-r--r--. 1 root root 89 6月 4 17:10 nginx_roles.yml drwxr-xr-x. 7 root root 77 6月 4 17:18 php -rw-r--r--. 1 root root 87 6月 4 17:37 php_roles.yml -rw-r--r--. 1 root root 811 6月 5 11:53 vhost.conf.j2

所有文件查看

[root@ansible roles]# tree 
.
├── hostlist
├── init_pkg.yml
├── lnmp.yml
├── mysql
│   ├── files
│   ├── handlers
│   │   └── main.yml
│   ├── tasks
│   │   ├── config.yml
│   │   ├── install.yml
│   │   ├── main.yml
│   │   └── service.yml
│   ├── templates
│   │   ├── my.cnf6.j2
│   │   └── my.cnf7.j2
│   └── vars
├── mysql_roles.yml
├── nginx
│   ├── files
│   │   ├── nginx-1.12.2.tar.gz
│   │   └── nginx-1.16.0.tar.gz
│   ├── handlers
│   │   └── main.yml
│   ├── tasks
│   │   ├── config.yml
│   │   ├── copypkg.yml
│   │   ├── group.yml
│   │   ├── install.yml
│   │   ├── main.yml
│   │   ├── service.yml
│   │   └── user.yml
│   ├── templates
│   │   ├── nginx.conf.j2
│   │   ├── nginx_init.j2
│   │   └── nginx.service.j2
│   └── vars
│       └── main.yml
├── nginx_roles.yml
├── php
│   ├── files
│   │   └── php-5.6.40.tar.gz
│   ├── handlers
│   │   └── main.yml
│   ├── tasks
│   │   ├── config.yml
│   │   ├── copypkg.yml
│   │   ├── group.yml
│   │   ├── install.yml
│   │   ├── main.yml
│   │   ├── service.yml
│   │   └── user.
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇vim简明教程--半小时从入门到精通 下一篇关于RabbitMQ

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目