使用ansible playbook编写lnmp架构
- name: nginx play
gather_facts: false
hosts: lnmp
remote_user: root
tasks:
- name: stop firewalld
service: name=firewalld state=stopped
- name: syslinux
command: '/usr/sbin/setenforce 0'
ignore_errors: true
- name: nginx.repo
copy: src=/etc/yum.repos.d/nginx.repo dest=/etc/yum.repos.d/
- name: haha nginx
yum: name=nginx state=latest
- name: start nginx
command: systemctl start nginx
tags:
- nginx
- name: mysql play
gather_facts: false
hosts: lnmp
remote_user: root
tasks:
- name: copy install mysql
copy: src=/opt/mysql-community.repo dest=/etc/yum.repos.d/
- name: copy
copy: src=/opt/mysql-community-source.repo dest=/etc/yum.repos.d/
- name: install mysql
yum: name=mysql-server
- name: start mysqld.service
service: name=mysqld.service state=started
- name: chushihua
script: /etc/ansible/playbook/mysql.sh
- name: php play
gather_facts: false
hosts: lnmp
remote_user: root
tasks:
- name: install php
shell: rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
ignore_errors: True
- name: yum
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
yum: name={
{
item}}
- name: start php
service: name=php-fpm state=started
- name: scp nginx
copy: src=/etc/nginx/conf.d/default.conf dest=/etc/nginx/conf.d/default.conf
- name: restart nginx
service: name=nginx state=restarted
- name: index.php
copy: src=/usr/share/nginx/html/index.php dest=/usr/share/nginx/html/