zoukankan      html  css  js  c++  java
  • 拿到新机器,进行初始化和部署Nginx的过程

    1. 在/etc/ansbile/hosts中添加主机init

    2. 在sysinit.yml中修改要初始化的机器:
       hosts: init

    3. 设置不检查key   
       export ANSIBLE_HOST_KEY_CHECKING=False

    4. 因为开启了selinux,所以需要安装libselinux-python
       ansible init -m shell -a 'yum install libselinux-python -y' -k

    5. 执行初始化
      ansible-playbook sysinit.yml -k
       
    6. 复制key到主机
       ssh-copy-id -i "/root/.ssh/id_rsa.pub" "-p 50000 lsyw@162.221.12.108"

    7. 测试key通信
       ####重新在hosts中编辑一个组nginx,然后配置group_vars:
       ansible_user: lsyw
       ansible_port: 50000
       ansible_su_password: "0xxxxx"

       ansible nginx -m ping

    8. 安装nginx
       在tengine_comm_deploy.yml中修改hosts为nginx
       执行命令:ansible-playbook tengine_comm_deploy.yml -S
       
    9. 部署d9导航页
       cd /root/distri     #切换到ansible源代码存放目录
       rz -y          #上传源代码到ansible主机
       ansible nginx -S -R root -m unarchive -a "src=d9_201608311030.zip  dest=/data"
       ansible nginx -S -R root -m shell -a "ln -s /data/d9_201608311030 /data/www"

       更新nginx配置文件:
        ansible nginx -S -R root -m shell -a "rm -rf /usr/local/gacp/nginx/conf/vhosts.d/*"
        ansible nginx -S -R root -m copy -a "src=www.d9.com.conf dest=/usr/local/gacp/nginx/conf/vhosts.d/"
        ansible nginx -S -R root -m shell -a "/sbin/service nginx reload"
        ansible nginx -S -R root -m shell -a "netstat -nl "

    10. 添加防火墙
        ansible nginx -S -R root -m shell -a "/sbin/iptables -I INPUT 5 -p tcp --dport 80 -m state --state NEW -j ACCEPT"
        ansible nginx -S -R root -m shell -a "/sbin/service iptables save"

  • 相关阅读:
    随笔
    随笔
    第一个存储过程
    mysql 存储过程
    join
    随笔
    玩家注册登录
    mysql 存储二进制数据
    mysql学习
    socket listen/accept
  • 原文地址:https://www.cnblogs.com/zhaojonjon/p/5830463.html
Copyright © 2011-2022 走看看