项目实战1一键自动化部署小规模集群架构


  • hosts: NFS
    tasks:

    • name: yum -y install nfs rpcbind nfs-utils #安装插件
      shell: yum -y install nfs rpcbind nfs-utils libselinux-python
    • name: qidong
      shell: service rpcbind start #启动RPC
    • name: mulu
      shell: test -d /data || mkdir /data #测试目录 然后创建
    • name: chuansongtupian
      copy: src=/root/tupian/qq.png dest=/data 给NFS服务器上data里传个图片
    • name: echo
      shell: echo “/data 192.168.200.0/24(rw,sync,all_squash)” > /etc/exports #修改NFS服务器上的文件
    • name: qidong2
      shell: service nfs start
    • name: quanxian
      shell : chown nfsnobody.nfsnobody /data #给data程序用户
  • hosts: nginx
    tasks:

    • name: anzhuang
      shell: yum -y install nfs-utils lrzsz vim net-tools gcc gcc-c++ ncurses ncurses-devel unzip zlib-devel zlib openssl-devel openssl libffi-devel epel-release libselinux-python
    • name : mulu
      shell : test -d /usr/local/nginx/html/static || mkdir /usr/local/nginx/html/static
    • name : guazai
      shell : mount 192.168.200.142:/data /usr/local/nginx/html/static
    • name : copy nginx.conf
      copy : src=/root/web/nginx.conf dest=/usr/local/nginx/conf/ #把ansible服务器上的配置文件给web发过去
    • name : qidong
      shell : /usr/local/nginx/sbin/nginx
    • name: check
      shell: /usr/local/nginx/sbin/nginx -t #测试
      register: nginx_result
    • debug: var=nginx_result
  • hosts: lb
    tasks:

    • name: anzhuang
      shell: yum -y install lrzsz vim net-tools gcc gcc-c++ ncurses ncurses-devel unzip zlib-devel zlib openssl-devel openssl libffi-devel epel-release libselinux-python
    • name: copy nginx.conf
      copy: src=/root/nginx/nginx.conf dest=/usr/local/nginx/conf/ #把ansible服务器上的配置文件给反向代理发过去
    • name: /usr/local/nginx/sbin/nginx
      shell: /usr/local/nginx/sbin/nginx
    • name:
      shell: /usr/local/nginx/sbin/nginx -t
      register: nginx_result
    • debug: var=nginx_result

当然用标准化是最简单明了的。这里不做演示。仅供参考

你可能感兴趣的:(项目)