目录
192.168.115.148:ansbile
192.168.115.149
192.168.115.151
设置防火墙、selinux
systemctl stop firewalld
setenforce 0
- [group]
- 192.168.115.148
- 192.168.115.149
- 192.168.115.151

- vim /etc/local.repo
- [local]
- name=local
- baseurl=file:///mnt
- enabled=1
- gpgcheck=0
- cd /etc/ansible/roles/
- mkdir -p {httpd,mysql,php,Discuz}/{files,tasks,handlers,templates,vars,meta}
- touch {httpd,mysql,php,Discuz}/{tasks,handlers,vars,meta}/main.yml
- tree
- .
- ├── Discuz
- │ ├── files
- │ ├── handlers
- │ │ └── main.yml
- │ ├── meta
- │ ├── tasks
- │ │ └── main.yml
- │ ├── templates
- │ └── vars
- ├── http
- │ ├── files
- │ ├── handlers
- │ ├── meta
- │ ├── tasks
- │ │ └── main.yml
- │ ├── templates
- │ └── vars
- ├── mysql
- │ ├── files
- │ ├── handlers
- │ ├── meta
- │ ├── tasks
- │ │ └── main.yml
- │ ├── templates
- │ └── vars
- └── php
- ├── files
- ├── handlers
- ├── meta
- ├── tasks
- │ └── main.yml
- ├── templates
- └── vars
- vim /ect/ansbile/roles/http/tasks/main.yml
- ---
- - name: 删除原来的yum源
- shell: rm -rf /etc/yum.repos.d/*
- - name: 分发本地源文件
- copy: src=/etc/local.repo dest=/etc/yum.repos.d/
- - name: 挂载本地sr0光盘
- shell: mount /dev/sr0 /mnt
- - name: 安装http服务
- yum: name=httpd state=present
- - name: 启动httpd服务,并设为开机自启
- service: name=httpd state=started enabled=yes
- - name: 删除httpd默认的访问网页
- shell: rm -rf /var/www/html/*
- vim /etc/ansible/roles/mysql/tasks/main.yml
- ---
- - name: 安装mysql
- shell: yum -y install mariadb mariadb-server
- - name: 启动mariadb设为开机自启
- shell: systemctl start mariadb && systemctl enable mariadb
- - name: 创建数据库hy
- shell: mysql -e 'create database hy;'
- - name: 创建用户qzh
- shell: mysql -e 'create user"qzh"@"localhosr" identified by "123.com";'
- - name: 为用户qzh授权hy库中的所有权限
- shell: mysql -e 'grant all privileges on hy.* to "qzh"@"localhost";'
- vim /etc/ansible/roles/php/tasks/main.yml
- ---
- - name: 安装php环境/依赖
- yum: name=php,php-gd,php-ldap,php-odbc,php-pear,php-xml,php-xmlrpc,php-mbstring,php-snmp,php-soap,curl,curl-devel,php-bcmath,php-mysql state=present
- vim /etc/ansible/roles/Discuz/tasks/main.yml
- ---
- - name: 分发论坛文件
- copy: src=/Discuz_X3.3_SC_UTF8.zip dest=/opt
- - name: 安装zip解压工具
- yum: name=unzip state=present
- - name: 解压论坛
- shell: cd /opt && unzip Discuz_X3.3_SC_UTF8.zip
- - name: 移动论坛文件
- shell: mv /opt/upload/* /var/www/html
- - name: 修改属主为Apache
- shell: chown -R apache /var/www/html/*
- notify: restart httpd
- vim /etc/ansible/lamp.yml
- ---
- - hosts: group
- remote_user: root
- roles:
- - http
- - mysql
- - php
- - Discuz
ansible-playbook /etc/ansible/lamp.yml




。
。
。
。


