zoukankan      html  css  js  c++  java
  • 第七章 Ansible模块搭建作业平台

    一、上传包

    1.上传php.tar.gz
    2.上传代码包kaoshi.zip
    

    二、配置主机清单

    [root@m01 ~]# vim /etc/ansible/hosts
    [web_group]
    web01 ansible_ssh_password='1'
    [nfs_group]
    nfs ansible_ssh_password='1'
    
    #配置hosts
    [root@m01 ~]# vim /etc/hosts
    172.16.1.7 web01
    172.16.1.31 nfs
    

    三、编写配置文件

    [root@m01 ~]# vim /etc/httpd/conf/httpd.conf
    User www
    Group www
    
    [root@m01 ~]# cp /etc/httpd/conf/httpd.conf ./
    

    四、编写ansible脚本

    #1.安装httpd
    ansible 'web_group' -m yum -a 'name=httpd state=present' &&\
    #2.解压php.tar.gz
    ansible 'web_group' -m unarchive -a 'src=/root/php.tar.gz dest=/tmp/' &&\
    #3.安装php
    ansible 'web_group' -m shell -a 'yum localinstall -y /tmp/*.rpm' &&\
    #4.解压代码
    ansible 'web_group' -m unarchive -a 'src=/root/kaoshi.zip dest=/var/www/html' &&\
    #5.创建文件上传目录
    ansible 'web_group' -m file -a 'path=/var/www/html/upload state=directory' &&\
    #6.创建用户组
    ansible 'all' -m group -a 'name=www gid=666 state=present' &&\
    #7.创建用户
    ansible 'all' -m user -a 'name=www uid=666 group=www state=present' &&\
    #8.授权代码目录
    ansible 'web_group' -m file -a 'path=/var/www state=directory owner=www group=www recurse=yes' &&\
    #9.配置httpd
    ansible 'web_group' -m copy -a 'src=/root/httpd.conf dest=/etc/httpd/conf/' &&\
    #10.启动httpd
    ansible 'web_group' -m systemd -a 'name=httpd state=started enabled=yes' &&\
    #11.安装nfs服务端
    ansible 'nfs_group' -m yum -a 'name=nfs-utils state=present' &&\
    #12.配置nfs
    ansible 'nfs_group' -m copy -a 'content="/data 172.16.1.0/24(rw,sync,all_squash,anonuid=666,anongid=666)" dest=/etc/exports' &&\
    #13.创建共享目录
    ansible 'nfs_group' -m file -a 'path=/data state=directory owner=www group=www' &&\
    #14.启动NFS
    ansible 'nfs_group' -m systemd -a 'name=nfs state=started' &&\
    #15.挂载
    ansible 'web_group' -m mount -a 'src=172.16.1.31:/data path=/var/www/html/upload fstype=nfs opts=defaults state=mounted'
    
  • 相关阅读:
    poj3192
    poj3511
    cnblogs太好了,让我能在开发时使用微软雅黑!!
    用ftp实现大文件上传
    学习.net必看的书:Scott Mitchell ASP.NET 2.0(pdf)
    c#实现ftp功能
    猛然发现c学的好不精阿!!
    OFFICE 大全简介(转自网络)
    c# 实现文件浏览功能
    IntelliSense
  • 原文地址:https://www.cnblogs.com/jhno1/p/15723188.html
Copyright © 2011-2022 走看看